What is the "url" option in the app / config / app.php configuration file

0

In Laravel 4 , we have a configuration file app/config/app.php .

There is an option called url . Many times I've seen this option empty:

'url' => '',

And also I've already tested put some url there:

'url' => 'http://meusite.com'

But I noticed that this did not change the links in my application. This happened in Laravel 3 .

So, what is the purpose of this option url in the file app/config/app.php ?

    
asked by anonymous 18.04.2016 / 21:16

1 answer

1

As far as I know, this setting has the purpose of defining which is the base url of the application when it is not possible to detect it automatically.

A basic example of this is running on the command line.

Consider the following example using the tinker command (Laravel on the iterative mode command line) of artisan .

First I leave the configuration file app/config/app.php like this:

// Outras definições ...

'url' => ''

Then I do this on the command line:

php artisan tinker --env=local

> URL::to('/test');

The result returned is: '/test'

Now we change the configuration file again. This time I'll put a default url.

Example:

// Outras definições ...

'url' => 'http://stackoverflow.com.br/',

We run tinker again:

php artisan tinker --env=local

> URL::to('/test');

The result is: 'http://stackoverflow.com.br/test' ;

So, notice that, in the absence of a "base url" for the system, Laravel will use this url set to app/config/app.php as the base url.

    
18.04.2016 / 21:39