Test Your PHP Application on PHP 7

PHP 7 is coming, which is nice, but what does it mean for the majority of PHP developers? PHP as a community is notoriously slow in adoption, some of us are still waiting for 2012’s new shiny to be available as standard on our hosting platforms. However with the performance benefits and a few really nice new features, PHP 7 is well worth everyone’s attention, and it’s actually quite easy to get started so here’s my quick howto. Continue reading

New Screencast Series: Git Fundamentals

git-fundamentals-screencastIf you’re a web developer looking to improve your git skills, then I have just the thing for you. I love it when a project is finished and “out there” and I’m pleased to announce that my new screencast course Git Fundamentals For Web Developers is now available. It’s mostly PHP but you’ll find Python and Node examples in there as well just to show off some of the tricks that work best for different disciplines. The course is structured around specific tasks or problems that we face in creating and deploying web applications, and my best advice on how to solve them. Mostly, I just want you to be able to be awesome at what you do already without your source control tool getting in the way :)

Edit: If you’re reading this before July 25th 2015, use code CFSCON5 to get a massive 50% off!
Continue reading

PHP 7 Benchmarks

If you know anything at all about PHP7, you probably know it’s fast. But did you know how fast? The alpha is out and looks very robust, so I decided I would create a new set of benchmarks to include it. Graphs first, disclaimers later :)

This graph shows the time it takes for each version of PHP to perform the same task, on average, with oldest PHP on the left and moving forward in time.

php-70-alpha-benchmarks

Continue reading

PHP 5.4 and Short Tags

PHP 5.4 isn’t exactly new; in fact the opposite is true! PHP 5.4 is end of life, but as our adoption rates show, as a community, PHP people aren’t especially good at upgrading! I’m getting lots of questions now because some of the hosting providers, notably including Acquia’s hosting, are finally upgrading away from those 5.2 and 5.3 offerings.

One thing in particular is tripping people up: the short open tag. I’ve had a few questions on this so here’s the advice I am giving to clients and friends.

What Actually Changed

The short_open_tag configuration directive was removed, but the short echo syntax <?= is always available.

How To Upgrade Your Codebase

  • If you have <?= in your templates, leave it alone, those will still work
  • If you have short tags <? in your code, including in any of your libraries, then you need to do a global find-and-replace and turn them all into <?php

If you have short tags somewhere in your codebase, you probably won’t get errors, you’ll just suddenly start seeing PHP code in your output as PHP doesn’t recognise the tag and therefore doesn’t evaluate the code! To find them, try searching for <? followed by a whitespace character.

Hopefully that helps; there are a few gotchas to getting upgraded from older versions (especially from PHP 5.2) but this particular gotcha really isn’t a problem and the instructions here should see you through.

Recover Bitly Bundle Data

For some years I’ve been creating a bundle of links covering articles I recommend for various topics in the Zend Certified Engineer Exam (if you can here looking for the bundle itself, it’s at http://lornajane.net/zce-links-collection). This was done using bitly’s bundles feature, which I thought was a great way to share links. In fact I had 10-15 bundles that I had created from collating all the links in a particular training course or talk, so that people didn’t have to try to write down URLs as I went along. Unfortunately they sunset their bundles and then removed them completely, and I missed the announcement (it all happened quite quickly, they’d seen some abuse of the feature, it’s free, all totally reasonable) BUT they also didn’t respond to my support questions about how to recover the data.

It turns out, it’s an undocumented feature on their API, so here is everything I know about recovering your bundle data, including the script I used to rescue my own data. Continue reading

PHP7: Easiest Upgrade Yet

With PHP7 looking increasingly stable (relatively speaking, it’s still pre-alpha so it’s VERY early days and anything could happen!), and work going well on the GoPHP7-ext project to get extensions converted, I have been thinking about the migration guides we’ll need to help people upgrade their existing applications. To this end, I took the simplest project I currently have (http://api.joind.in) and gave it a whirl on PHP7, using Rasmus’ PHP7 dev box. The result:


Continue reading

PHP Quick Stack Trace in Exception Handler

PHP and frameworks built from it have many great tools to assist with debugging (I particularly like XDebug) but sometimes you can find yourself in a situation where the “helper” features aren’t all that much help … in my case this was a framework totally determined to output HTML from my commandline script and to only show me 5 lines of stack trace, which wasn’t enough for my complex application. I had to look up how to generate a nice stack trace inside an exception handler so here it is in case I want it again some time (future me, you’re welcome!) Continue reading

ZCE Preparation Pack

tl;dr version: the ZCE Preparation Pack is now available from Leanpub https://leanpub.com/zce costing $30.

I’ve been running a preparation course for the Zend Certified Engineer exam for many years now.  Once upon a time it was possible to buy a pack of sample exams and I used them myself when preparing for certification and also recommended them for all my students.  Unfortunately this resource became unavailable and so I created a sample exam to use with my own course …. and then (after some nagging!) made it generally available.

I’ve now relaunched the pack on a new platform (for boring regulatory reasons); its new home is on Leanpub which is a fantastic platform for authors, offering markdown authoring, github integration, and many other awesome features.  Perhaps more importantly, it also offers great features for readers: a 45-day money back guarantee and automatic updates to any book you have bought.

If you’re thinking of improving your skills by studying for ZCE or considering upgrading your certification to the current version (PHP 5.5), this pack will help you to prepare.  It includes:
– Advice on what to expect on the day
– One exam’s worth (70) of questions in the style of the ZCE
– Answers with explanations, worked examples, and resources for further study

Help yourself get ready for ZCE: https://leanpub.com/zce

XHGui on VM, Storage on Host

I’m doing some performance tuning on a project at the moment and my favourite tool is still XHGui – but it’s designed to run on the same machine as its victim and since this is a vagrant VM, the chances of me destroying the machine and therefore the data are pretty high! Instead, I set it up to store the data onto the host and I thought I’d share how I did that. Continue reading

ZCE Questions Pack Unavailable

There is a change in legislation for selling digital goods to anyone in the EU, and to cut a long story short this means that my ZCE Questions Pack will be unavailable at least in the short term. The pack is intended for anyone preparing for ZCE, it has general advice, sample questions and detailed answers and resources covering all the topics you will encounter at ZCE.

However from January the VAT rules change and I’m not in a position to comply with the new rules (they would cost a lot more than the sales make). I’m looking for alternative sales channels that would enable me to keep making the pack available but those won’t be in place immediately. If you are studying for ZCE over the Christmas break, please make sure you have the pack well in advance!

Edit: Pack temporarily unavailable now

I have other (free!) resources for you also on my ZCE page. If you have an earlier version of this pack, email me your receipt and I’ll send you a new copy – but again, you have about a week to do it!