Testing Repositories

Another common confusion I see in the PHP community is unit testing repositories. Some developers using an ORM like Doctrine mock a query builder and make their mocks expect particular methods calls with particular arguments. Others even try to parse resulting DQL and check it for particular structure. And there…

Assets Cache Busting in Symfony

When using Assetic or the asset function to output assets in Symfony, you get something like the following in the HTML output: <link href="/css/style.css" rel="stylesheet"/> Unless you disable caching on the web server level, this CSS file will get cached the first time it's…

Symfony Without Bundles

One of the first things developers new to the Symfony framework learn about is bundles. Everything in Symfony is a bundle, the documentation says. Based on that thought enthusiastic developers happily hop the bundle bandwagon and start creating a bunch of bundles in their apps: CommonBundle CoreBundle UserBundle FrontendBundle BackendBundle…

Symfony: Disabling HTML5 Form Validation Globally

If for some reason you want to disable HTML5 form validation globally by changing something in one place only, here's one way you could do it: Another way would be to add a custom form theme and override the form_start block, but using an extension feels like a better…

Rebooting Servers One-by-One With Ansible

If you have several nodes, you want to reboot them one by one so that online nodes can still do their jobs. Here's a playbook that shows one way of doing that in Ansible: serial: 1 makes the playbook execute all the tasks for a single server before moving to…