dev-master
9999999-devSets the router default base URL. It is required when the router is used while not dealing with a request (like in the console).
MIT
The Requires
by Francesc Rosàs
Wallogit.com
2017 © Pedro Peláez
Sets the router default base URL. It is required when the router is used while not dealing with a request (like in the console).
Notice this functionality is already available in Symfony since version 2.1, (*1)
This Symfony2 bundle sets the router default base URL (which by default is http://localhost), (*2)
It is required when absolute URLs are generated while not dealing with a request (like when sending an email from a cron job)., (*3)
Require it, (*4)
$ composer require frosas/base-url-bundle:1.*@dev
Register it in app/AppKernel.php, (*5)
$bundles = array(
// ...
new Frosas\BaseUrlBundle\FrosasBaseUrlBundle
);
Set the base URL. This is the recommended usage:, (*6)
# app/config/config.yml
frosas_base_url:
base_url: %base_url%
# app/config/parameters.yml
parameters:
base_url: http://example.com
Controller tests fail when using generated URLs, (*7)
If you generate the URLs you test, (*8)
$client = self::createClient();
$profileUrl = $client->getContainer()->get('router')->generate('profile', array('id' => 123);
$client->request('get', $profileUrl);
your tests can fail as the default Symfony test client expects the site to be in the root of the domain
(like http://example.com). If your base URL has a path (like http://localhost/~user/my-site) you'll
have to change it for you test environment., (*9)
# app/config/config_test.yml
frosas_base_url:
base_url: http://localhost
Sets the router default base URL. It is required when the router is used while not dealing with a request (like in the console).
MIT