2017 © Pedro Peláez
 

library lumen-advanced-route

Add Support For Nested Group && Resource.

image

elemenx/lumen-advanced-route

Add Support For Nested Group && Resource.

  • Wednesday, February 21, 2018
  • by branchzero
  • Repository
  • 1 Watchers
  • 1 Stars
  • 883 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 88 % Grown

The README.md

Note

inspired by fremail/lumen-nested-route-groups, adding support for lumen resource route., (*1)

Changelog

  • v.0.1.1 Remove Useless Code.
  • v.0.1.0 Add Support For Lumen 5.5 && Resource.

How to install (steps)

1. Install using Composer

composer require "elemenx/lumen-advanced-route:~0.1"

2. Required changes in bootstrap/app.php

Change initialization of Lumen Application class to initialization of Lumen Nested Route Groups Application class in bootstrap/app.php., (*2)

Before:, (*3)

$app = new Laravel\Lumen\Application(
    realpath(__DIR__.'/../')
);

After:, (*4)

$app = new ElemenX\AdvancedRoute\Application(
    realpath(__DIR__.'/../')
);

Any() and Match() and resource() methods

Do you like any() and match() methods on Laravel? I love them! That's why I added supporting them on Lumen. The syntax is the same as for Laravel:, (*5)

$app->match($methods, $uri, $action);

Where $methods - an array of methods. Example: ['get', 'post', 'delete']. $uri and $action are the same as on other methods, (*6)

$app->any($uri, $action);

Here are $uri and $method are the same as on other methods like $app->get(...) etc., (*7)

Example of using this lib

This is an example of routes/web.php, (*8)

$app->group(['middleware' => 'auth'], function () use ($app) {

    $app->get('test', function () {
        echo "Hello world!";
    });

    $app->resource('user', 'UserController', ['only' => ['show', 'store', 'destroy']]);

    /**
     * only admins
     */
    $app->group(['middleware' => 'admin'], function () use ($app) {

        $app->group(['prefix' => 'admin'], function () use ($app) {
            $app->get('/', 'AdminController@index');
        });

    });

    /**
     * $app->any and $app->match available from v1.1.0
     */
    $app->any('/', function () use ($app) {
        echo "Hey! I don't care it's POST, GET, PATCH or another method. I'll answer on any of them :)";
    });

    $app->match(['PATCH', 'PUT', 'DELETE'], '/old/', function () use ($app) {
        echo "This is an old part of our site without supporting REST. Please use only GET and POST here.";
    });

});

The Versions

21/02 2018

dev-master

9999999-dev

Add Support For Nested Group && Resource.

  Sources   Download

MIT

The Requires

 

lumen route group match any elemenx

21/02 2018

0.1.4

0.1.4.0

Add Support For Nested Group && Resource.

  Sources   Download

MIT

The Requires

 

lumen route group match any elemenx

01/02 2018

0.1.2

0.1.2.0

Add Support For Nested Group && Resource.

  Sources   Download

MIT

The Requires

 

lumen route group match any

01/02 2018

0.1.1

0.1.1.0

Add Support For Nested Group && Resource.

  Sources   Download

MIT

The Requires

 

lumen route group match any

05/12 2017

0.1.0

0.1.0.0

Add Support For Nested Group && Resource.

  Sources   Download

MIT

The Requires

 

lumen route group match any