Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the config/web.php urlManager configuration #4

Closed
dersonsena opened this issue Sep 15, 2019 · 0 comments
Closed

Improve the config/web.php urlManager configuration #4

dersonsena opened this issue Sep 15, 2019 · 0 comments
Labels
improvement General improvements

Comments

@dersonsena
Copy link
Owner

dersonsena commented Sep 15, 2019

Create the config/routes.php file and add the code below:

<?php

return [
    // To create a standalone route
    // 'pattern/to/your/route' => 'controller-id/action-id'

    // To create a standalone route with more configurations
    /*[
        'pattern' => 'pattern/to/your/route',
        'route' => 'controller-id/action-id',
        'verb' => ['GET']
    ]*/

    // To create a Active route (Active Controller)
    /*[
        'class' => 'yii\rest\UrlRule',
        'controller' => 'controller-id',
        //'pluralize' => true,
        'extraPatterns' => [
            'GET test' => 'test',
        ],
    ]*/
];

In the top of the config/web.php, insert the

$routes = require __DIR__ . '/routes.php';

In the urlManager config, setup the rules property to a variable created above:

'urlManager' => [
     'enablePrettyUrl' => true,
    'enableStrictParsing' => true,
    'showScriptName' => false,
    'rules' => $routes,
]
@dersonsena dersonsena added the improvement General improvements label Oct 2, 2019
dersonsena added a commit that referenced this issue Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement General improvements
Projects
None yet
Development

No branches or pull requests

1 participant