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

Asked

Viewed 188 times

0

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

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

'url' => '',

And I also did the test to put some url there:

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

But I realized that it didn’t change the links in my application. This happened in Laravel 3.

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

1 answer

1


As far as I know, this setting is intended to define the base url of the application when it is not possible to detect it automatically.

A basic example of this is command line execution.

Consider the following example using the command tinker (Larable in iterative mode) command line artisan.

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

// Outras definições ...

'url' => ''

Then I do it on the command line:

php artisan tinker --env=local

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

The returned result is : '/test'

Now we have changed the configuration file again. This time I will put a default url.

Example:

// Outras definições ...

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

We rotated the tinker again :

php artisan tinker --env=local

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

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

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.