Category Archives: PHP

The beginning of the end of PHP’s popularity?

“there will be no more PHP 4 releases, regardless of whether there are security issues found in PHP 4.”

Whoa. Is PHP shooting itself in the foot here?

Despite recent hating and negativity of PHP as a programming language, there’s no debate that PHP still rules as the most popularly deployed scripting language for the web. If you separate PHP developers from those just running PHP applications, that gap widens even further. Ease of deployment for PHP apps plays a huge role in its popularity versus other languages like Python and Ruby, despite the fact there are very capable web frameworks for both. It doesn’t get much easier than purchasing a $5/mo. shared hosting account, slapping WordPress on it and having a website. But could today’s last release of PHP version 4 bring about the beginning of the end of the language’s widespread popularity as a clear leader?

Today Derick Rethans, the release manager for PHP announced version 4.4.9, which is to be the last release of version 4:

“Now, more than 3 years after the last major PHP 4 release, it is time to die down. With hardly any support for OO, sub-standard XML support and generally lots of other suckyness as well, it’s time to focus on the future: PHP 6. So please die PHP 4 – and quickly. Today, August 7th, 2008 is the last release of PHP 4 – PHP 4.4.9. After today there will be no more PHP 4 releases, regardless of whether there are security issues found in PHP 4. It’s time to upgrade now.” [link]

Now, there are reasons that popular software for PHP is to this very day still written for PHP 4. A large number of hosting providers have not made the jump to version 5. While both versions can be run simultaneously, the solution is not optimal, and a bit of a hack. A little over a year ago, Matt Mullenweg of WordPress stated his reason for not abandoning version 4. I personally disagree with his apparent “if it ain’t broke don’t fix it” attitude:

WordPress works just as well with PHP 5 as 4, and there are no features on the roadmap (including ones on your list) that would require PHP 5. The only reason for us to break PHP 4 compatibility would be political, and our users without the ability to upgrade their server would be the ones who lose. WordPress doesn’t make PHP 4 interesting or not, it’s agnostic.” [link]

I certainly agree that Matt should have his user base in mind, and that yes, WordPress as an application is not novel because of the language it is written in, but to say there is no advantage to using the PHP 5 features in the development is a bit dubious.

But now there’s a new dilemma facing both the hosting providers and application developers such as WordPress; namely, the “vendor” of PHP 4 is closing shop. As far as official PHP releases are concerned, there will be no bug fixes, security updates, feature additions, or optimizations. What will happen if a serious security hole is found? I’m not preaching FUD, but being realistic based on history. At what point will hosting providers have to upgrade? Will the application developers follow suit and take advantage of the PHP 5 features and benefits? More importantly, will the ease of use of frameworks like Rails and Django bring about the “killer apps” for the world’s blogging, e-commerce, mailing list management, classified ads, and other applications that put PHP where it is today? Is Typo indeed the next WordPress?

It’s no secret I’m a fan of PHP, warts and all. PHP will do fabulous things for you as the glue language that it is. There are plenty times when I don’t need a full-stack MVC that would just be wasteful. I wholeheartedly agree that Rails is a joy to develop with, even if it’s a pain to deploy, but I would challenge anyone to a pure Ruby vs. pure PHP hackathon to prove you can write “cowboy code” in any language.

As far as my predictions for PHP’s popularity ranking, I’m really not worried. The upgrade is not bad, the building and configuring of the software across versions follows the same conventions. Porting applications, if they need it at all, is a modest task. For PHP to lose its foothold among hosting providers, better app solutions from other languages would have to exist, become wildly popular, and have good community support for updates. Simultaneously, the frameworks and server libraries would have to be stable enough for hosting providers to support and provision. So really the choice is: modest upgrade to PHP 5, or complete overhaul to trendier languages and frameworks? Of course, we talking open source here, so I guess there’s always a possibility of a grassroots PHP 4 maintainence posse.

Advertisements

Yahoo Pipes adds support for serialized PHP

A few days ago I sent an email to Chad Dickerson, who I’ve met at Yahoo! and had a chance to hang out with at Mashup Camp in Dublin.

Chad,

