Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Paul Jones:
Modernizing Serialized PHP Objects with class_alias()
Jul 01, 2015 @ 14:57:50

Paul Jones has posted an article to his site with another helpful hint to modernize your legacy PHP application. In the post he looks at updating serialized object handling with the help of the class_alias function.

Several weeks ago, a correspondent presented a legacy situation that I’ve never had to deal with. He was working his way through Modernizing Legacy Applications in PHP, and realized the codebase was storing serialized PHP objects in a database. He couldn’t refactor the class names without seriously breaking the application. [...] Before I was able to reply, my correspondent ended up changing the serialization strategy to use JSON, which was a rather large change. It ended up well, but it turns out there is a less intrusive solution: class_alias().

He talks about how this function could be useful to prevent the need for updating the class name in every serialized instance by setting up an alias to the new name. You can even use namespacing in the alias that will let the autoloader work with the PSR-0/PSR-4 handling to correctly load the class. With this in place, you can then refactor to the new version of the class without worry of breakage.

tagged: modernize serialized object classalias namespace psr0 psr4

Link: http://paul-m-jones.com/archives/6158

SitePoint PHP Blog:
Modernizing Legacy Applications in PHP: Review
Jan 15, 2015 @ 18:46:34

The SitePoint PHP blog has posted a review of Paul Jones' "Modernizing Legacy Applications" book. The book share's Paul's gathered knowledge about migrating legacy code into a more modern, maintainable and robust application.

Chances are you’ve come across some horrible legacy code once or twice in your lifetime as a PHP developer. Heck, if you’ve worked with WordPress to any degree, I’m sure you have. I myself have had the satisfying task of modernizing a monolithic ZF1 application, and it was the most mentally exhaustive (but, admittedly, the most educational) year of my career. If only I had had Paul M. Jones’ “Modernizing Legacy Applications In PHP” book back then, I would have been done in half the time, and the work I did would have been twice as good.

Bruno talks briefly about the contents of the book and its goals (from legacy to MVC really). He goes on to point out that the target audience for the book is not the beginner PHP developer but someone that's familiar with good software design concepts and application structure. He goes through the technical side of things, commenting that it's "sound - amazingly so" and how it seems to be taken from a real-life project's refactoring. He wraps things up with a list of some of the pros and cons of the book and a recommendation along with a 4.5 of 5 "elephpant" rating.

tagged: modernize legacy application book review pauljones

Link: http://www.sitepoint.com/modernizing-legacy-applications-php-review/


Trending Topics: