Converting umlaute with symfony String component

There are multiple PHP native ways to convert umlaute and other special characters to ascii save formats, but most of them i experience insufficient in the one or other way.

Since i am using symfony anyway i can use the String component which has a handy slugger which converts any characters into safe ascii characters.
It is very flexible and can be customized with locales, custom replacements and closures.

$umlautString = "Müller Meier"; $slugger = new Symfony\Component\String\Slugger\AsciiSlugger('de'); $slugger->slug($umlautString, $seperator = ' ')->toString(); echo $umlautString; // mueller meier
Code language: PHP (php)

I guess this will become my go-to method resp. slugger to convert umlaute in any PHP application.

Continue reading “Converting umlaute with symfony String component”

[Symfony 2][Assetic] Sass, CompassFilter + Foundation Responsive Front-end Framework

Did you ever wonder how to enable 3rd party plugins (or so called “frameworks“) within the great compass toolset managed by assetic in your edgy symfony 2.1 project?

(If there is more extensive documentation available concerning assetic + CompassFilter, please stop reading on and let me know!)

If you take a look at the filter class itself (it is CompassFilter in the generic Assetic\Filter namespace), you should recognise several option values that you can use in your application wide config.yml file.

But first you have to install the framework plugin following these instructions.

Continue reading “[Symfony 2][Assetic] Sass, CompassFilter + Foundation Responsive Front-end Framework”

[Symfony 2] composer.json for a assumed-stable symfony 2 distribution

This small composer.json file is used in a project i am working on atm, feel free to use it at own risk. I will provide non-periodical updates and hopefully soon a full upgrade to symfony 2.1.x including doctrine orm 2.2.x.

I still did not get the point regarding dependency resolution, so i simply “composed” the composer file by writing down my own requirements (“i want only the hottest, newest stuff!!”, then tracked down the error messages, removing them by explicetly writing down the missing dependencies by using the latest “dev-*” versions. After that i tried to run the project, which actually did not work, but selective downgrade of some of the bundles (framework, security-extra blahblah) finally did the job. Continue reading “[Symfony 2] composer.json for a assumed-stable symfony 2 distribution”

Symfony 2 – Set Default Locale On Form Login #2

A small update/correction out of sequence:

A few weeks ago i described how to hook into the form login process in order to change the user session´s locale.

In the meantime a non backwards compatible code modification has been introduced that outdated this article. From now on (Symfony 2.0.4) the locale and default locale settings are maintained within the request object (and not as used to be in the session).

So, here is a little update – under reserve – because the locale setting´s logic will probably change again in the future.

Continue reading “Symfony 2 – Set Default Locale On Form Login #2”