Tuesday 07th January 2014 PHP-Based CMS Comparisons
Not every development project we work on gets to be a brilliant portfolio piece that showcases our PHP mastery. Sometimes, we wind up accepting projects that require a fair amount of front-end development in addition to the more exciting programming aspects. Rather than completely re-inventing the wheel by coding an entire site from scratch complete with convenient access for clients to update and add new content themselves, sometimes it can be useful to employ a content management system (or CMS). This saves a great deal of time and work, and lets you focus on the more interesting development challenges without a whole lot of tedious mucking around on front-end work. Fortunately, there are several great PHP-based content management systems that can be easily installed and then customised to meet your needs.
Easily one of the most popular and easy to work with is Wordpress. While those of you without much experience with it may tend to think of it simply as a blogging platform, it's actually quite extensible thanks to a robust PHP-based plugin system that allows you to develop and implement additional functionality using the PHP language. In fact, there is an extremely large directory of plugins both free and paid that are available for download, and install with the click of a button which can then be edited to your needs. The entire CMS itself is also coded in PHP, which means it will take very little work to get up to speed even if you've never used it before.
Another very popular PHP CMS is Drupal, which is one of the oldest (if not the very oldest) PHP CMS' found on the web, having been launched way back in 2001. This extended lifespan shows in it's capability and scalability, but compared to working with Wordpress, it's extremely difficult to get a handle on. Most plugins available for Drupal, known as 'modules', are not free, although there are a few good ones floating around. Definitely the choice of more seasoned developers, those less experienced should lean towards a Wordpress or Joomla implementation - to give you a sense of what it can do, the US government website whitehouse.gov is powered by Drupal.
Joomla is a sort of happy middle ground between the extreme flexibility of Drupal and the simple hand-holding of Wordpress. Powering a respectable set of sites that includes linux.com, Joomla is aimed more at an interim-level developer who needs more capability than Wordpress offers but doesn't require the same level of implacable stability that comes with the more rigid Drupal. However, its SEO-friendliness leaves something to be desired compared to Wordpress, although it does have a similarly expansive plugin directory that can save you a lot of development time.
Always choose the right CMS for the job!
Thursday 02nd January 2014 The Hidden Mysteries of PHP
Ah, the age old bane of programmers: documentation. Or, more specifically, the lack thereof, especially when it comes to working with someone else's code. However, the problem can sometimes be compounded a thousand-fold for the actual creators of a programming language, as they have a far more comprehensive and staggering task ahead of them. This is especially true for a language like PHP, which as you may or may not know, arose from a set of tools coded by one intrepid web developer in the early 1990s by the name of Rasmus Lerdorf. PHP, or Personal Home Page Tools as it was known originally, has since grown to become the most widely used programming language on the web, and the documentation that comes along with PHP has also been developed into a fairly robust and well put together guide to the language.
Many web developers learned the language without ever actually touching the manual, however, and may be slightly surprised by some of the amusing tidbits of information that are scattered throughout the official PHP documentation. In fact, as user-generated content in the documentation grew, a website sprang up dedicated to bringing these bits of hilarity and inexplicability to light, named 'PHP Manual Masterpieces', which is worth a visit if you have some time and you love (or are simply curious to learn more about) PHP.
One of the things that has perplexed PHP developers since the very beginning of the language was the structure of the function names. They're sort of all over the place, and PHP Manual Masterpieces highlighted this issue when they brought to light a hilarious revelation from Lerdorf in a forum exchange. Another developer asked Lerdorf what the rational was, to which he replied, "Back when PHP had less than 100 functions and the function hashing mechanism was strlen(). In order to get a nice hash distribution of function names across the various function name lengths names were picked specifically to make them fit into a specific length bucket. This was circa late 1994 when PHP was a tool just for my own personal use and I wasn't too worried about not being able to remember the few function names."
Yup, you read that right. PHP functions were renamed simply to make them fit a certain length, which explains why so many developers have torn out their hair trying to work with them. But hey, we still love you, PHP.
Monday 30th December 2013 A Look at Laravel
Frameworks, frameworks frameworks - like the old adage about real estate locations, frameworks tend to be on the tip of every PHP developers tongue these days. The relative merits of each one are up for debate, and many developers fiercely defend their chosen framework against any possible slight, real or imagined. While many contend that it's more important to choose the right framework based on the particulars of a given project, there are still wide disparities in the usage of the various options. As we saw in our look at the usage statistics that are the obligatory part of the 'end of year' type blog posts, a clear frontrunner has emerged from the PHP framework pack in 2013 and outpaced all the rest: Laravel.
Fully 25% of all PHP developers responding to a poll hosted by developer hub SitePoint said they use Laravel, which makes it easily the most popular framework around. This is by no means completely scientific, as this data was gathered by a single site, and there are plenty of ways the data could be distorted, but regardless, Laravel merits a closer look for those of you who are still unfamiliar with it.
Often touted as a spiritual successor to the now relatively defunct CodeIgniter framework, Laravel is famed for its simplicity of use and gentle learning curve, which is no doubt part of the reason it scores so highlight on the SitePoint poll. Already up to version 4 at the time of this writing, Laravel has developed quite a large community and so overcome some of the initial trepidation that developers had when it comes to adopting a new framework. It's even reached a point where the first Laravel conference will be held this year in May, Laracon 2014 in New York City.
Those who've embraced Laravel rave about its intuitive usage, easy routing and that it comes out of the download with Eloquent ORM, which plays nice with all manner of database formats. This is especially useful now that the latest version of PHP are starting to deprecate MySQL extensions in favour of MySQLi and, even better, PDO, which Laravel plays quite nicely with. The framework itself is built on a number of components from the well-known Symfony framework, which also lends weight to its stability, reliability and credibility.
So whether you're a new PHP developer looking for a framework to whet your appetite or a framework-weary old hand, you'll likely be able to find something to catch your interest in the Laravel framework.
Posted on December 30th 2013 at 09:32pm
Friday 27th December 2013 The PHP Zeitgeist Project
As another part of the annual end-of-year statistical roundups that are happening everywhere, at the end of December the PHP Zeitgeist project receives its yearly update. For those of you who haven't heard of the project before, it follows a similar model to the Google Zeitgeist project, which provides a summary of the most popular search topics for the preceding year - the difference being that the PHP Zeitgeist project has actually been going on since the year 2000, when PHP Classes, the site that operates the project, first published its website.
While the project only tracks searches made on the PHP Classes site itself, it's truly fascinating to see how the see how the priorities of PHP developers have evolved over the course of PHP's lifespan. Looking back at the results from the year 2000, all the searches are for extremely basic functions of PHP, largely concerned with relatively things like sending email and connecting to and querying MySQL databases, as developers were just beginning to get a handle on what PHP could really do.
Fast-forward to this year, and you'll see that in 2013 developers were concerned with far more complex matters. Chief among the searches was 'wordpress data import class', which highlights the dominance that Wordpress (and by extension PHP) has over the majority of the web, and is operating as the de facto blog publishing standard. File formats were another major concern of developers, as users are relying more and more on web-based applications for handling file transfers and conversions.
Interestingly, database query searches are still roughly as common as they were in 2000, but focus has moved away from MySQL and shifted in favour of newcomers MySQLi and PDO (PHP Data Objects). Thanks to the latest release of PHP 5.5, MySQL is going to be left by the wayside in favour of more robust options that have been more thoroughly developed recently.
Posted on December 27th 2013 at 09:53pm
Tuesday 24th December 2013 PHP Frameworks: 2013 Roundup and Looking Ahead
As 2013 comes to a close and we reach the season of holidays, the new year, and year-end statistical roundups, many people are curious about the state of the PHP framework debate. As with many debates among programmers, the opinions are often loud and tenacious, and understandably so - it tends to irritate us when other people don't see the same advantages that we do (ah, the perpetual design versus development debate). With that in mind, one of the best ways to compare the relative metrics of the available PHP frameworks is to look at how many people are using each one over the course of the last year.
As you're no doubt aware, there are many, many frameworks to choose from, but most of them capture a relatively small percentage of the so-called market share. According to a recent poll conducted by the ever-popular developer website SitePoint, the six most popular frameworks account for almost 75% of the available market share, with the remaining twelve polled dividing up the remaining 25% between them. The most popular framework is Laravel, by a relatively wide margin, taking home over 25% of the votes all by its lonesome, followed by Phalcon in a distant second with nearly 17% of the votes. Symfony2 rounds out the top three with almost 11%, followed by a tie between CodeIgniter and Yii for fourth place at 7.6%, and then yet another tie between Aura and CakePHP at roughly 4% apiece.
Looking at these results, you'd probably be inclined towards experimenting with Laravel for your next project, as we all know that the larger the community a framework has, the better the support will be and the more robust the framework will be overall. However, as a new year is also a time for new resolutions, you might want to consider experimenting with more than one framework over the course of your upcoming projects. Obviously, you'll need a couple of projects to really put a framework through its paces, but matching the right framework with the right project can make a huge difference in performance and ease of development. Symfony2, upon which Laravel is based, is often praised for the huge number of features it provides, but is also decried as slow and clunky by its detractors for the same reason.
In order to choose the right framework, you need to know each one of them, and be familiar with the pros and cons of each one - so make 2014 a year of experimentation and expanding your horizons, and you'll soon see that blindly picking one framework and sticking with it can be a time-consuming mistake. Be flexible, and have a happy new year!
Posted on December 24th 2013 at 07:49pm
Friday 20th December 2013 Facebook Porting PHP VM to ARM Architecture
Facebook is arguably one of the most well-known websites in the world. With over a billion active user accounts (despite some disagreements over how many of those are fake accounts), Facebook is also one of the largest PHP deployments in the world - if not the absolute largest. A custom written virtual machine dubbed the 'Hip Hop Virtual Machine' translates Facebook's PHP code into 64-bit x86 instructions for various kinds of heavy-duty server-side computation.
Naturally, though, they're interested in ensuring that they have the best possible setup on the back-end, and the up and coming ARM architecture has a number of advantages over x86 processors for massively scaled server setups like Facebook uses. Interestingly enough, Google, who uses a mixture of AJAX and Python for their heavy lifting as also interested in experimenting with the ARM processor architecture.
For Facebook, however, the primary concern is not being locked into a monoculture of processors as various implementations of the technology evolves. They're hoping to adjust the Hip Hop Virtual Machine to be as architecture independant as possible, although their most realistic timeframes don't see a complete switch for several years.
The ARM processor architecture is extremely attractive for any large web-based service, as it's far more power-efficient than a comparable x86 server farm setup. When you have a massive number of servers the way Facebook does - estimated in 2012 at just under 200,000 - power bills are one of your major concerns, and the ability to adopt newer, more power efficient architectures is extremely appealing.
While Facebook is remaining relatively quiet about the entire process, you can look at a far more technical explanation of their plans at their Hip Hop Virtual Machine blog here
. If you're a highly-skilled PHP developer who is also very familiar with the ARM server architecture, you might even consider applying for the job!
Posted on December 20th 2013 at 10:36pm
Tuesday 17th December 2013 PHP.net Breached With Potentially Unique Malware
In what is no doubt an embarrassing security breach, PHP.net, the official website of the PHP programming language, was compromised temporarily by hackers. Having a server compromised is not a particularly rare occurrence in the modern digital era, although as the flagship site of the PHP language, it must be particularly galling - as well as being a potent cautionary tale for PHP programmers everywhere. After all, if it can happen there, it can happen anywhere.
The attack, which compromised the site for nearly 3 days in October, was intended to force users who visited the site to download and execute some malicious code - also not particularly uncommon in this day and age. More recently, however, security researchers were analyzing the payload that was downloaded to user's machines, and found it to be a highly specific and potentially unique piece of malware dubbed DGA.Changer, which employs sophisticated techniques to evade detection and maintain links with command and control systems, for the purpose of downloading other pieces of malware to the infected machines which would otherwise be caught and removed.
Here's where things get curious, though: the machines infected by DGA.Changer from the PHP.net attack don't seem to be downloading other pieces of malware. There have been no reported cases of additional malware downloads in the wild, and security researches are concerned that something more complex is at work - the digital equivalent of the 'long con', perhaps. Aviv Raff, CTO and security researcher at Seculert writes, "Our analysis at this point is that 'no news is bad news.' Why would adversaries deploy a malware which downloads nothing, on a site used by software developers, and then engineer it so that it can receive commands from a C2 server to change the DGA seed? It makes no sense—and that [is] worrisome. Not all adversaries are geniuses, but they typically have an agenda."
The current running theory is that PHP.net was targeted because it has a very high probability of being visited by PHP programmers who are working on high-value projects that may not even be released yet, giving whoever holds the keys to DGA.Changer a very valuable pool of potential targets. While there seems to be no activity or damage caused as a result of the attack, the possibility that someone is specifically targeting PHP programmers rather than average users is a disturbing trend that should have every developer concerned - and ensuring their antivirus definitions are up-to-date and working properly.
Posted on December 17th 2013 at 10:46pm
Saturday 14th December 2013 Symfony Gets Boost from SensioLabs Funding
Most PHP programmers are familiar with the value of using frameworks in their coding projects. As a result, there are now quite a number to choose from, but one of the most popular and widespread is the open source PHP framework Symfony. While the project is open source, it was originally developed way back in 2005 by a team led by Fabien Potencier that formed a startup in France last year, SensioLabs. This same firm recently completed a round of financing from venture capital firm CM-CIC Private Capital, to the tune of $7 million USD.
SensioLabs founders Fabien Potencier and Gregory Pascal have announced several upcoming projects, one of the most exciting of which is SensioLabsInsight, which hopes to measure the quality of PHP code within a given application. Originally launched as a beta in October of this year, and still only available to private beta testers, it no doubt helped to secure the round of funding they received. The main goal of the startup, however, is to provide support for developers and companies that implement the Symfony framework in their applications, with the intent of fostering more widespread adoption.
This is an ongoing challenge, of course, as despite the fact that PHP is the most common programming language on the Internet, there are a growing number of detractors who advocate the use of other competing languages such as Python and Ruby on Rails. However, thanks to the widespread success of Symfony, the community that's grown up behind the framework released a more recent updated version in 2011, Symfony2, to even more widespread acceptance.
This level of continued support for the framework should make it even more enticing to companies who are searching for a robust, well-established framework. Yahoo was one of the first major companies to embrace the original Symfony framework, and since then, TOEFL, Virgin Mobile, and the French government (among many others) have all implemented Symfony in some way, and no doubt many more big names will sign on as a result of these events.
Posted on December 14th 2013 at 09:13pm
Wednesday 11th December 2013 Coping With Legacy PHP Code
Developers, like any creative individuals, tend to like to work on their own projects from start to finish. There's nothing more satisfying than seeing a project go live that you've shepherded the whole way from conceptual planning to development and testing to that sweet, sweet final build. Sadly, the world doesn't always work that way. Whether you're working as part of a larger development team, you've been brought in to redirect a project that went off the rails or you're updating a project that's been around almost as long as PHP has, at some point in your career you're going to run into code that doesn't shine - and you're still going to have to work with it.
At first blush, it can seem pretty overwhelming to pick up a project that's got years of development behind it. As with most actively ongoing PHP projects, the entire codebase has evolved over time as the needs of the client, the user and the technology itself has adjusted over the project's lifespan. Even the language itself has changed dramatically since it was first implemented. Best practices that are commonplace now were barely heard of and rarely used when some projects began, and those that existed at the time were not well known. So what do you do?
The most important thing to do is to examine the codebase in its entirety and decide what's most sorely in need of updating. Prioritising your list of updates can make the job seem less like an impossible mountain to climb and actually more like something that might be completed within your lifetime. What sections of code are you going to be working with most directly? Which aspects are so antiquated that they can barely interface with any new code you write? Are there any gaping security holes? Answering these simple questions can provide you with a roadmap of smaller goals that can quickly be completed, giving you a sense of control over the project.
Don't get caught up in a perfectionist mindset. Is it really important for you to start with small-scale optimisation improvements? That can probably wait until some of the larger issues are sorted out. Above all, though - make sure that you follow current PHP best practices when you're implementing your changes, otherwise you - or another programmer a couple of years down the line - are just going to wind up in exactly the same situation as before.
Posted on December 11th 2013 at 09:11pm
Saturday 07th December 2013 Facebook PHP Virtual Machine Released
One of the holy grails of complex PHP application development is maximizing performance. Not only does better performance mean more manageable server loads, if you're scaling large enough, there can be a number of other dramatic gains in terms of power consumption and energy costs. Few companies are more familiar with this than the social networking giant Facebook, which is coded entirely in PHP and also just happens to be the largest social networking site on the planet. With over a billion active accounts, that's nearly 20% of the entire world's population - almost nobody else is as familiar with complex and robust PHP deployments as they are.
When it comes to web deployments of PHP applications, most developers initially choose to write the complicated code in PHP, but as the application scales and the usage levels increase, the more complex calculations are often re-coded using a faster server-based language such as C or C++. Facebook itself did this in the past, using a custom compiler named HipHop that translated the site's PHP code into C++ for faster execution. As in many large development environments, however, this eventually grew to create separate problems, which meant a new solution was called for.
Thus began the development of the HipHop Virtual Machine, or HHVM as it's more commonly known. Without getting too deep into the technical specifics, the HHVM translates PHP code into a custom bytecode known as HHBC (you guessed it, Hip Hop Byte Code) which is then processed by an x64 just-in-time compiler, along with a companion bytecode interpreter when absolutely necessary. This allows Facebook's entire staff of PHP developers to work on the entire codebase together, instead of dividing up the development process into PHP and C++, which can often lead to major headaches when it comes time to reconcile.
Joel Pobar, a developer at Facebook, cautioned that many developers hoping to gain performance improvements from implementing HHVM may not get the results they want, saying, "Chances are [your code is] spending too much time talking to the database or spending too time talking to the memcache caching layer." In other words, your performance bottleneck isn't likely to be execution speed, as there are other more typical culprits that can be identified by using benchmarking applications. The HHVM is strongly optimized towards very large PHP codebases with very heavy usage loads, but it may be worth investigating for your next project.
Posted on December 07th 2013 at 10:13pm