get getEnvironment() from a service

There is no need to inject container. In fact, it is not a good idea to inject container because you’re making your class dependent on the DI. You should inject environment parameter: services.yml notification: class: NotificationService arguments: [“%kernel.environment%”] NotificationService.php <?php private $env; public function __construct($env) { $this->env = $env; } public function mailStuff() { if … Read more

doctrine querybuilder limit and offset

This is a know issue where setFirstResult() and setMaxResults() need to be use with care if your query contains a fetch-joined collection. As stated about First and Max Result Items: If your query contains a fetch-joined collection specifying the result limit methods are not working as you would expect. Set Max Results restricts the number … Read more

Symfony redirect to external URL

Answer to your question is in official Symfony book. http://symfony.com/doc/current/book/controller.html#redirecting public function indexAction() { return $this->redirect(‘http://stackoverflow.com’); // return $this->redirect(‘http://stackoverflow.com’, 301); – for changing HTTP status code from 302 Found to 301 Moved Permanently } What is the “URL”? Do you have really defined route for this pattern? If not, then not found error is absolutelly … Read more

Symfony2 ecommerce bundles feedback

TLDR If you are going to develop an ecommerce website with symfony right now ( as of 2013-05-26 ) and you want to make use of existing bundles/implementations… Go for Sylius! Why? Vespolina Vespolina has received some attention when first announced as it claimed to be the first ecommerce solution for symfony2 but it’s really … Read more

What is the difference between ‘url’ and ‘path’ in symfony2.3

They are very similar. path() Generates a relative/absolute path : path(‘contact’) will generate /contact url() Generates a scheme-relative/absolute url, ie domain + path url(‘contact’) will generate http://example.org/contact The url() style is useful when using cross-domain ajax or generating emails, because the hostname won’t be the same. Take a look at the code https://github.com/symfony/symfony/blob/master/src/Symfony/Bridge/Twig/Extension/RoutingExtension.php for more … Read more