German symfony trainings 2010

4. January 2010 in General

Hello all,I just anounced the dates and locations for my german symfony trainings/workshops. The workshops take place in Stuttgart and Heilbronn. The language of the workshops is german. 
You can find more information and prices at the following training-website
Maybe we can see us at one of these events :-)    

Vote for Lime-Support in Netbeans

23. October 2009 in General

The Netbeans-IDE already has PHPUnit support. It is possible to run the unit tests from the IDE and get the result shown in a pretty way. I opend a feature request at the netbeans tracker to support Lime too. I think Lime2  support should not be really difficult through the xUnit XML-Resultfile-Support of Lime2. If you like to have the feature in a future version of Netbeans just vote for it under:


Colorize your Windows Console output

15. October 2009 in General

Update: The code-changes are included in symfony by now. If you use 1.3 or higheryou will not need to patch any symfony files.

If you are one of the developers, that is “forced” to use Windows on your development machine, you probably wish yourself a more comfortable console window. The windows one just missing all features I wish me for developing with Symfony. A good copy&paste, no colored output, no tabs… I know that many developers are using cygwin to get arround of such problem, but cygwin and I will never get the best friends…

Today I came across AnsiCon ( This small utility helps the Windows commandline to understand ANSI-Color-Codes and other escape characters. The installation is pretty easy, just copy the ansi.dll and ansicon.exe in a folder of your machine (i.e. c:\ansicon). After that set the PATH-Environment-Variable in the system settings, add the ansicom path there. Afterwards start ansicon with “ansicon.exe -i”. This installs a registry setting. Thats it!

ANSI-Colors and escape characters are now interpreted correctly. But there is a problem for Symfony-Developers: The Symfony classes with Console output doesn’t output ANSI-Colors on Windows :-(

At the moment the only possibility is to change the Symfony Sourcecode. This is a bad thing. You never should change the framework sourcecode. Therefore I opened a ticket in the Symfony-Wiki ( If you lin to have this function added to symfony just support this in the ticket.

If you like to test the colorization for yourself open the lib/vendor/lime/lime.php and change line421 from

   !function_exists('posix_isatty') ||


if (is_null(getenv('ANSICON')) && (DIRECTORY_SEPARATOR == '\\' ||
   !function_exists('posix_isatty') ||

When you call “symfony test:unit” you will get a result like the one in the screenshot:


The other file that needs to be changed is the  libn/commands/sfAnsiColorFormatter.class.php. There you need to change line 145 to:

return !is_null(getenv('ANSICON')) ||
      function_exists('posix_isatty') &&
     @posix_isatty($stream) );

That’s it! Now the symfony tasks (list, help…) will show their results in color :-)

Launched German Symfony User Group

29. September 2009 in General

I launched a new Symfony User Group for the german area Stuttgart, Ludwigsburg and Heilbronn. Everyon who is interessted can join us via We will try to hold regular meetings in the future as soon as we have enough members.

So come on over and join us :-)

Copy&Paste Detector Task for Phing

29. September 2009 in Continuous Integration, General, Phing, Symfony


I use the Hudson Continuous Integration system to build my Symfony projects (will write a blog series about this in the next few days). For that I created a new task  for the Phing build system. Sebastian Bergamann wrote a Copy&Paste Detector for PHP some time ago (PHPCPD). This small tool scans PHP sourcecode for duplications. You can use the Task in a Phing build file as shown in the following sample:

<phpcpd haltonerror="false">

  <fileset dir="${builddir}" id="filestocpd">

    <include name="apps/**/*.php" />

    <include name="lib/de/**/*.php" />

    <include name="lib/task/**/*.php" />

    <include name="lib/services/**/*.php" />

    <include name="lib/form/**/*.php" />

    <include name="lib/model/**/*.php" />


  <formatter type="pmd" outfile="reports/pmd-cpd.xml"/>


The CPD task is incorporatated in the current Phing trunk. If you want to use it you need to checkout the Version2.4.0 RC at the moment. The PEAR Installer version doesn’t contain the Task at the moment.

Maybe this is useful for you too. Stay tuned for more informations on Symfony and Continuous integration

sfAmfPlugin 1.4.2

5. August 2009 in AMF, doctrine, Flex, General, Symfony

I released a new version of the Symfony-Plugin sfAmfPlugin som hours ago. With the new version the communication between Flex and Symfony is easier than ever.The new version brings big improvements regarding the Doctrine Adapters. Relations between classes are handled better now. The error_reporting is working now as it should and there is a default implementation of a gateway module included.I hope you like it and find it useful. And as always I would like to hear from you if there are bugs or feature requests.Get it while it’s hot :-)Timo

Serving PDF Files through Symfony Controllers

3. August 2009 in General, Symfony

A lot of web applications offer to download some kind of PHP file. Maybe you want to implement some kind of export feature or you have paid content in form of a PDF or other media or you just want to secure your PDF files in the same way as the rest of your application (i.e. username/password). If this is the case you wouldn’t place your PDF-files in a subfolder of the web-Directory of your Symfony project, because all these file can be accessed directly via browser.

So how to serve your PDF-Files through a Symfony controller? it is an easy one. Just assume you put your pdf-files in a directory called “media” on the root-level of your Symfony-project.

  |-- apps
  |-- cache
  |-- config
  |  |-- demo.pdf
  |-- media
  |-- lib
  |-- web

These files cannot be reached by Browser, so we  need a new routing information for Symfony to get them accessible via the webbrowser. For that open the routing.yml of your application and add the following rule topmost in this file.

  url: /media/:filename.pdf/*
  param: { module: media, action: show }

From now on if you try to access a PDF-File in the media-folder (i.e. http://domain/media/demo.pdf) the media-Module with the action show is called. That was easy but how to implement this action. First you need to create the media module with the symfony command line tool:

$> symfony generate:module appname media

Afterwards add the following method to the class in the media/actions/actions.class.php file:

public function executeShow(sfWebRequest $request) {
  // being sure no other content wil be output
  sfConfig::set('sf_web_debug', false);

  $pdfpath = sfConfig::get('sf_root_dir').DIRECTORY_SEPARATOR.'media'

  // check if the file exists

  // Adding the file to the Response object
  $this->getResponse()->setHttpHeader('Pragma: public', true);

  return sfView::NONE;

Thats it! You can improve this Action method a little bit. For example you can add a “download”-switch. If this switch is set to 1 the file is downloaded instead of shown in the browser (i.e. http://domain/media/demo.pdf/download/1).

public function executeShow(sfWebRequest $request) {
  // being sure no other content wil be output

  sfConfig::set('sf_web_debug', false);

  $pdfpath = sfConfig::get('sf_root_dir').DIRECTORY_SEPARATOR.'media'

  // check if the file exists

  // Adding the file to the Response object
  $this->getResponse()->setHttpHeader('Pragma: public', true);

  // download-switch
  if ($request->getParameter('download', 0) == 1) {
                            'attachment; filename="'.


  return sfView::NONE;

As we now use a Symfony-Controller you can do just use the complete Symfony infrastructure. You like to secure the PDF-files? Just enable the Symfony security mechanisms (is_secure: on in the security.yml) and only logged in users can download them. In the same way you can create paid content.  Or you can add watermarks to your PDF using Zend_Pdf for example.

Hope this is helpful for you.

Looking for help for CuteFlow

15. July 2009 in General

CuteFlow is an open source PHP workflow management system. The current version is written in plain PHP. The codebase is pretty old and pretty pretty pretty ugly for current PHP standards. We are at the beginning of a complete rewrite of the system with Symfony but still maintaining the old version. The most work is done by myself, so I can need any help I can get. If you are interessted in helping there are a lot of areas you can help.

  • New website with symfony (layout is ready)
  • Writing documentation
  • Creating Screencasts
  • Developing

If you are interessted send me a mail to

New sfAmfPlugin release

29. June 2009 in General

I have just released a new version of my Symfony-Plugin sfAmfPlugin. The new version 1.4.0 has the following changes included:

  • Added an error handler function. All Errors will now be delivered as an exception (thanks to raphox for this)
  • Fixing problem with associative array values
  • Updated SabreAmf to version 1.3.0
  • Added correct content type support, you should now use the handleRequest method in your actions as shown in the documentation

You can now use the the plugin in your actions like this:

public function executeAmf(sfWebRequest $request) {


  return sfView::NONE;


There is a lot of stuff coming for the next version of the plugin, so stay tuned :-)

sfAmfPlugin 1.3.0 released

5. May 2009 in AMF, doctrine, Flex, General, Symfony

Just want to inform you that my sfAmfPlugin for Symfony-Flex-Communication was released in version 1.3.0.

Most noticeable changes:

  • Fixing a bug with PHP Strict mode (thanks to Daniel Holmes for spotting this one)
  • Adding the possibility to store the services in all lib-folders of a project (app, module, project, plugins)
  • Fixing different bugs with AMF conversion of Doctrine objects (thanks to Patrick Schirch for bugging me about them)

I’m still working to get the Doctrine support better, there will be much more about this in the next version of the plugin. Class mapping is also a thing I want to improve a lot. So stay tuned and watch out for future versions :-)