Lumen quick-start boilerplate with common functionality like user management, authentication and email notifications.
This project is a quick-start boilerplate of the PHP micro-framework
Lumen to start an API backend project
with the common functionality out of the box like user management, authentication
and email notifications.
It’s recomended for API projects that implement the JSON API specification (http://jsonapi.org/).
ams-bl is a backend project that matches the frontend project ams-be
developed with the Javascript framework Ember.js and
may be set up with the ams-bel architecture
(though other frontend and architecture may be used).
This project uses following packages:
Download or fork this project and take it as the starting point of your own project.
Set file and directory permissions:
$ sudo chown -R <user-name>:<group-name> ams-bl/
$ find ams-bl/ -type d -exec chmod 755 {} \;
$ find ams-bl/ -type f -exec chmod 644 {} \;
Files and directories within “storage/” directory need to be writable for the web server user.
$ sudo chgrp -R www-data ams-bl/storage/
$ find ams-bl/storage/ -type d -exec chmod 775 {} \;
$ find ams-bl/storage/ -type f -exec chmod 664 {} \;
On command line inside the project directory:
$ composer install
Create the .env
file by copying .env.example
:
$ cp .env.example .env
Set the application key with the command (from Flipbox Lumen Generator package):
$ php artisan key:generate
Set the application secret to hash the signature of the JSON Web Tokens (JWT):
$ php artisan jwt:secret
Configure .env
file with the Mailgun data.
Create MySQL database and user:
$ mysql -u <user> -p
mysql> create database ams_bel;
mysql> create user '<user_name>'@'localhost' identified by '<password>';
mysql> grant all on ams_bel.* to '<user_name>'@'localhost';
mysql> show grants for '<user_name>'@'localhost';
Configure .env
file with the database data and run migrations:
$ php artisan migrate
To serve the project locally, on command line in the project directory (command
from Flipbox Lumen Generator package):
$ php artisan serve
After creating your own project from this one, add your own files to the
existing ones.
You can modify the existing files on the project you’ve created. The key
files are located in:
tests/
app/Helpers/
app/Http/Controllers/
app/JsonApi/
app/Mail/
app/Models/
resources/views/mail/
$ vendor/phpunit/phpunit/phpunit --verbose # --verbose shows incomplete and skipped tests (if @depends is used)
Lumen does not have emailing functionality. It’s one of the features lost when
stripping down Laravel to obtain a micro framework.
The steps followed to add emailing functionality are described on:
Email sending and exception handling are performed on app/Helpers/MailHelper.php
.
More info on Laravel documentation:
https://laravel.com/docs/5.6/mail
Emails may be previewed on browsers enabling specific routes as you can see on
routes/web.php
.
The email routes are available for testing purposes but on production
environments remove them from routes/web.php
,
or at least comment them if you expect to be needing them often.
To test the emailing functionality, the mail driver is set to log
so that emails
are not sent but written on the app log (storage/logs/lumen.log
).
Thus, use config(['mail.driver' => 'log']);
as you can see on
tests/MessagingTest.php
.
MIT License. Please see LICENSE file for more information.