From what I can tell, if you create a Pipe and add additional fields (Shortcuts, Term Extraction), the only way to get to them in an API-like way is to use the JSON renderer. The RSS renderer removes those extra fields to follow the RSS spec. PHP supports JSON decoding, but you need a PEAR library or a quite recent version of PHP. If Yahoo supported serialized php with Pipes like you do with the other common API’s, it would be a lot easier for folks on shared hosting to work with Pipe data on the server side. I imagine with the new badge stuff you released that there’s a push to keep things client side, but there’s a huge advantage to rendering server-side to keep things nice and spiderable.

Short Version:

Expose Pipe results as serialized PHP. Pretty please.

Chad sends this along to the Pipes team, and less than three days later:
Pipes Blog » Blog Archive » New Yahoo Pipes PHP serialized output renderer

kick.
ass.

John Herren and Chad DickersonTwo points to be made: first, I’m damn impressed that one of the largest sites on the ‘net would roll a feature request from an outside developer in less than three days. Second, developers should never resist the urge to ask for help from an API provider. If a company is taking the time to support an API, chances are very good that they will listen to developers and react. I can personally say I’ve gotten immediate results from Technorati, Dapper, and now Yahoo!. So blow off the idea that a big website would never listen to little ol’ developer you. With that negative attitude it’s guaranteed you’ll never get it. Ask, believe, receive, right?

So props to Chad, Jonathan Trevor, Paul Donnelly, and the rest of the Pipes team!

The Details

I’m a big fan of Yahoo Pipes. It’s an incredibly useful tool for putting together quick aggregators and filters for mashups. To integrate a Pipe on a webpage, you have a few options. You can go the cut and paste route and use a Badge, which works client side, or you roll your own code to integrate a pipe.

Put this in your pipe..

After you run a Pipe, you’re given a list of output formats. Copy the link location of these to get the URL of the output and tweak the parameters.

Until yesterday, the output formats useful for mashups were JSON and RSS. JSON is great for client side mashups, but as you know, search engines will not index client side content, so you lose any SEO love you might get. RSS is easy to consume server side, but Pipes will normalize the output to conform to the RSS spec. That means if you’re using term extraction or Shortcuts or any other meta data to your pipe, you’ll lose it with RSS ouput unless you put that data into one of the RSS fields (title, description, etc.). So that leaves us with hacking JSON on the server side. The JSON output format retains all that sweet metadata. In PHP, the best options are a JSON PEAR module or, if you’re rocking 5.2 and above, you have the handy json_decode() function.

Now that Yahoo supports serialized PHP, using Pipe output just got a lot easier. I made a Pipe to add Term Extraction info from any RSS feed. Basically what we’re doing is automatically tagging all the posts in the feed and to retrieve the tags in your own script, all it takes is:

<?

$pipeURL = ‘http://pipes.yahoo.com/pipes/pipe.run?_id=Zli1l6UB3RG_l7ZvX0sBXw&_render=php&rssurl=‘;
$feedURL = ‘http://rss.news.yahoo.com/rss/topstories‘;

$tags = array();
$response = unserialize(file_get_contents($pipeURL.rawurlencode($feedURL)));
foreach ($response[‘value’][‘items’] as $item) {
foreach ($item[‘tags’] as $itemTags){
$tags[] = $itemTags[‘content’];
}
}
var_dump($tags);

At this point $tags is and array of all of the terms from the feed. Now what could be done with that data?

Serialized PHP or JSON?

If you have json_decode() available in your PHP install, is there any advantage to using JSON over serialized PHP? Let’s find out.

File Size

Saving the output directly to disk gave me

JSON – 51192 bytes
Serialized PHP – 56885 bytes

Because of syntax and PHP’s type specification, serialized PHP is about 11% larger than JSON. This ratio will increase as the number of elements in your output increases.

Decoding Speed

How long does it take to slurp these formats into PHP variables? My tests decode each 100 times.

JSON
real    0m0.269s
user    0m0.264s
sys     0m0.004s

Serialized PHP
real    0m0.088s
user    0m0.088s
sys     0m0.000s

It’s clear that unwinding serialized PHP is faster than JSON, so it’s a better choice performance-wise despite being slightly bigger over the wire.


