2017 © Pedro Peláez
 

symfony-bundle base-url-bundle

Sets the router default base URL. It is required when the router is used while not dealing with a request (like in the console).

image

frosas/base-url-bundle

Sets the router default base URL. It is required when the router is used while not dealing with a request (like in the console).

  • Friday, May 3, 2013
  • by frosas
  • Repository
  • 1 Watchers
  • 4 Stars
  • 413 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

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)

Installation and configuration

  1. Require it, (*4)

    $ composer require frosas/base-url-bundle:1.*@dev
    
  2. Register it in app/AppKernel.php, (*5)

    $bundles = array(
        // ...
        new Frosas\BaseUrlBundle\FrosasBaseUrlBundle
    );
    
  3. 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
    

Troubleshooting

  • 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
    

The Versions

03/05 2013

dev-master

9999999-dev

Sets the router default base URL. It is required when the router is used while not dealing with a request (like in the console).

  Sources   Download

MIT

The Requires

 

by Francesc Rosàs