PHPNews

Silex Controllers as Services

**UPDATE**: The functionality described below is now baked in to Silex, checkout the [ServiceControllerServiceProvider](http://silex.sensiolabs.org/doc/providers/service_controller.html). **TL;DR** Use a custom controller resolver to load controllers from the service container - [code][code] I'll …

Continue reading »

Written by Dave Marshall - - Aggregated on Wednesday October 3, 2012


Too few DEFINEs for my taste

The Crime It takes a big man to admit when he’s wrong, and @dilbert4life is one of those men. Here’s a snippet of horror that he wrote around a year-and-a-half ago. Too many defines? Nay! I say let the site grow and see just how many we can stuff in there. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18…

Continue reading »

Written by CSI: PHP - - Aggregated on Friday September 28, 2012


What idiot wrote this? Oh, wait, it was me.

Starting with this post, we have a new category here at CSI: PHP. It’s called ‘ mea culpa ’, and it’s criminal code written by yours truly. Behold the awesome that is error() , an unholy concoction of PHP, JavaScript, and HTML. It’s the only function in a file called common.php, which makes perfect sense because …

Continue reading »

Written by CSI: PHP - - Aggregated on Friday September 21, 2012


Stop rolling your own

Seriously. Stop it. Or you’ll end up with garbage like this, in which a developer writes two separate functions for converting JSON to an array, only one of which is compatible with json_decode . Yes, both are in production. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 …

Continue reading »

Written by CSI: PHP - - Aggregated on Friday September 14, 2012


We don't need no stinkin' POST variables

CSI: PHP investigator Duane Gran sent in this horrifying snippet. He explains: I wondered why dumping the $_POST variables before this section didn’t help in debugging. This occurs in a second step of a 3-step form on a GET request. It applies a set of session fields to the $_POST variable for later use. …

Continue reading »

Written by CSI: PHP - - Aggregated on Friday September 7, 2012


Why Symfony?

Yesterday, Zend Framework 2.0 and Symfony 2.1 were released... almost at the same time. First, I want to congratulate the Zend Framework team for this huge milestone; I know that working on a new major version is no small task. And of course, people started to ask questions about these new versions and one of the …

Continue reading »

Written by Fabien Potencier - - Aggregated on Friday September 7, 2012


I do not think DRY means what you think it means

Perhaps this developer decided it would be better to create convenience methods than to litter their codebase with date format strings. Nothing wrong with trying to DRY up your code, but creating 13 inscrutably named date formatting functions ain’t the way to do it. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 …

Continue reading »

Written by CSI: PHP - - Aggregated on Friday August 31, 2012


data-attributes are an anti-pattern

HTML5 has a lot of cool things in it, but the one thing I wish I could remove are data-attributes, because of the crimes against clean front-end code that it seems to encourage. What is this clean web code you speak of? We have 3 technologies that go into building a web app, HTML, CSS, and JavaScript. All three …

Continue reading »

Written by Matt Briggs - - Aggregated on Friday August 10, 2012


Are PHP developers functophobic?

There is this one thing that I noticed recently and that concerns me: PHP devs don’t use functions. Now, that was overly general, so let me clarify: PHP developers who have reached a certain degree of sophistication basically stop using plain functions - instead everything goes all classes and methods. At least …

Continue reading »

Written by Nikita Popov - - Aggregated on Friday August 10, 2012


How Shall We Define Design?

I love object-oriented design. It’s like open source software in general; perfect strangers come up with ideas that can save me time and money and then, out of the goodness of their hearts, go to a fair amount of trouble to pass these ideas on. I benefit from their efforts every day. However, you don’t have to go …

Continue reading »

Written by Blog - Sandi Metz - - Aggregated on Thursday July 5, 2012


PHP is much better than you think

Rants about PHP are everywhere, and they even come from smart guys. When Jeff Atwood wrote yet another rant about PHP, it made me think about the good parts of PHP. The biggest problem of these rants is that they come from people stuck in the old days of PHP. They either don't care or they don't want to admit that …

Continue reading »

Written by Fabien Potencier - - Aggregated on Wednesday July 4, 2012


Cron Expression Parsing in PHP

As a PHP developer, I’ve often been faced with the task of ensuring something happens on a recurring schedule or determining the next date in time an event will occur. At my previous job, we needed to run scheduled Gearman jobs on a recurring basis. We chose to use cron as the serialization format of our schedules, …

Continue reading »

Written by unknown - - Aggregated on Sunday June 3, 2012


Cron Expression Parsing in PHP

I’ve often needed to ensure that something happens on a recurring schedule. At a previous job, we needed to run scheduled Gearman jobs on a recurring basis. We chose to use cron as the serialization format of our schedules, and implemented a database driven system for storing these schedules. Storing the cron …

Continue reading »

Written by unknown - - Aggregated on Sunday June 3, 2012