PHP code example of macellan / laravel-advanced-route

1. Go to this page and download the library: Download macellan/laravel-advanced-route 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/ */

    

macellan / laravel-advanced-route example snippets




namespace App\Http\Controllers;

class UserController extends Controller {
    /**
     * Responds to any (GET,POST, etc) request to /users
     */
    public function anyIndex() {
        //
    }

    /**
     * Responds to requests to GET /users/show/1
     */
    public function getShow($id) {
        //
    }

    /**
     * Responds to requests to GET /users/admin-profile
     */
    public function getAdminProfile() {
        //
    }

    /**
     * Responds to requests to POST /users/profile
     */
    public function postProfile() {
        //
    }
}

AdvancedRoute::controller('/{YOUR PATH}', '{YOUR CONTROLLER FULL NAME}');

Route::group(['prefix' => '/', 'middleware' => []], function () {
    AdvancedRoute::controller('/auth', 'AuthController');
    AdvancedRoute::controller('/cms', 'CmsController');
    AdvancedRoute::controller('/shop', 'ShopController');
    Route::any('/', 'WebsiteController@anyIndex');
});

AdvancedRoute::controllers([
    '/auth' => 'AuthController',
    '/cms' => 'CmsController',
    '/shop' => 'ShopController',
]);

class WikiController extends Controller
{
    public function getIndex() { /* show main page or list of content */ }
    public function getCreate() { /* a page to add a new wiki-page */ }
    public function postCreate() { /* add a new wiki-page */ }
    public function missingMethod() { /* do anything elselook up the path in the wiki-database */ }
}