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
Wednesday 04th December 2013 The Importance of Keeping PHP Up to Date
PHP is a robust and flexible language, used almost everywhere on the web in one form or another - and, increasingly, it's being used in many non-standard environments. As we grow into the so-called Internet of Things - the holy grail of web connectivity where every device we own is integrated into a network - the places PHP can be found are often extremely surprising to the unexpecting user. Never before has this been more highlighted than by a new piece of malware that was identified in the last two weeks by security firm Symantec.
Capitalising on a by-now ancient PHP bug, the malware is a worm known as Linux.Darlloz has currently only been infected Intel x86-based systems, but security researchers warn that there are variants of the worms code that are designed for chip architectures that are most commonly found in consumer-grade routers, IP security cameras, and even television set-top boxes, which are not typically devices that are targeted by malware attacks. While there have been no recorded incidents of any of these devices being infected 'in the wild', the possibility exists that the current operational structure will change.
This serves to highlight the importance of working with up to date versions of PHP, and ensuring that if you or your company are responsible for working with devices that contain web interfaces, as most devices in the Internet of Things do for control and configuration purposes, it's absolutely crucial to roll out properly timed security updates. The particular flaw exploited by the Linux.Darlloz worm is only found in PHP versions 5.4.1 and earlier ; the patch for the flaw was implemented as far back as May 3rd of 2012.
It doesn't take much time to ensure that your current development environments are running the latest version of PHP - a quick version check and an update to your binaries is all it takes. It's possible that you may have to make some updates to any projects that are currently in the works, and if you've got any deployed projects they should be updated to patch any security flaws, but the benefits of the added stability and security far outweigh the hassles involved in staying updated. Even if you're not ready to adopt the latest bleeding edge version, at least try to stay with a version that was released in the current year.
Posted on December 04th 2013 at 03:29am
Saturday 30th November 2013 The History of PHP
Over the course of this blog, we've covered a pretty wide range of topics relating to PHP. Learning, security, frameworks, best practices for build and launch, and even good ways to keep your code clean and reuse well-written snippets. There's one point that we've neglected to mention, though: the history of PHP itself. Even the acronym itself was something of a mystery, so we decided to take a quick trip down memory lane and discover how PHP came to be the powerhouse of a language that it is today.
PHP was originally developed as part of another language, known as PHP/FI, by Rasmus Lerdorf all the way back in 1994 in the very earliest days of the World Wide Web (it was so long ago that people were still actually calling it by its full name). Lerdorf had published his resume online, and wanted to ensure that he could track how many visits the resume had received. He had written some CGI (common gateway interface) scripts in Perl to handle this, but thanks to performance considerations he rewrote the scripts in C, and for good measure, incorporated the ability to interact with databases and web forms. This was the rather clunkily named PHP/FI, which, when released to the public in 1995, extended out into the name (wait for it…. big reveal time!) Personal Homepage Tools version 1.0. Hopefully that build-up wasn't overdone, but it's sometimes good to remember that the language that powers some of our most incredible dynamic web apps originally started out as a product of one guy working on his website.
A couple of years passed, and two other programmers, Zeev Suraski and Andi Gutmans began collaborating on the beginnings of what would be PHP 3, rewriting the parser from the short-lived PHP 2 and launching it in 1998. Shortly thereafter, they created the Zend Engine by rewriting core aspects of PHP, and PHP's place in the web world was cemented for good in 2000 with the release of PHP 4. In 2004, the first iteration of PHP 5 was launched, and since then major updates have been scarce on the ground, as here we are almost 10 years later working with PHP 5.5 which was just released earlier in 2013.
Excitingly enough, PHP 6 is currently under development. This next major update was originally slated for a release in March 2010, but, as is often the case in massive development projects, the release date has been continually pushed back as various setbacks change the estimates of time investment.
Posted on November 30th 2013 at 12:44am