Remote CLI debugging with XDebug

There are quite some tutorials out there on how to use XDebug to debug PHP CLI code, which where more confusing than helpful (to me). I found out that, once you have a running XDebug configuration, it is very easy to debug on the console, particularly with phpStorm.

Simply run the following line once

export PHP_IDE_CONFIG="" ; export XDEBUG_CONFIG="idekey=PHPSTORM"

(after customizing it to your needs, of course), set your breakpoints and run the script. That’s already it. You can also put this into your .bashrc file.


Currently I’m attending the 10th International Typo3 Conference (or in cool: T3CON14) in Berlin, and although it is not over yet I really liked it so far. Not only because of the great location in one of the hippest parts of Berlin, or the tasty food, or that I was able to carry home a 3-years supply of stylish pens, no … the atmosphere is fantastic and it is very nice to see the faces behind the names. Also many sessions where very inspirational. My favorite so far was the brilliant speech of Clemens Prerovsky (Aloha-Editor).

Also, and I’m definitely no fanboy, but to attend a speech of the Typo3-founder Kaspar Skårhøj was really something I would not have expected after all these years ;-)

Typo3 Caching and TypoScript conditions

Having taken over a somewhat shabby Typo3 project recently (I prefer using the term “challenge” here), digging through the many TypoScript files revealed something which is probably very common in many Typo3 setups:

[browser = msie]
page.includeCSS.file22 = fileadmin/templates/css/ie.css
[browser = msie] AND [version = 7]
page.includeCSS.file23 = fileadmin/templates/css/ie7.css

Why is that a problem? Well, when it comes to caching, Typo3 starts building up Cache entries for every possible condition. So from the above example, we will get 3 cache entries:

  1. Internet Explorer 7
  2. Other Internet Explorers
  3. All other browsers except Internet Explorer

Of course this blows up the database, but space wasn’t the main problem in our case – it was the time it took to rebuild the cache after clearing it. This Typo3 installation serves thousands of pages, and they are crawled regularly to build up the cache, so we really don’t want to waste any time.

So what do we do? First and obvious step, drop IE 7 support! Ahhh, that feels so right…. Ok. Now the remaining, really few IE hacks in the ie.css will be included by using good old Conditional comments:

page.headerData.123 = TEXT
page.headerData.123.value (
<!--[if IE]>
<script type="text/css" src="fileadmin/templates/css/ie.css"></script>

The additional load for IE users is minimal, and we got rid of quite some cache entries and saved a good amount of computational power.

Use HeidiSQL with your vagrant box

I already discussed how to use HeidiSQL with a remote server in a former post. I now switched to use a local Vagrant VM instead of a remote VM. Of course I still wanted to use my beloved HeidiSQL. And it is – again – very easy!


On the above page, you need to use the MySQL Username and Password.


On the “SSH tunnel” tab we have to use the Username and Password for the SSH connection. I use a Private Key instead of a password, so I leave the password empty and specify the Private key file instead.

My box is configured to use SSH port 2222 instead of the default port 22. This will most likely differ on other boxes, so it is worth to check this first if the connection is not possible.

That’s it :-)

Template Engines vs. PHTML

The Problem: Performance. Once again.

It was time to think again about the use of Template Engines (i.e. those like Smarty or Fluid who offer their own syntax) versus so called PHTML files (i.e. basically mixed HTML and PHP), as one of my colleagues currently works on a Typo3 Extbase extension with a very huge HTML output. Unfortunately the rendering process was extremely slow. In our case Fluid, the template engine that comes bundled with Extbase, was to blame.

Although using compiled templates, it took about 6 seconds to render. After clearing the cache it was way beyond 20 seconds until the templates were compiled again. What the heck. Where does this massive overhead come from?

Looking at the compiled templates, I was a bit shocked: one of it had almost 20.000 lines of PHP code, tons of closures and function calls! It was just a template, now it is a monster. 6 seconds rendering time is not acceptable at all. Surely the extension produced a big HTML code, using loads of loops, partials and view helpers, but we had to find a way to deal with it.

