This is a Laravel Laravel 5.* based project.
- PHP 7.*+ (for Laravel 5.5+ framework)
- Node.js 6.*+
- Redis 3+
- Laravel Echo Server 1.3.*+ installed globally
- PM 2 (Optional : Run Laravel Echo Server as a "daemon")
Run this command and make sure to chmod properly the storage and cache folders.
composer create-project --prefer-dist rygilles/laravel-api-boilerplate your-project-nameOr install this project manually by cloning with git. In this case, you must copy the .env.example file to .env and run this command :
php artisan key:generateCheck the .env file and change the values according to you preferences.
This project uses the same libraries as Laravel common projects.
But also (Check composer.json and package.json file for details) :
- alsofronie/eloquent-uuid for User, UserGroup and Notification models.
- bugsnag/bugsnag-laravel for debug purpose (Set BUGSNAG_API_KEY in your .env file).
- dingo/api for Api features.
- felixkiss/uniquewith-validator for advanced validation rule.
- filp/whoops for better error display in debug mode.
- predis/predis for interactions with redis server and laravel-echo-server.
- rygilles/laravel-apidoc-generator for generating Api documentation.
- rygilles/laravel-openapi-schema-generator for generating Open API json file.
- laravel-echo : Laravel Echo is a JavaScript library that makes it painless to subscribe to channels and listen for events broadcast by Laravel.
- socket.io-client : Realtime application framework (client) used with Laravel Echo.
- nikic/php-parser : PHP parsing (Used with the
php artisan app:makeApiModelResourcecommand). - twig/twig : Twig template rendering (Used with the
php artisan app:makeApiModelResourcecommand). - barryvdh/laravel-ide-helper package : Tool for generating Laravel definitions (PhpDoc) php file. Adding auto-complete in your IDE.
Vue.js :
- vue : Vue.js javascript framework for back-office UI.
- vuex : Centralized state management for Vue.js.
- vue-router : Official router for Vue.js.
- vue-i18n : Translations management in Vue.js.
- vue-gravatar : A dead-simple gravatar component for Vue.js.
Graphics :
- admin-lte : Back-office dashboard and control panel.
- bootstrap-less and bootstrap-sass : Used with AdminLTE.
- node-sass : Used with AdminLTE.
- font-awesome : Used with AdminLTE.
- ionicons : Used with AdminLTE.
- noty : Live notifications UI.
- datatables.net-select-dt : Used for custom data table component styles.
Laravel :
- laravel-mix : An elegant wrapper around Webpack for the 80% use case.
- cross-env : Cross platform setting of environment scripts.
Miscellaneous :
- jquery : Used with AdminLTE.
- axios : Authentication and Api requesting.
- pace : Dynamic loading bar (Top of the screen).
- lodash : JavaScript utility library used with Vue.js.
- moment : Dates formatter.
This application use InnoDB tables for foreign keys constraint support and utf8mb4_unicode_ci encoding for modern chars support (including emoji). It also use UUID (128 bits).
Run this command to create the database basics with default migrations (check database/migrations directory).
Make sure Redis is installed properly.
php artisan app:makeFreshThis will install :
Laravel basic tables : user, password_resets, notification, jobs
Passport bundle tables : oauth_auth_codes, oauth_access_tokens, oauth_refresh_tokens, oauth_clients_table, oauth_personal_access_clients)
Boilerplate tables : i18n_lang, user_group
An Artisan command (See below) can supply your database with samples data for users, projects, etc, for testing and documentation generation purpose.
Check database/seeds/Samples folder for more information.
| User ID | User Group ID | Name | Password | |
|---|---|---|---|---|
41abdec2-1389-11e7-93ae-92361f002671 |
Developer | John Doe | [email protected] | johndoe |
509dd5c0-1389-11e7-93ae-92361f002671 |
Support | Alan Smithee | [email protected] | alansmithee |
605c7610-1389-11e7-93ae-92361f002671 |
End-User | John Smith | [email protected] | johnsmith |
82b5da82-138c-11e7-93ae-92361f002671 |
End-User | Mickey Mouse | [email protected] | mickeymouse |
Install NodeJs dependencies (check package.json file for more information).
npm installCreate your own back-office images by replacing :
- resources/assets/img/dashboard-logo.png (50 x 200)
- resources/assets/img/dashboard-mini-logo.png (50 x 50)
- resources/assets/img/favicon.jpg
Check the webpack.mix.js to enable favicon.jpg copy and manage you own assets.
Run this command to compile the assets
npm run devReal-time notifications and events are send by a local Node.js server, using Redis and Socket.io.
The whole process is handled by laravel-echo-server.
Initialize Laravel Echo Server by creating laravel-echo-server.json configuration file with this command :
laravel-echo-server initUse PM2 for auto-restart feature
Make sure you've configured all in laravel-echo-server.ecosystem.config.json file. :
pm2 start laravel-echo-server.ecosystem.config.jsonOr use this command to manually start the server :
laravel-echo-server startphp artisan app:makeFreshThis command will reset/refresh migrations, re-create required database data and (optionally) create a fresh app with samples data.
php artisan app:generateApiDocsGenerate API documentation using current database resources.
Make sure you've configured all in config/apidocs.php file.
php artisan app:makeApiModelResourceOnly in development environment !
Generate and MODIFY source files to add a new model with related files :
- Model : Created in app/Models folder.
- Migration (Optional) : Created in database/migrations folder.
- Init seeder (Optional) : Created in database/seeds folder. That will also MODIFY the database/seeds/InitSeeder.php file !
- Samples seeder (Optional) : Created in database/seeds/Samples folder. That will also MODIFY the database/seeds/Samples/SamplesSeeder.php file !
- Controller (Optional) : Created in app/Http/Controllers/Api folder. That will also MODIFY the routes/api.php file !
- Requests : Will be generated if "store" method or "update" method making is wanted. In app/Http/Requests folder.
- Transformer : Will be generated if needed. In app/Http/Transformers/Api folder.
During this command execution, the Laravel application will be down (php artisan down then php artisan up at the end, called implicitly).
Composer dump autoloads will be called at the end.
php artisan app:makeApiModelResourceAssetsOnly in development environment !
Generate and MODIFY basic assets source files for a new resource model in the dashboard :
- Resource model list vue component : Created in resources/assets/js/components/dashboard folder.
- Resource model item vue component : Created in resources/assets/js/components/dashboard folder.
- Resource model locales js files : Created in resources/assets/js/locales folder (one file per locale).
- Routes locales js files resources/assets/js/locales/en/routes.js and other locales file : MODIFY to add resource model list and item routes.
- Vuex store js file resources/assets/js/store.js : MODIFY to add resource model state, getters, mutations and actions.
- Routes js file resources/assets/js/routes.js : MODIFY to add resource model list and item routes.
- Side-bar menu vue component file resources/assets/js/components/includes/sidebar-menu.vue : MODIFY to add resource model links (interactive).
During this command execution, the Laravel application will be down (php artisan down then php artisan up at the end, called implicitly).
Make sure to run npm run dev or npm run watch to check your assets compilation.
(Upcoming upgrades to do : Model resource analysis to complete new components fields and other stuff like this.)
php artisan openApiSchemas:generateThis command is provided by the rygilles/laravel-openapi-schema-generator package.
It will analyze your laravel project files and generate a openapi json file, describing the capabilities of your Api.
Check the config/openapischemas.php configuration file before running this command.
Some information can not be retrieve automatically by the script, you might update/add data in the "openapi_bindings" configuration array.
php artisan ide-helper:generateThis command is provided by barryvdh/laravel-ide-helper package.
Only for development environment
This package generates a file that your IDE understands, so it can provide accurate autocompletion. Generation is done based on the files in your project, so they are always up-to-date. If you don't want to generate it, you can add a pre-generated file to the root folder of your Laravel project (but this isn't as up-to-date as self generated files).