Lumen API scaffolding is a barebone lumen application with a few pre-installed packages required for development & production environment.
If you don't know how to build lumen application from scratch or you need to start your project painlessly, this project may help you.
This branch contains Lumen 6.x
. Check other branches for other another lumen versions.
This project comes with docker
& docker-compose
. But to minimize the boot up time when you try docker-compose up -d --build
the local files are mounted to application & worker containers and NOT COPIED TO CONTAINERS.
Thus, it's recommended to use PHP & composer locally. Resolve your project dependency before you run your application using composer install
.
This project contains,
nginx
for web server.postgres
/mysql
for database.redis
for cache.beanstalkd
for queue driver.beanstalk-console
as beanstalk's admin tool.
require
packages
- For Authentication: tymon/jwt-auth
- Guzzle wrapper for HTTP Request: anik/apiz
- Laravel type form request validation: anik/form-request
- For Redis: illuminate/redis
- For Cors: nordsoftware/lumen-cors
- For NewRelic: nordsoftware/lumen-newrelic
- For queue with Beanstalk: pda/pheanstalk
- For UUID: ramsey/uuid
- For Sentry: sentry/sentry-laravel
require-dev
packages
- For missing Laravel commands: flipbox/lumen-generator
- Clone the repository.
- Switch to appropriate branch for the Lumen version you want to use.
cp docker-compose.yml.example docker-compose.yml
.- Make the required changes to your
docker-compose.yml
. cp .env.example .env
.- Make the required changes to your
.env
. docker-compose up -d --build
to build your containers.- Loading
http://127.0.0.1:{NGINX_PORT}
in your browser will return a json response.
REPORT_TO_SENTRY
- set tofalse
if you don't want to use sentry.SENTRY_LARAVEL_DSN
- to send your error messages to sentry.JWT_*
- settings for JWT package it uses.REDIS_*
- configuration forredis
as cache.BS_*
- configuration for Beanstalk for your queue driver.BS_DEFAULT_QUEUE
- if you run your queue supervisor without providing queue name, set comma separated values here.QUEUE_REDIS_CONNECTION
- Redis connection name if you want to useredis
as your queue driver.QUEUE_REDIS_*
- Will use these settings for redis queue driver set byQUEUE_REDIS_CONNECTION
QUEUE_REDIS_DEFAULT_QUEUE
- if you run your queue supervisor without any queue name, set comma separated values here.ENABLE_QUERY_LOG
- setfalse
to disable ortrue
to enable.daily
to enable and log in ./storage/logs/query-{Y-m-d}.log file.LOG_HTTP_REQUEST
- settrue
to enable orfalse
to disable when usingApp\Service\AbstractApiService
on behalf of APIZ package to Communicate with remote service.SERVICE_*
- Timeouts when usingApp\Service\AbstractApiService
class on behalf of APIZ.VERIFY_SSL
- SSL Verification when usingApp\Service\AbstractApiService
class on behalf of APIZ.
- In
bootstrap/app.php
, change
$app->instance(Illuminate\Contracts\Debug\ExceptionHandler::class,
new Nord\Lumen\ChainedExceptionHandler\ChainedExceptionHandler(new App\Exceptions\Handler(), [
new Nord\Lumen\NewRelic\NewRelicExceptionHandler(),
]));
to
$app->singleton(
Illuminate\Contracts\Debug\ExceptionHandler::class,
App\Exceptions\Handler::class
);
- In
bootstrap/app.php
, removeNord\Lumen\NewRelic\NewRelicMiddleware::class
from$app->middleware()
array. - In
bootstrap/app.php
, comment$app->register(Nord\Lumen\NewRelic\NewRelicServiceProvider::class);
. - Remove
nordsoftware/lumen-newrelic
fromcomposer.json
.
- In
bootstrap/app.php
, remove the following block.
if (report_to_sentry()) {
$app->register(Sentry\Laravel\ServiceProvider::class);
}
- In
app\Exceptions\Handler.php
remove the following.
if (report_to_sentry() && app()->bound('sentry') && $this->shouldReport($exception)) {
app('sentry')->captureException($exception);
}
- Remove
sentry/sentry-laravel
from yourcomposer.json
.
- In
bootstrap/app.php
, comment$app->configure('cors');
- In
bootstrap/app.php
, removeNord\Lumen\Cors\CorsMiddleware::class
from$app->middleware()
array. - Remove
nordsoftware/lumen-cors
from yourcomposer.json
.
- In
bootstrap/app.php
, remove the following block.
if (log_db_queries()) {
$app->register(App\Providers\QueryLoggerServiceProvider::class);
$app->middleware(App\Http\Middleware\QueryLoggerMiddleware::class);
}
- Use separate docker file for your PRODUCTION, in which you'll copy your code and not mount volumes.
- Enable
opcache
for better performance and removenano
,unzip
,zip
,git
,composer
in your production dockerfile. - Change
docker/php/conf.ini
according to your need. - The
app
service indocker-compose
file,app.build.args
takes NewRelic information. You can use it to install and integrate newrelic in your application. Only installs if theapp.build.args.ENVIRONMENT
isproduction
- Don't use
Facade
s, useapp('facade-accessor')
instead.
It'd be great if you think I missed something or something is wrong, please send a PR.