/lumen-dingo-boilerplate

RESTful API template made from lumen and extended by dingo/api.

Primary LanguagePHPMIT LicenseMIT

Build Status

RESTful API template made from Lumen 6 and extended by dingo/api.

Old version of Lumen

Lumen
5.8
5.7

Installation

1. Download

Clone/Download this repository place on your server. (I highly recommend you use either Laravel Homestead or Laravel Valet, to get the optimal server configuration and no errors through installation.)

2. Environment Files

This boilerplate comes with a .env.example file in the root of the project.

Copy env.example to .env where you prepare your environment.

Note: Make sure you do not rename .env.example, for team purposes.

3. App Key

Lumen has no php artisan key:generate. You can research how to add APP_KEY in Lumen. search here

You can also try to run:

php -a # An interactive php shell

echo substr(md5(rand()), 0, 32); # Generating 32 character string

4. Composer

Lumen/Dingo boilerplate dependencies are managed through the PHP Composer tool. Install the depencencies by navigating into your project in terminal and typing this command:

composer install

After that run :

composer fresh

This will migrate tables, seed fake data to your database, and install laravel passport.

See composer.json > scripts index.

Login using OAuth2 by laravel/passport

1. Installation

Install laravel passport by navigating into your project in terminal and run this command:

php artisan passport:install

This will generate Client ID and Client Secret.

2. Access Tokens

Use the Client ID and Client Secret of password grant for OAuth2 - Login (Password grant) endpoint.

Do not forget to add Headers

  • Accept = application/x.lumen.dingo.boilerplate.v1+json (Depends on your API_SUBTYPE value in your environment if api strict mode is enabled).
  • Content-Type = application/x-www-form-urlencoded.

API Documentation

You should run this command in your project directory first:

npm install apidoc -g

To generate the API documentation run this command:

php artisan apidocs

You can visit the generated API documentation in http://lumen-dingo-boilerplate.test/docs.

screenshot from 2018-12-31 11-09-41 screenshot from 2018-12-31 11-09-56

PHPUnit

You can view integration here

In your project directory run this command:

First run this command to create database.sqlite in database folder. this make testing database faster

composer db

Then run phpunit

vendor/bin/phpunit

Notes:

  • If you running this via Homestead's ssh, you can this command: phpunit (in your project directory).
  • Run composer coverage to see code coverage via html.
  • Run composer coverage-txt to see code coverage via terminal.

Built With

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License.

Todo

  • Log viewer
  • Documentation private route with permission
  • Localization
  • Code Generator
  • Seeder for Test/Production separately
  • Manage seeder for permissions
  • Include Postman collection/Config/Preset
  • Wiki
  • Firewall
  • Social login

Soon web interface