Video Course on Learnable: OOP PHP

I’m delighted to announce that my new video course on Object-Oriented PHP is now available on Learnable! It’s very much an introduction, aiming to cover WHY objects are so cool as well as how to declare and use one. The course is a mix of video (filmed in my kitchen, welcome to my home everyone!), screencast, a couple of exercises for you to try, and also plenty of sample code to download. If you are just looking to get started with OOP, or know someone who is, then hopefully this will help you out.

On a related note, I’m also doing a Sitepoint “Talk with the Experts” session on 11th April (early morning UK time, as a special treat for everyone in Europe and further east, that doesn’t happen often!). There are more details here: http://www.sitepoint.com/forums/showthread.php?1012242-Talk-Object-oriented-PHP-with-the-Experts and I hope you can join me then.

9 Magic Methods in PHP

This post forms part of a series of articles about using PHP to do objected oriented programming, or OOP. They were originally published elsewhere but are no longer available at that location, so I’m reposting them here. Previously in the series was an introduction to OOP in PHP, in two parts

The title is a bit of a red herring as PHP has more than 9 magic methods, but these will get you off to a good start using PHP’s magic methods. It might be magic, but no wands are required!

Continue reading

A Little More OOP in PHP

This post forms part of a series of articles about using PHP to do objected oriented programming, or OOP. They were originally published elsewhere but are no longer available at that location, so I’m reposting them here.

This post follows an earlier entry introducing the basics OOP and what that looks like in PHP. This time around we’ll look at some more advanced concepts and some more practical examples of building code, covering use of constructors and how to add access modifiers in to control how calling code can operate on your objects. We’ll also show off how to create static methods and properties and, perhaps more importantly, illustrate applications of these features.

Continue reading

Introduction to PHP OOP

This is the first in a series of articles about using PHP to do objected oriented programming, or OOP. They were originally published elsewhere but are no longer available at that location, so I’m reposting them here.

Since the introduction of PHP 5 in 2004, PHP has had an object model worthy of that description and became a truly modern language for use on the web. Earlier PHP scripts would have been of the kind where, to quote from Alice’s Adventures, you would “Begin at the beginning, and go on till you come to the end: then stop.” Nowadays that very procedural approach is less common in PHP, so this article takes a look at some of the basic object oriented features available in the language and shows some examples of using them with code examples.

Continue reading

Upcoming PHP Courses

Since becoming freelance 18 months ago, I’ve taught a number of courses at my excellent local tech training centre, NTI Leeds. Over the next few months we’re running some one-day PHP courses (see my course dates page for more detail and the dates, all these are in Leeds although I’d like to run them elsewhere too), targeted at a particular area or set of skills. These are areas that I find myself delivering consultancy or training on frequently, or things I teach when I go places and realise these gaps exist in their knowledge. Does this match your experiences of “things I wish PHP developers knew – including me”? Continue reading

Using Gearman from PHP

I’ve introduced Gearman into a project I’m working on, and since a few people have asked I thought I’d share my experiences. Basically, this application generates some PDFs from a variety of data sources, makes images, and emails it. Since the whole data processing, image handling, PDF generation process is fairly heavy, I’m putting the requests to generate these onto a gearman queue and having some workers process the jobs. The eventual aim is to bring up EC2 instances (or php-specific cloud hosting perhaps? Recommendations gratefully received!) to do this work but right now I have one worker and it’s all on one server.

Continue reading

Declaring Static Methods in PHP

I was confused recently to realise that I had accidentally called a static method in PHP dynamically from another part of my code; I expected PHP to output warnings when this is done. On closer inspection I discovered that:

  • Static functions can be called dynamically
  • Dynamic functions generate an E_STRICT error if called statically

This made a lot more sense when I thought about it a bit more and wrote some toy code:

Continue reading