Been meaning to say this for a while now but George Schlossnagle’s book – Advanced PHP Programming is excellent. This isn’t meant as an extensive review but rather some thoughts, in reverse order to the books contents page…
– The coverage of Zend internals and extending PHP is the best I’ve seen (PHP has been badly in need of this) and was my reason for buying it. Not only is the “how” of extending PHP explained; there’s also detailed discussion of the Zend engine, the PHP execution lifecycle and so on, I believe based on George’s experiences with apd. Even if you’re not planning on writing your own PHP extension, there’s some valuable insight which can help influence the design of your PHP apps, particularly where performance is concerned. Knowledge of C is assumed (otherwise it would be a very big book), so be warned, but think George has succeeded in proving this misappropriation of the Tao Te Ching wrong (someone please kill it). While I’m on the subject of PHP extensions, there is another book, Building Custom PHP Extensions serves as a useful reference (probably not updated for PHP5 yet though) but lacks insight and explanations.
– Discussion of performance issues and scalability play a very big part, George having unique insight from sites he’s worked on. To an extent, I almost want to dispute the title – “High Performance PHP” might almost be better. As well as much open ended discussion of issues like caching, a significant part of this discussion looks at supporting technologies that help a site handle high traffic; finding them examined in a single book as part of a “big picture” is something else that makes the book special – even if you don’t work with PHP, it’s worth a read if you’re in position of having to run / develop web apps exposed to serious traffic. The bottom line is, again, it’s the only material of it’s kind right now for PHP. To get a taste of what to expect, it’s worth reading George’s recent article over on the Oracle Technology Network: Scaling Oracle and PHP.
– The first section of the book examines what I’d call “development practices” and where most talk of PHP itself happens – subjects like coding standard, OOP, CVS, unit testing and so on. George “dares” to use Smarty and PHPUnit, which probably won’t please everyone but the concepts are transferable.
The style of the book is discussion and “enablement” rather than step by step solutions. The chapter on caching, for example, never reaches “the answer” (is there one?) but provides looks and many different approaches and where / when they make a good choice.
It’s probably not a good place to begin coding PHP with unless you’ve already had experience of other programming languages. You may also find yourself all dressed up with nowhere to go, once you’ve read it (i.e. hunting for an employer with a high traffic site) but even if you’re not able to put everything it offers into practice, there’s a ton of ammo to fire back at that Java developer who makes snide remarks about PHP.
Overall, Advanced PHP Programming is on a par with the Redbooks and is a much needed addition to PHP’s bookshelf. As John puts it; “George, you the man!”.
Frequently Asked Questions about Advanced PHP Programming
What are the key differences between basic and advanced PHP programming?
Basic PHP programming involves understanding the syntax, variables, data types, operators, control structures, and basic functions. It’s the foundation that allows you to write simple scripts and applications. On the other hand, advanced PHP programming delves into more complex areas such as object-oriented programming, exception handling, design patterns, and security. It also involves understanding and using PHP frameworks, working with databases, and integrating with APIs.
How can I improve my skills in advanced PHP programming?
Improving your skills in advanced PHP programming requires consistent practice and learning. You can start by understanding the basics of PHP, then gradually move to more complex topics. Reading books like “Advanced PHP Programming” by George Schlossnagle can provide in-depth knowledge. Participating in coding challenges, contributing to open-source projects, and building your own projects can also help you improve your skills.
What are some common mistakes to avoid in advanced PHP programming?
Some common mistakes to avoid include not using prepared statements for database queries, which can lead to SQL injection attacks. Another mistake is not properly validating or sanitizing user input, which can lead to security vulnerabilities. Also, avoid using outdated PHP functions or features, as they may not be supported in newer versions of PHP.
What are some best practices in advanced PHP programming?
Some best practices include using object-oriented programming principles, following the PSR standards set by the PHP-FIG, and using a PHP framework for larger projects. It’s also important to write clean, readable code and to comment your code for better understanding.
How important is it to understand design patterns in advanced PHP programming?
Understanding design patterns is crucial in advanced PHP programming. Design patterns provide solutions to common programming problems and can help improve the efficiency and structure of your code. They also make your code more readable and maintainable.
What are some recommended PHP frameworks for advanced programming?
Some recommended PHP frameworks include Laravel, Symfony, CodeIgniter, and Zend. These frameworks provide a structured way to build web applications and come with many built-in features that can speed up development.
How can I ensure the security of my PHP applications?
Ensuring the security of your PHP applications involves practices like validating and sanitizing user input, using prepared statements for database queries, and protecting against CSRF and XSS attacks. It’s also important to keep your PHP version up to date, as newer versions often come with security improvements.
What is the role of APIs in advanced PHP programming?
APIs play a crucial role in advanced PHP programming. They allow your application to interact with other applications or services. For example, you can use APIs to integrate with payment gateways, social media platforms, or other third-party services.
How can I optimize the performance of my PHP applications?
Optimizing the performance of your PHP applications can involve techniques like caching, using a PHP accelerator, optimizing your database queries, and reducing the use of expensive operations like file I/O.
What resources are available for learning advanced PHP programming?
There are many resources available for learning advanced PHP programming. These include books like “Advanced PHP Programming” by George Schlossnagle, online tutorials and courses, coding bootcamps, and PHP documentation. Participating in coding challenges and contributing to open-source projects can also provide valuable learning experiences.
Harry Fuecks is the Engineering Project Lead at Tamedia and formerly the Head of Engineering at Squirro. He is a data-driven facilitator, leader, coach and specializes in line management, hiring software engineers, analytics, mobile, and marketing. Harry also enjoys writing and you can read his articles on SitePoint and Medium.