When using Doctrine, it very frequently happens that you have an entity in hand, an Article for example, that is in a many-to-one relationship with another entity (a Category), and you need to get the related entity's id. The problem is that Doctrine uses proxy objects for relationships, and when you access the id, the proxy will self-load itself, sending a query to the database. Shouldn't it be possible to get the related id, without another query? It's in the same table after all.
Every time I have to set up Symfony2 on a new machine, I get a bit lost on the rewrite configuration. Rewriting in apache is easy, since the net is already full of examples on how to do it, but there is nearly not as much info for nginx (yet).
I have done many stupid things in my life, but today, I have a new contender for the 4th most idiotic thing I have done, ever. I saw an ad at the place where I usually play squash for a "military-like endurance training" program, and I thought it might be a good idea to try that.
I just had a chance to use the "new" HTML5 <audio> tag. Using it is just as eas y as using anything from HTML5/CSS3. That was sarcasm. The same things apply, you need to be aware of all the various browser inconsis tencies. The main one is the supported formats of course, some vendors support the industry standard MP3, others don't want to support that because it's not open, and Google supports everything because they are swimming in money, and can afford it. Turns out that in o rder to support all the browsers out there, you need to offer at least 2 kinds of formats, consult the chart on Wikipedia for details. While that's inconvinient, like most things in the CSS3/HTML5 area, there is a much bigger waitwhat? here.
We were looking for an easy to set up hosting solution for our new PHP application. A colleague mentioned that we should try Heroku, since they are praised everywhere. I can agree, I don't even know what it is, but I have already seen it praised on various blogs.
Some interesting stuff I found while browsing my RSS feeds, upcoming new stuff in PHP 5.5, a site called PHP The Right Way, and it looks like PHP will finally have some kind of official coding style.
Common scenario: it is the beginning of a new project, you create a new virtualhost in your webserver, record newproject.local into your hosts file, so the address resolves to your local machine, restart webserver, test. Is there an easier way? Yes, it is possible to spare the part where you edit the hosts file.
This a response to Mattis Geniar's post, titled Bad ORM is infinitely worse than bad SQL, where he talks about his bad encounters with ORMs, and how easy it is to mess up performance, and forget about what really happens behind the scenes. He ends the post with
If you disagree with me, prove me wrong.
Be my guest.
The new major (or minor, if you look at version numbers) version of PHP has been released on March 1st, so here's the obligatory blog post on the new features. I'm only covering the parts that I think are important, this isn't a complete changelog.
Doctrine2 is an ORM (Object relational mapper) library for PHP, and is one of the best things to happen to the PHP world, so far. The main point of an ORM is, to put it simply, to allow you to map PHP objects, to database tables. You can save and load your objects to/from the database, in a general way, that is, you don't need to write select/insert/update/delete SQL queries for them, because the ORM will take care of that for you.