A simple Twig truncate filter – Silex

Sometimes you can get in trouble when dealing with dynamic data with variable length, such as titles and descriptions, so they can fit well in your layout. With Smarty you have the built-in filter “truncate”, but Twig doesn’t have this filter by default. I know there’s some text extensions available, but I didn’t get it to work with Silex easily and I didn’t want to lose more time on this issue, so I made this simple twig truncate filter and it’s working perfectly for truncating strings in the smarty style. Just add this to your bootstrap.php (or whatever initialization file…
View Post

Silex and Localization (i18n/L10n): TranslationServiceProvider

I’ve been using Silex* in a large variety of projects in the last year, and I always find something new to make my life easier. Last week, I was dealing with internationalization / localization (i18n / L10n) – a quite relevant topic when talking about web projects aiming a high audience. This post shows how to make an easy structure who automatically loads language files written in YAML, using the TranslationServiceProvider. Although the post is focused on Silex, I believe it’s also compliant with Symfony 2. If you wanna go directly to the code, there’s a GitHub repo with the…
View Post

Getting started with Silex – the php micro framework based on Symfony 2

This post aims to show the basics, and how to get started with the php micro framework Silex– which, by the way, is my favorite php framework nowadays. It’s based on Symfony 2, but focused on smaller applications. It has a really comprehensive and intelligent schema for url rewriting (so-called “Routes”) that brings to PHP one of the great things you can find in Django. It’s concise, extensible – using Pimple and Composer for dependency management – and secure. Oh, almost forgot: it’s practical, easy to learn and super versatile – according to my own experience with the framework so…
View Post