# Routing

## Register a route

In root directory go to routes folder and you will find two files web.php file and api.php, those are the files to register urls routes, in web.php you will find next code:

```php
<?php
class Routes
{
    public static function setRoutes()
    {
        $routes = [
            '/'=>'AppController@index',
            'users'=>'UsersController@index',
            'users/profile'=>'UsersController@show',
            'users/edit'=>'UsersController@edit',
            'users/update'=>'UsersController@update',
            'users/new'=>'UsersController@create'
        ];
        return $routes;
    }
}
?>
```

{% hint style="danger" %}
routes will go in every key of the array, and in the value of every element will be place the name of the controller and the current method separated by '@' like this:

'yourRoute'=>'YourController\@currentMethod'
{% endhint %}

The name of the methods and controllers are based on conventions, because PHP Booster promote and works fine with conventions, but in controllers it does not affect in functunallity

{% hint style="info" %}
You could register your urls in any of those files, but it´s recomendable to use api.php just to register API Routes, and all web application routes in web.php.
{% endhint %}

$routes is the default root array to register url, but you could add more routes in other arrays after $routes like this:

```php
<?php
class Routes
{
    public static function setRoutes()
    {
        $routes = [
            '/'=>'AppController@index',
            'users'=>'UsersController@index',
            'users/profile'=>'UsersController@show',
            'users/edit'=>'UsersController@edit',
            'users/update'=>'UsersController@update',
            'users/new'=>'UsersController@create'
        ];
        $moreRoutes = [
            'otherRoute'=>'OtherRouteController@index',
            'otherRoute/show'=>'OtherRouteController@show',
        ];
        addRoutes($routes, $moreRoutes);//this helper add new route arrays
        return $routes;
    }
}
?>
```

With **addRoutes()** helper you could add as many route arrays as you want and it is helpful to organize routes by controllers or features or any order that you want.

{% hint style="info" %}
**addRoutes()** helper need two params, the principal array and as second parameter every new route array that we want to add.
{% endhint %}

##
