Foundations for our Future
posted 2012-11-28 by Phil Sturgeon
The team here have been meaning to get more active with blogging about what is happening behind the scenes and there is no time like the present.
I am constantly amazed by the number of people using, blogging about, launching with, and contributing to PyroCMS. Compared to a year ago we're a much bigger community and this can be seen through so many metrics. We're the Most Watched PHP CMS on GitHub, we have hundreds of contributors and PyroCMS just got translated into Chinese Simplified - it's 22nd language!
While the v2.1 branch is doing this well I am not content with it. We are tantalizingly close to getting v2.2.0 out the door and you guys will be very happy with the changes included there. Totally modular Search is a certainly going to be a big thing, along with the amazingly powerful Page Types which are going to blow people away with how powerful and easy they are. With v2.2.0 getting close to launch I do of course have to start planning the future beyond that.
v2.3.0 will be PHP 5.3
But thinking even further ahead than v2.2.0 is v2.3.0, which will be an even bigger improvement for PyroCMS. PHP 5.2.4 has been our minimum requirement for a long time, but the usage numbers for that version of PHP 5.2.x have dropped so significantly in the last few months (down from 30% to less than 15%) that we feel it's appropriate for us to start building out new versions with PHP 5.3.6 as a minimum requirement.
Wether that interests or concerns you, the team feels like it is absolutely for the best of PyroCMS users. I completely understand that there are many of you who are unable to upgrade because your web host for some reason still only has PHP 5.2 available, or for whatever other reason, but you are not forgotten about.
Versions of PyroCMS are supported for 2 minor versions (e.g: 2.0 is currently supported), so you essentially have about a year to get from 2.2 to 2.3 before you need to be concerned. Security updates and hotfixes will be applied to the 2.2.x branch for that time, and if by next year PHP 5.3 is not an option for your web hosts then you seriously need to consider moving.
If anyone is looking for a hosting solution with PHP 5.3 as an option then please try out our hosting platform for free, or take a look at our hosting partners on the same page.
Composer and Laravel
The main thing here is Composer. Composer allows us to easily include code and packages from a number of sources, including other frameworks instead of being limited to CodeIgniter-only code. CodeIgniter has been incredibly good to us for years now, and we've been happy to contribute code and features back to the community, but there are some things it just cannot do well.
For example the PDO support in CodeIgniter is broken. You can select, insert, update, delete but the DBForge is just functionally and fundamentally broken for anything other than MySQL. We want to bring SQLite and Postgres support to you properly in 2.3 and that cannot happen using CodeIgniter's Database Driver.
While looking for alternatives to using CodeIgniter's broken database drivers we came across the Laravel 4 Database package, which can run entirely standalone in any framework. Thanks to Composer we can easily install this code in with our own. It's namespaced, doesn't conflict and works extremely well - it's even unit tested! We can just drop this in as an option to developers who want to use a powerful new database layer and even have access to Eloquent, which is an incredibly lightweight system, while keeping the CodeIgniter Database layer intact for a few versions to allow people enough time to move away from using it.
This is not the only package we'll be utilizing. Laravel provides much more powerful Validation, Jerel has built a PSR-2 Caching system based off quick-cache, Guzzle is a considerably more advanced component to replace my aging Curl and Rest Sparks, and much much more - all of which leverages PHP 5.3 and its wonderful namespaces, callbacks, static facades and other kickass design patterns.
This sounds scary, but please, do not be afraid. This is a huge undertaking and we are not taking this lightly.
As I said above CodeIgniter has served us extremely well over the last few years and many of you use PyroCMS because it is based on CodeIgniter. That said there are fundamental limits in the design of CodeIgniter which block it from ever truly taking advantage of PHP 5.3 or any of its features. CodeIgniter puts an extremely heavy focus on backwards compatibility with its API, which over the last 5 years has essentially never changed. I know, I was on the development team for almost 2 years and a focus was always on "not breaking the API". From PHP 4 to PHP 5.2 this has worked out well enough and while certain features were not able to be implemented properly it did mean that application developers could be confident different versions would not be drastically different.
Well, that worked up until PHP 5.2 but for CodeIgniter to ever leverage any part of PHP beyond that it would require a drastic rewrite. Nobody is interested in doing that rewrite, not us, not the company who owns CodeIgniter and definitely not the community - so it's just not going to happen. If it did happen somehow then we'd be faced with having to rewrite PyroCMS anyway - so this change makes the most sense for us. We can move to a codebase of our choice at a time of our choosing, and roll the changes out over a few versions to keep add-on developers happy. We've been talking to the developers of PyroCart, FireSALE and other popular addons and they cannot get enough of the Laravel 4 components that we have been demonstrating to them. These add-on developers are excited to get going and even diving into GitHub to help speed the process up, and I believe this definitely shows we're on the right track.
Laravel 3 is an incredibly popular framework already and its roots come from CodeIgniter. If you've ever used CodeIgniter, Kohana, FuelPHP or PyroCMS you will know exactly how this works and feel right at home. The documentation is as (or more) extensive as CodeIgniter's and you will fall in love with the amazingly simple syntax in no time. The whole focus of Laravel is making clean, modern, even sexy code, with heavy testing and a stable base. It's important to mention that we're not moving to Laravel 3 (the current full-stack framework) but actually moving to Laravel 4, which is entirely built with PSR-2 components. We're good friends with the Laravel team and so this has been going very smoothly, even though these components are not yet released. They will however be entirely ready and entirely documented before 2.3 launches, don't worry about that.
All of this said, the move to Laravel is going to take time and is going to be done in steps. As I mentioned above 2.3 will include the new Database layer, the Eloquent ORM - which is an insanely lightweight ORM, and potentially some of their validation and other components. For the lifetime of PyroCMS 2.3.0 these components will be available if you want to use them, or you can keep on using CodeIgniter exactly the same as you are now. This gives Add-on developers a great amount of time to start utilizing these components before PyroCMS 3.0 happens. This is the softest and easiest approach we can take, and it should work out really well.
To put this into context, Drupal 7 to Drupal 8 was a total rewrite onto a new framework and nothing works between those two versions. Everyone had to go back to square 1 and start everything from scratch. This sort of stuff happens, but we're spreading this out over multiple versions to make the transition that much easier.
Testing is now a focus
In the past there have been bugs which should have been found with testing. I'd hate to blame this entirely on CodeIgniter, but it certainly hasn't made it easy.
Most Composer packages are unit-tested, and we will only be using components that have good code coverage. This means most of our codebase will already be tested thanks to the tests that each component already implements.
Then we can create some behavioral tests that simulate installation, common user interaction, etc. This again is much easier with a PHP 5.3 codebase than in PHP 5.2.
Onwards and Upwards
PyroCMS is slowly transitioning itself to the new world of PHP - which it would have to do at some point. We can do it now and stay at the front of the pack, or be forced to in a few years after we’ve stagnated. If we were to lock things down completely and not upgrade our codebase then you'd grow bored or frustrated and move to a totally new CMS, and that is going to be a LOT more difficult than the upgrade process we have planned.
We'll be blogging, tweeting, supplying documentation, recording screencasts and doing everything we can to help you guys out during this time. Our support is free and you're welcome to contact us directly if you have any more questions.