PHP code example of sebastiaanluca / laravel-router

1. Go to this page and download the library: Download sebastiaanluca/laravel-router library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sebastiaanluca / laravel-router example snippets




namespace App\Http;

use Illuminate\Foundation\Http\Kernel as HttpKernel;
use SebastiaanLuca\Router\Kernel\RegistersRouters;

class Kernel extends HttpKernel
{
    use RegistersRouters;
}



namespace App\Http\Routers;

use SebastiaanLuca\Router\Routers\Router;

class UserRouter extends Router
{
    /**
     * Map the routes.
     */
    public function map()
    {
        $this->router->group(['middleware' => ['web', 'guest']], function () {

            $this->router->get('/users', function () {

                return view('users.index');

            });

        });
    }
}

/**
 * The application routers to automatically boot.
 *
 * @var array
 */
protected $routers = [
    \App\Http\Routers\UserRouter::class,
];

app(\App\Http\Routers\UserRouter::class);



namespace App\Http;

use Illuminate\Foundation\Http\Kernel as HttpKernel;
use SebastiaanLuca\Router\Kernel\RegistersRouters;

class Kernel extends HttpKernel
{
    use RegistersRouters;

    /**
     * The application routers to automatically boot.
     *
     * @var array
     */
    protected $routers = [
        \SebastiaanLuca\Router\Routers\RegisterRoutePatterns::class,
    ];
}

Route::get('user/activations/{uuid}', function ($uuid) {
    return view('users.activations.show');
})->where('uuid', '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}');

$this->router->get('user/activations/{uuid}', function ($uuid) {
    return view('users.activations.show');
});

$this->router->group(['domain' => '{domain}'], function () {

    $this->router->get('user/{id}', function ($domain, $id) {
        return 'You\'re visiting from ' . $domain;
    });

});