How do I read configuration settings from Symfony2 config.yml?

I have added a setting to my config.yml file as such: app.config: contact_email: [email protected] … For the life of me, I can’t figure out how to read it into a variable. I tried something like this in one of my controllers: $recipient = $this->container->getParameter(‘contact_email’); But I get an error saying: The parameter “contact_email” must be … Read more

Should everything really be a bundle in Symfony 2.x?

I’m aware of questions like this, where people tend to discuss the general Symfony 2 concept of bundle. The thing is, in a specific application, like, for instance, a twitter-like application, should everything really be inside a generic bundle, like the official docs say? The reason I’m asking this is because when we develop applications, … Read more

Count Rows in Doctrine QueryBuilder

I’m using Doctrine’s QueryBuilder to build a query, and I want to get the total count of results from the query. $repository = $em->getRepository(‘FooBundle:Foo’); $qb = $repository->createQueryBuilder(‘n’) ->where(‘n.bar = :bar’) ->setParameter(‘bar’, $bar); $query = $qb->getQuery(); //this doesn’t work $totalrows = $query->getResult()->count(); I just want to run a count on this query to get the total … Read more

What is the difference between .yaml and .yml extension? [duplicate]

This question already has answers here: Is it .yaml or .yml? (4 answers) Closed 3 years ago. I read them on YAML-wikipedia but not really understood the main difference between them. I saw there are someone using .yaml extension, however, Symfony2 use .yml extension. YAML is a human-readable data serialization format that takes concepts from … Read more

How to update a single library with Composer?

I need to install only 1 package for my SF2 distribution (DoctrineFixtures). When I run php composer.phar update I get – Updating twig/twig (dev-master 39d94fa => v1.13.0) The package has modified files: M CHANGELOG M doc/filters/batch.test M doc/filters/index.rst M doc/filters/url_encode.rst M doc/functions/index.rst M doc/tags/index.rst M doc/tests/index.rst M lib/Twig/Autoloader.php M lib/Twig/Compiler.php M lib/Twig/CompilerInterface.php -10 more files … Read more