Halloween == Christmas

Because

Oct 31 == Dec 25

It’s an octal joke. John Lim over at PHP Everywhere had to chase a bug report because in PHP tossing a zero in front makes your number octal, the way 0x makes you hexadecimal.

Octalpussy | PHP Everywhere

Octal notation can be useful for things like filemasks, but I can’t think of many other practical (non-bit fiddling) uses, so school me on it please.

A common PHP mistake is forgetting the chmod() function wants an octal number as the file mode. I wrote about this and some other fun screwups when I worked for Zend in an article called PHP Gotchas, which could really use a part two..


Stop comparing PHP to Rails

PHP is a language. Rails is a Ruby framework.  Comparing PHP to Rails is like comparing Perl to Django, or Haskell to Seaside, and that makes no sense. Two things that DO make sense:

  • Using PHP for web development. It deploys and scales great.
  • Using Ruby on Rails for web development. The framework provides an excellent set of conventions for rapid development.

PHP Gets Namespaces

$reasons_php_sucks--;


Want a sweet developer job?

My good buddy Hans Veldhuizen is working on a new music startup called NovaTunes. They are looking for a solid PHP developer to work in Venice Beach:

Life’s a Beach! Fix The Music Business! Work in VENICE, California
NovaTunes is a revolutionary new music company putting control in the hands of the artists and delivering quality music to a hungry global community. One lucky contestant will join a small team of web and music veterans as Software Architect. NovaTunes has a great vibe, sits 100 yards from the Boardwalk and is hooked-up in the worlds of music and web.

We seek an experienced code writer unafraid to get his/her hands dirty and turn a great vision into a reality working with and managing top software developers both off-site and at our Venice HQ. The Software Architect guides development of the company’s web site, community and technology and interfaces with Web Producers to create widgets and cool web apps.
A successful Software Architect will have an excellent opportunity to make a difference and advance within the company.

Skills:
– Solid PHP and MySQL scripting skills
– Familiarity with HTML, DHTML, JavaScript, CSS 2.0
– Widgets/Gadgets using Flash or Ajax
– Audio-Video and Broadband and Networking
– Hands-on experience with relational database design and web service API’s
– Search engine optimization
– Some knowledge of JSP/Java, ASP,.NET
– Familiarity with the LAMP environment (Linux, Apache, MySQL, PHP)

Bonus Skills:
– 5+ years professional Web development experience
– BS/BA in CS, EE, or equivalent education experience
– Strong presentation, communication, and collaboration skills
– Experience with online communities
– Positive attitude and professionalism in the workplace

Perks:
Generous equity in well-funded company, benefits, competitive salary and casual work environment.

Contact Us:

So, if sad and you’re feeling blue go out and buy yourself a new pair of shoes, but if you need a job to afford the shoes call Michael Lato @ 310-748-8041 or send an e-mail to novatunesjob@gmail.com.


Busy week at the Zend Conference

ZCE logo

The Zend conference this week has been lots of fun. Here’s a rundown of some of my personal highlights from the Zend Conference.

  • Finally meeting my buddy Aaron Wormus in person.
  • Finally meeting my buddy Jon Bauer in person.
  • Meeting Ilia Alshanetsky, Sara Golemon, Christian Wenz, Shahar Evron, Sebastian Bergman, Chris Anderson, Matthew Weir O’Phinney, Eli White, Chris Jones, Paul Reinheimmer, and Wolfgang Drews.
  • Hanging out with my other PHP friends.
  • Having my work with the Google Data APIs shown off at the opening keynote.
  • Seeing Dave Berlind show off my good friend Andrew Bidochko’s MapBuilder service in his mashup keynote.
  • Running into Nilesh Dosooye among thousands of crazy Halloweeners.
  • Taking and passing the new version of the Zend Certification Exam. I’m a Zend Certified Engineer!
  • It also turns out I’m the deuce of spades.

P.S. If you attend a conference session, glean the speaker’s knowledge, and then decide you need to steal that speaker’s personal property, it officially makes you a “punk ass.” May the fleas from a thousand herd of buffalo infest your armpits.