PHP code example of mikbox74 / yii2-autorouter

1. Go to this page and download the library: Download mikbox74/yii2-autorouter 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/ */

    

mikbox74 / yii2-autorouter example snippets


return [
    // ...
     'bootstrap' => [
         [
             'class' => \mikbox74\Autorouter\AutorouterComponent::class,
         ],
         //...
     ],
];

 public static function getUrlRules()
 {
     return [
         [
             'class' => 'yii\rest\UrlRule',
             'controller' => [
                 'mymodule/controller',
             ],
         ],

         'GET  mymodule/controller/<id:\d+>'   => 'mymodule/controller/view',
         'POST mymodule/controller'            => 'mymodule/controller/create',
         'PUT mymodule/controller/<id:\d+>'    => 'mymodule/controller/update',
         'DELETE mymodule/controller/<id:\d+>' => 'mymodule/controller/delete',
     ];
 }