Posts Tagged: Twig

Symfony Load Twig Template From String

As is always the case with PHP, or open source technology, there’s a gazillion ways to rule the world, or solve a problem. I had a problem with a Symfony app I was building. I needed to load the Twig template from a string variable rather than a file. To do so is easy. All… Read more »

Customize Symfony Form Builder Error Message in Twig Template

I’m building a form to gather credit card information and I want to customize the error messages displayed on the form. I’m sure I can do this with form theming, and that’s great, but I just wanted a down and dirty, in the template, spitting out custom error messages solution. Of course, normally, I would… Read more »

Symfony Twig Concat String

Concatenating a string using Twig is pretty simple, if you know what you’re doing. In my first instance in Twig string concatenation, I wanted to dynamically load some assets based on the route parameters. With my solution, I ended doing something like this to load a stylesheet, for instance. <link rel=”stylesheet” type=”text/css” media=”all” href=”{{ asset(‘bundles/hack3r3dradio/css/’… Read more »

Stop building shitty PHP web applications

I’m sort of active on Stackoverflow.com and I see so many stupid questions from people who know nothing about PHP trying to cobble together a pile of shit web application. I admit that nearly 20 years ago when I started working with PHP, I wrote some awful code, just wretched shit. But back then, everyone… Read more »

Symfony 2: Enable Twig Extensions

The other day I was dicking around with some code and I felt like I needed to truncate a string. Fortunately I was working with Symfony, which uses Twig templates, which is definitely my preferred templating system in 2014. But by default Symfony’s Twig extensions, which give you stuff like a truncate filter, is not… Read more »