I’m getting the following error when I try and visit my app_dev.php page: No route found for “GET /” The thing is that I defined this route, my routing.yml file looks like this: 0 v42homepage: 1 …
Tag: symfony
Twig Template Unit Testing
I began to think about Continuous Integration for the twig templates in Symfony. A template is independent logic. There are mistakes in the templates. But in the process of development I do not want …
Symfony2 / Twig – getting array from dynamic array key
In PHP I would do this: foreach( $array as $key => $value ) { echo $another_array[$key]; } I can’t see how to do that in Twig (in Symfony2). I’ve tried various things, but this would seem …
key value being replaced by ‘key’ when using merge() in twig
I am trying to add pairs of key value to an array with their current values for all those attributes not starting by ‘_’. For some reason, the merge replaces the value of “key” (i.e slug) with the string ‘key’. For example when slug is the only attribute with key not starting with ‘_’, it behaves as follows: I have
Calling console command within command and get the output in Symfony2
I have a few console command in Symfony2 and I need to execute one command from another command with some parameters. After successfull execution of the second command I need to get the result (as an array for example), not the display output. How can I do that? Answer Here you can have a basic command inside a command. The
Doctrine – Add default time stamp to entity like NOW()
Following the Doctrine guidelines I understand how to set a default value for an Entity, but what if I wanted a date/time stamp? http://docs.doctrine-project.org/projects/doctrine-orm/en/2.1/reference/faq.html My problem is my database has a default of NOW() on a field but when I use Doctrine to insert a record the values are null or blank but the rest of the insert happened. Also
Default value of Doctrine ORM association
I have the entity (such as below). I want to set some default values while creating. As you can see in __construct, it is easy to set the $name (string), but how can I set the $group? (for example I …
symfony2: how to access service from template
If I created a service is there a way to access it from twig, without creating a twig.extension? Answer You can set the service a twig global variable in config.yml, e.g And in your template.html.twig file you can invoke your service this way: See here.
Symfony2 Validating an optional field
In my form, I have a field with required option set to false, this field is optional. However, I would like to have a notBlank validation on this field when the field is used: Right now, I can’t use the validation constraint NotBlank because it will cause my form validation to fail when the field is unused. I tried something
Check if in “dev” mode inside a Controller with Symfony
When using dev mode with a Symfony2.x application, one usually works in locale. Hence, such function does not works as expected (for instance, try to get the current IP under localhost). This could be a problem, e.g. when one try to use such ip-based web service. Hence, I just want to know how to check inside a controller if the