Two options where obvious at that moment:

  1. Do we really need to use Fluid?
  2. How about loading at least parts of the content, which is not immediately used, via AJAX?

I admit I’m biased. I never liked using any Template Engine in PHP. That’s why I had a closer look at option 1, while my colleague started working on option 2 meanwhile.


Let’s think about the Pros and Cons of using template engines in PHP. Here is what we came out with:


  • No PHP knowledge required to build templates: yeah, sure. This is a common argument. So it is ok for the Webdesigner to learn a new template engine, but too much to learn PHP basics. Plus, at least in our team there is nobody who doesn’t speak PHP.
  • Templates are cleaner, easier to read: this depends on the template engine of course, but considering Fluid I would agree on that. It is not very important for me, though.
  • No risk of PHP abuse in template: Yip, good point. I guess we’ve all had these “WTF!?!” moments when we looked at PHTML templates, finding functions with business logic in templates. This surely requires the coders to be disciplined, and/or Code Reviews.
  • Template Engines offer caching mechanisms: true. But without caching they wouldn’t even come close to the performance of PHTML files. There’s nothing to say against implementing your own caching when you use PHTML templates, though.


  • Using a template engine produces overhead: you can’t ignore the fact that a templating engine per se is additional overhead. This is not necessarily bad, when the overhead is low, but when the content takes more than double the time to render it might not be the correct choice.
  • Templates can not be debugged properly: I’m used to develop using a PHP debugger a lot, especially when I have to deal with many variables and nested arrays. I can’t use that in templates. I can use it in PHTML files.
  • “Why did my change don’t come through? Ah, I forgot to clear the cache again!”: If this applies to you, as it does for me, then template engines can be a bit of a pain sometimes.
  • “I’m not slacking off, my code’s compiling”: Not only a smart reference to XKCD, but also a very annoying aspect: if you develop, you either turn off caching completely (slow!), or you have to clear the cache whenever needed (annoying – and slow!).

Ok, there are some points which speak for Template Engines, but are they really worth the overhead? This surely depends on personal preferences, but for me it was clear: No. It is not.

Conclusion: Go back

Great. We wanted to stick with Extbase, but we didn’t want to use Fluid all the time. So we need a PHTML template renderer for Extbase. It should at least cover the following requirements:

  • We want true MVC! View and Logic must be separated.
  • Extbase/Fluid must not be modified. Copy&Paste has to be avoided.
  • The PHTML renderer should be easy to integrate. Existing controller actions shouldn’t be rewritten at all.
  • The use of Fluid should still be possible.
  • Partials must be supported.
  • Fluid ViewHelpers should be supported, at least some sort of ViewHelpers must exist. Namespaces for ViewHelpers would be nice.

Of course there is a mayor drawback: all the Fluid templates which already existed need to be “backported” to PHTML. Oh well…

It should however show that the required goal was very easy to achieve. This will be shown in the next post.

What are your views on Template Engines? Maybe we missed the one argument to use them instead of PHTML?

Free! JavaScript! Literature!

Back in the days, one of my profs at the University always had some cool quotes at hand. One of his favourites was “There is no such thing as a free lunch”. While I basically agree (at least what food is concerned), you often find free gems in the internet, like a series of JavaScript related books:

They are available for free on github, however the author also sells them as e-book or even printed versions. I’m not sure if I would pay $17 for a 98 pages e-book which I can read for free, though… that sounds a bit too expensive in my opinion.

Microsoft drops support for ancient IE versions (finally)

I was very pleased, happy, yes – almost euphoric when I read that Microsoft plans to drop support for older IE versions:

While Windows Vista users will still get support for IE 9 (are there any Vista users out there anyway?), on Windows 7 only IE 11 will be supported. Aren’t that good news? After wasting billions of hours of webworkers precious livetime all over the world, Microsoft finally understood. A bit. I guess.