Blog RSS Feed Subscribe

Jordi Boggiano

Jordi Boggiano Passionate web developer, specialized in web performance and php. Partner at Nelmio, information junkie and speaker.


Symfony Live 2010 - Symfony2, speaking and stuff

Overall the conference was pretty interesting since I don't have a lot of experience with symfony I learned quite a bunch of things about it's usage. I also met a lot of nice people, and ended the trip yesterday evening at the github meetup, after going for food with a couple phpBB guys who are really much nicer than the forum software they stand for. They were also very open to us bashing phpBB and seem to be headed towards a brighter future for the next version, which I'm sure nobody will complain about.

I also had my first session at a conference, accompanying Lukas though so I wasn't really flying by myself yet but it was still a nice and interesting (and stressful) experience that I will try to renew. We didn't get all that much feedback by the way so feel free to do so (also here if you are too lazy to register on, the organizers need it and obviously I wonder how the talk was received as well.

As for Symfony 2 (which now comes with a capital S please), I kind of saw the flexibility coming since we already implemented the dependency injection container in our Okapi framework at Liip, but I was still impressed by the jump away from symfony (1) Fabien conceded, many people would have tried to keep more BC at the cost of going forward, and I'm really glad he didn't, I think it will pay in the long run. The new version of the framework will basically be able to be totally ripped apart to fit your needs better if you have high performance requirements, which was the major pain point of symfony 1 as far as I'm concerned, and one of our reasons to keep working on Okapi which is pretty much a baseline micro-framework you can build upon. We will have to see if adopting Symfony in its place will make sense, but it sounds promising and it would offload some maintenance away from us which is always good.

Obviously Symfony 2 isn't going to be stable for a while, and there are some rough edges that still need to be discussed and improved, mostly in the way bundles are handled imo, but it looks very good already and I'll definitely give it a try asap. I would also encourage everyone to do so, especially framework developers, because the dependency injection is a pretty awesome thing to have, both for the testability of code and flexibility of the development process. Although if it's your only interest in it, checking out the Okapi 2 core (or the app ported to use it) is probably easier as there is less code to read, and we didn't add any of the abstraction to the dependency injection layer that Symfony 2 has.

February 18, 2010 // PHP // Post a comment

Dwoo is better than Twig

It's lame catchy title day, a more appropriate one would be "Think for yourself", but I want to get my point across.

This is a general purpose idea of course, I don't think there is any case in your life where you shouldn't think for yourself, but this particular post is about programming.

I just read someone (and I won't name names, it's not relevant) that was pondering using Dwoo or Twig in his CMS, who ended up picking Twig because, and I quote: "but twig says they're better than dwoo so ...". Now I sincerely couldn't care less if someone decides to use something else over Dwoo - which I'm working on in case you wouldn't know. It's your own choice, and even I wouldn't say Dwoo is the best choice for every damned purpose out there.

What bothers me though, is that obviously the guy read Fabien Potencier's article about php template engines, which was obviously not so much of an objective post, but that has already been discussed so let's not go to deep into it. Anyway, the guy most likely read it, and all it says about Dwoo to dismiss it is "Unfortunately, Dwoo has no sandbox feature and its core is not flexible enough". So.. out of this most enlightening comment, you decide to trust Fabien and just assume Twig is better? I just don't get it.

So again, please, just think for yourself.

December 08, 2009 // PHP // Post a comment

Major glob() fail

I just had the pleasure of discovering another of PHP's little quirks and since it's been almost a year since my last post, I thought it would be a good occasion.

Working on some personal project that lists a bunch of stuff on my hard drive, I found out that directories that contain square brackets (those []) don't return any results for the simple reason that glob reads [stuff] as a character class, just like in regular expressions. When you know it it makes perfect sense, but when you don't, the documentation is really not so helpful. Of course it mentions libc's glob() and unix shells, but not everyone knows what that implies at first glance.

My first reaction when I noticed that those directories were missing was to try and escape them with backslashes, which works on unix systems, but not on windows since the backslash is the directory separator. The cross platform solution is to enclose them in brackets (i.e. [[]), which effectively creates a character class with only the opening bracket in it, so it matches correctly.

I then wrote this glob_quote function which, just like preg_quote, escapes the meta characters that glob uses.

function glob_quote($str) { 
    $from = array( '[', '*', '?'); 
    $to = array('[[]', '[*]', '[?]'); 
    return str_replace($from, $to, $str); 

Another detail worth noting while I'm at it is that this problem also occurs when you do glob('*.txt') if your cwd contains brackets, since in this case the cwd is pre-pended to the pattern, the solution being to escape it as well as such:

That's it for today, so until next year..

December 02, 2009 // PHP // Post a comment

Multiton base class

While I like the Singleton pattern every now and then, I prefer the flexibility that the Multiton potentially offers, and well it's just an extended version of the Singleton, so it's "compatible" with the Singleton model.

Anyway, to the point, PHP5.3 is coming, and with Late Static Binding you can do a base Multiton (or Singleton if you insist), which wasn't possible before. Now I like this very much because you can simply extend it rather than rewriting those (few, I know, but still) lines each time.

Continue reading...

December 23, 2008 // PHP // Post a comment

The joys of user stylesheets

User stylesheets are a way to inject some CSS in all the sites you visit, each browser has his own way of setting it up (if you use opera step 2 there should be replaced with: "Tools > Preferences > Advanced > Content > Style Options > Select your css file in My stylesheet"), but the idea is always the same.

I've recently found a couple of use for these styles so I thought I might as well share :

Changing gmail's font

I like gmail, but losing my dear monospaced font was annoying me - especially when reading code-related mails with snippets in them. So this little hack allows you to choose the font used in the mail body area of the page. It's made for the "old" gmail interface since I don't have the new one yet, but it can probably be adapted if it doesn't work with the new one.

.XoqCub .ArwC7c {
  font:16px proggytinytt, "courier new", courier !important;
  font-size:16px !important;

This uses the proggytinytt font by the way, which is my font of choice for all monospace purposes, however if you don't have it it falls back on courier new/courier.

Saving flickr's images peacefully

Some images on flickr seem to be protected with a file called spaceball.gif that's overlayed onto the actual image, so that when you right-click it to save, you hit the transparent gif and can't save the image. With the help of that great CSS3 selector :nth-child(N), you can make sure you hide the gif if it's there.

.photoImgDiv img:nth-child(2) {
	display:none !important;

If you've anything useful, feel free to post it in the comments.

November 28, 2008 // Web // Post a comment

Dwoo v1.0 is out

Now that Dwoo's user base has grown a bit and that I've received enough feedback and fixed quite a bunch of bugs and design flaws, I feel confident it's time to go stable, so here comes Dwoo 1.0.0

For those that missed it, Dwoo is a template engine compatible with Smarty templates, with a lot of new features and syntax sugar and a new PHP5 codebase, if you want to read more I suggest you have a look at my earlier post, and its website.

Continue reading...

October 22, 2008 // PHP // Post a comment

Installing Habari on Lighttpd

Just a small post about Habari installation over Lighttpd, since it is not really documented anywhere that I could find.

I will assume that you know how to run php scripts on your server, and start from there. So once you have unpacked Habari files in say /home/seld/, all you need to do is add the following to your lighttpd.conf file :

$HTTP["host"] =~ "^(www\.)?domain\.com$" { 
    server.document-root =  "/home/seld/" 
    url.rewrite-once =  ( 
        "^/(?!scripts/|3rdparty/|system/|doc/|user/(?:themes/|files/|plugins/|locales/|sites/))[^?]*(\?(.*))?" => "/index.php/$1"

Update: See also the Habari wiki on how to set that up, they have since then added docs on Lighttpd support

With this setup, your blog must lie in the top level directory ( ), should you want to install it in a subdirectory, you need to add it to the url rewrite, for example to install in you would need to replace line 4 with:

"^/blog/(?!scripts/|3rdparty/|system/|doc/|user/(?:themes/|files/|plugins/|locales/|sites/))[^?]*(\?(.*))?" => "/blog/index.php/$1"

August 02, 2008 // Web // Post a comment

Who let the Dwoo out ?

Four months have passed since I started on this project and I finally feel that it is stable enough to make an announcement and have more people trying it.

So what is it ? Dwoo is a PHP5 template engine. Another one you might think, indeed but with every new project comes a new vision, and hopefully you will like mine.

Continue reading...

May 12, 2008 // PHP // Post a comment

Random Seeds - Ordering Disorder

Randomness is great, that's a fact, it's very useful in many areas of programming, and is especially good to build non-repetitive games. However in some cases, it's useful to be able to reproduce randomness.

Let's say you have a Tetris game or a puzzle that randomizes it's different elements before the game start. It might be a nice feature to offer a "Try again" button, which would allow the player to replay the exact same game, to see if he performs better. Or you may want to have two players play the same game to compete against each other, while still playing a random game.

There are two approach to this, the first and maybe the most straightforward is to log the random somewhere to be able to replay it. This works of course, but it forces you to implement the entire logging process, and it uses memory. That's not efficient.

Continue reading...

March 13, 2008 // ActionScript // Post a comment

AS3 and the Display List, addChildAt magic.

ActionScript 3 introduced the Display List, which is the new version of the old depth system that AS1/2 had, and the Display Objects, which replace the MovieClip, but extending the idea a lot since now there are many types of objects that can be added to the Display List.

There are many advantages to this implementation, you don't HAVE to provide a depth anymore, the Display Object names are optional as well, and it's all more consistent as the only way to add an object to the list is through AddChild/AddChildAt, no more createEmptyMovieClip, attachMovie, etc.

All of this is quite easy to adjust to as it's really nicer and more powerful than AS2 was, but until recently I was stuck with my old habits of using depths. What I mean is that, in AS2, if you did ten times createEmptyMovieClip('name',0); then only one MovieClip was left at the end, as each new MovieClip created was overwriting the previous at depth 0.

I recently wanted to add an object at the bottom of the stack, to display it as a background. So I looked at my options, and since I was still thinking in the "AS2 way", I thought about using swapDepths (now swapChildren) on all the current objects to move them up and free the zero-depth.

But then when I went into the documentation to check if this could be done more efficiently with a new method I didn't know of, I realized that the addChildAt method, if set to an already occupied index, will not overwrite it as it happened before. Instead it will just push all the objects up to make room for your newly added object. This is a really great feature, which allows you to really forget all about depths. swapChildrenAt acts in the very same way, allowing to move things around without having to worry about keeping track of all your used depths.

December 21, 2007 // ActionScript // Post a comment

First page< Newer entries 1 2 3 4 [5] 6 Older entries > Last page