Tuesday, September 18, 2018

Create API Service with Lumen 5.2

Useful Tools:

1. APIDOC (Inline Documentation for RESTful web APIs)
npm install -g apidoc

2. Project Preparation : Getting Lumen Installer
 composer global require "laravel/lumen-installer"

 3. Project Initialization
lumen new blog
that command will install a startup project in folder "blog" with latest Lumen version. As a note, this will require latest PHP version also. If you have old php version installed on your server and don't want to upgrade, you can use older version of lumen for example is version 5.2 which still able to use PHP 5.5x.
composer create-project laravel/lumen blog "5.2"
Check the latest installation requirements based on Lumen and its version here: https://lumen.laravel.com/docs/installation 

4. Route
Use prefix "api"
$app->group(['namespace' => "App\Http\Controllers", 'prefix' => 'api'], function($app){
    $app->get('/lessons', 'LessonsController@index');  
});
Share:

0 comments:

Post a Comment