Best Practices for Theming Symfony Forms

Many Symfony developers struggle at customizing the HTML output of a Symfony form. Rendering a prototype is easy:


{{ form(form) }}}

But no real application is as simple as that. Real applications usually need a more complex and customized HTML. So you start using all of the advanced tooling that Symfony provides, from custom blocks over form themes, theme inheritance and many more. Real soon your template becomes quite complicated. Wouldn't it be much easier to write everything by hand? Yes it would!

Let me guide you through a few what I consider best practices for rendering your forms with Symfony.

Continue Reading

Value Objects in Symfony Forms

Many times, Symfony developers wonder how to make a form work with value objects. For example, think of a Money object with two fields $amount and $currency:

class Money
{
    private $amount;
    private $currency;

    public function __construct($amount, $currency)
    {
        $this->amount = $amount;
        $this->currency = $currency;
    }

    public function getAmount() // ...
    public function getCurrency() // ...
}

Can you write a form type for this class without adding the methods setAmount() and setCurrency()? In this post, I will show you how.

Continue Reading

Managing Web Assets with Puli

Yesterday marked the release of the next beta version of Puli 1.0. Puli is now feature-complete and ready for you to try. The Puli documentation has been updated and contains all the information that you need to get started. My current plan is to publish a Release Candidate by the end of the month and a first stable release at the end of April.

The most important addition since the last beta release is Puli's new Asset Plugin. Today, I'd like to show you how this plugin helps to manage the web assets of your project and your installed Composer packages independent of any specific PHP framework.

Continue Reading

Puli 1.0 Beta Released

Today marks the end of a month of very intense development of the Puli library. On December 3rd, 2014 the first alpha version of most of the Puli components and extensions was released. Today, a little more than a month later, I am proud to present to you the first beta release of all the libraries in the Puli ecosystem!

Continue Reading

Puli: Powerful Resource Management for PHP

Since the introduction of Composer and the autoloading standards PSR-0 and PSR-4, the PHP community changed a lot. Not so long ago, it was difficult to integrate third-party code into your application. Now, it has become a matter of running a command on the terminal and including Composer's autoload file. As a result, developers share and reuse much more code than ever before.

Unfortunately, sharing your work gets a lot harder when you leave PHP code and enter the land of configuration files, images, CSS files, translation catalogs – in short, any file that is not PHP. For brevity, I'll call these files resources here. Using resources located in Composer packages is quite tedious: You need to know exactly where the package is installed and where the resource is located in the package. That's a lot of juggling with absolute and relative file system paths and prone to error.

Continue Reading