PHP Classes

Lumen Starter Pack: Implement a OAuth 2 based REST API server

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStarStar 89%Total: 441 All time: 6,249 This week: 36Up
Version License PHP version Categories
lumen-starter-pack 1.0.1The PHP License5PHP 5, User Management, Libraries, We...
Collaborate with this project 

Author

lumen-starter-pack - github.com

Description

This package can implement a OAuth 2 based REST API server.

It implements a module on top of Lumen Laravel micro-framework to provide a REST API based on OAuth2 authorization.

The package also provides a users module with permission control that can create, update, delete and list users.

Picture of Eray Akartuna
  Performance   Level  
Name: Eray Akartuna <contact>
Classes: 2 packages by
Country: Turkey Turkey
Age: 29
All time rank: 322954 in Turkey Turkey
Week rank: 178 Up2 in Turkey Turkey Up

Recommendations

Suitable out of the box REST API
REST API to replace service without a backend

Example

<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/

$app->group(['namespace' => 'App\Http\Controllers'], function($group) use($app) {

   
$app->get('/admin/users', 'AdminUserController@index');
   
$app->post('/admin/users', 'AdminUserController@store');
   
$app->get('/admin/users/{users}', 'AdminUserController@show');
   
$app->patch('/admin/users/{users}', 'AdminUserController@update');
   
$app->delete('/admin/users/{users}', 'AdminUserController@destroy');

   
$app->get('/users', 'UserController@index');



   
$group->get('/', function () use ($app) {
        return
view()->make('client');
    });

   
$group->post('login', function () use ($app) {
       
$username = app()->make('request')->input("email");
       
$password = app()->make('request')->input("password");
        return
$app->make('App\Auth\Proxy')->attemptLogin(["username" => $username, "password" => $password]);
    });

   
$group->post('refresh-token', function () use ($app) {
        return
$app->make('App\Auth\Proxy')->attemptRefresh();
    });

   
$group->post('oauth/access-token', function () use ($app) {
        return
response()->json($app->make('oauth2-server.authorizer')->issueAccessToken());
    });

});








Details

Lumen Starter Pack

This package can implement a OAuth 2 based REST API server.

It implements a module on top of Lumen Laravel micro-framework to provide a REST API based on OAuth2 authorization.

The package also provides a users module with permission control that can create, update, delete and list users.

Installation

How To

  • Insert project into empty folder / git clone https://github.com/erayakartuna/lumen-starter-pack.git
  • Create an empty database table
  • Copy the .env.example to .env and insert the Database config
  • Run the following commands
    composer install
    php artisan migrate
    php artisan db:seed
    
    Thats it!

Usage

Routes

-------------------------------------------------------------------------------------
POST      => /login   Required Params:email,password
POST      => /refresh-token
-------------------------------------------------------------------------------------
Required Params : access_token

GET       => /admin/users             AdminUserController@index
POST      => /admin/users             AdminUserController@store
GET       => /admin/users/{user_id}   AdminUserController@show
PATCH     => /admin/users/{user_id}   AdminUserController@update
DELETE    => /admin/users/{user_id}   AdminUserController@destroy

-------------------------------------------------------------------------------------
GET       => /users   Required params: access_token   |  UserController@index
-------------------------------------------------------------------------------------

*Look inside to Unit tests to understand more*

Users Table Schema

Schema::create('users', function(Blueprint $table)
		{
			$table->increments('id');
			$table->string('name');
			$table->string('email')->unique();
			$table->string('password', 60);
			$table->boolean('is_admin',0);
			$table->rememberToken();
			$table->timestamps();
		});

User Login Informations

user@user.com
user1234

Resources

LUMEN

LUMEN API OAUTH


  Files folder image Files (57)  
File Role Description
Files folder imageapp (1 file, 9 directories)
Files folder imagebootstrap (1 file)
Files folder imageconfig (3 files)
Files folder imagedatabase (3 directories)
Files folder imagepublic (2 files)
Files folder imageresources (2 directories)
Files folder imagetests (2 files)
Accessible without login Plain text file .env.example Data Auxiliary data
Accessible without login Plain text file artisan Example Example script
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file composer.lock Data Auxiliary data
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation
Accessible without login Plain text file server.php Appl. Application script

  Files folder image Files (57)  /  app  
