We can create a REST API in the Laravel Lumen microframework interactively. First of all, install the composer dependency and install lumen globally using the composer. Please follow the command below:
composer global require "laravel/lumen-installer"
In this step, we create a project and named it blog using the following command.
lumen new blog
Navigate to the blog folder and run the project.
cd blog php -S localhost:8000 -t public
Rename the .env.example to .env and make
APP_DEBUG=true, add the database connection properly. Now you need to create an
APP_KEY. Add the key generator package using the following command and it will be used to generate the
composer require flipbox/lumen-generator
We need to activate the lumen generator. So we need to add the following line to bootstrap=>app.php and it will enable the lumen generator:
Generate the APP_KEY using the following command and check the .env file.
php artisan key:generate
It will generate a base 64 application key in the .env file. If you want to see the stack trace of your source code error, just uncomment $app->withEloquent(); in bootstrap=>app.php