File Role Description
Files folder imageAuth (2 files)
Files folder imageConsole (1 file)
Files folder imageEvents (2 files)
Files folder imageExceptions (1 file)
Files folder imageHttp (1 file, 2 directories)
Files folder imageJobs (2 files)
Files folder imageListeners (1 file)
Files folder imageProviders (3 files)
Files folder imageSupport (1 file)
  Plain text file User.php Class Class source

  Files folder image Files (57)  /  app  /  Auth  
File Role Description
  Plain text file Proxy.php Class Class source
  Plain text file User.php Class Class source

  Files folder image Files (57)  /  app  /  Console  
File Role Description
  Plain text file Kernel.php Class Class source

  Files folder image Files (57)  /  app  /  Events  
File Role Description
  Plain text file Event.php Class Class source
  Plain text file ExampleEvent.php Class Class source

  Files folder image Files (57)  /  app  /  Exceptions  
File Role Description
  Plain text file Handler.php Class Class source

  Files folder image Files (57)  /  app  /  Http  
File Role Description
Files folder imageControllers (4 files)
Files folder imageMiddleware (2 files)
  Accessible without login Plain text file routes.php Example Example script

  Files folder image Files (57)  /  app  /  Http  /  Controllers  
File Role Description
  Plain text file AdminController.php Class Class source
  Plain text file AdminUserController.php Class Class source
  Plain text file Controller.php Class Class source
  Plain text file UserController.php Class Class source

  Files folder image Files (57)  /  app  /  Http  /  Middleware  
File Role Description
  Plain text file Authenticate.php Class Class source
  Plain text file ExampleMiddleware.php Class Class source

  Files folder image Files (57)  /  app  /  Jobs  
File Role Description
  Plain text file ExampleJob.php Class Class source
  Plain text file Job.php Class Class source

  Files folder image Files (57)  /  app  /  Listeners  
File Role Description
  Plain text file ExampleListener.php Class Class source

  Files folder image Files (57)  /  app  /  Providers  
File Role Description
  Plain text file AppServiceProvider.php Class Class source
  Plain text file AuthServiceProvider.php Class Class source
  Plain text file EventServiceProvider.php Class Class source

  Files folder image Files (57)  /  app  /  Support  
File Role Description
  Accessible without login Plain text file helpers.php Example Example script

  Files folder image Files (57)  /  bootstrap  
File Role Description
  Accessible without login Plain text file app.php Example Example script

  Files folder image Files (57)  /  config  
File Role Description
  Accessible without login Plain text file app.php Aux. Auxiliary script
  Accessible without login Plain text file oauth2.php Conf. Configuration script
  Accessible without login Plain text file secrets.php Aux. Auxiliary script

  Files folder image Files (57)  /  database  
File Role Description
Files folder imagefactories (1 file)
Files folder imagemigrations (15 files)
Files folder imageseeds (3 files)

  Files folder image Files (57)  /  database  /  factories  
File Role Description
  Plain text file ModelFactory.php Class Class source

  Files folder image Files (57)  /  database  /  migrations  
  Files folder image Files (57)  /  database  /  seeds  
File Role Description
  Plain text file DatabaseSeeder.php Class Class source
  Plain text file OAuthSeeder.php Class Class source
  Plain text file UserSeeder.php Class Class source

  Files folder image Files (57)  /  public  
File Role Description
  Accessible without login Plain text file .htaccess Data Auxiliary data
  Accessible without login Plain text file index.php Example Example script

  Files folder image Files (57)  /  resources  
File Role Description
Files folder imagelang (1 directory)
Files folder imageviews (1 file)

  Files folder image Files (57)  /  resources  /  lang  
File Role Description
Files folder imageen (1 file)

  Files folder image Files (57)  /  resources  /  lang  /  en  
File Role Description
  Accessible without login Plain text file validation.php Conf. Configuration script

  Files folder image Files (57)  /  resources  /  views  
File Role Description
  Accessible without login Plain text file client.blade.php Aux. Auxiliary script

  Files folder image Files (57)  /  tests  
File Role Description
  Plain text file AdminTest.php Class Class source
  Accessible without login Plain text file TestCase.php Test Unit test script

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:441
This week:0
All time:6,249
This week:36Up
 User Ratings  
 
 All time
Utility:100%StarStarStarStarStarStar
Consistency:100%StarStarStarStarStarStar
Documentation:100%StarStarStarStarStarStar
Examples:100%StarStarStarStarStarStar
Tests:91%StarStarStarStarStar
Videos:-
Overall:89%StarStarStarStarStar
Rank:1