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

Leonid Mamchenkov:
Dependency resolution with graphs in PHP
Nov 22, 2016 @ 16:52:23

Leonid Mamchenkov has a post to his site showing how he solved an interesting problem in one of his recent projects: determining the order to use items based on their dependencies.

One of the projects I am working on at work presented an interesting problem. I had a list of items with dependencies on one another and I needed to figure out the order in which to use those items, based on their dependencies.

He gives the example of database tables where it would be required to export the tables so that the relations between them are maintained when imported back in. He gives some example data, a basic nested PHP array, and defines the relationships between them (just strings in this case). While he did solve the problem, he wasn't happy with the solution. Instead he went looking for other options and found graph theory to be a good match. He briefly cover what the theory involves and links to an example that basically does what he needs...but is written in Python. He finishes off the post sharing his refactoring of this logic into PHP including a recursive "dependency resolver" and the output showing the correct ordering for loading objects based on their dependencies.

tagged: resolve dependency graph theory example tutorial load order

Link: http://mamchenkov.net/wordpress/2016/11/22/dependency-resolution-with-graphs-in-php/

Damien Seguy:
Prepare for PHP 7 error messages (Series)
May 26, 2015 @ 14:35:11

For those looking forward to PHP 7, there's a new series of posts from Damien Seguy that can help you with some of the newer error messages and what might be causing them.

The first step to prepare for PHP 7 is to lint it : using the command line instruction ‘php -l script.php’, one can easily check that every file in a current application compile with PHP 7. The second step is to run the application and the unit tests : in short, execute it with PHP 7. And this is where we’ll learn about the new errors that PHP has prepared for us. In order to be one step ahead of the migration, this article will help you prepare here is a panorama on PHP error messages.

In part one he looks at some of the most often raised errors including the incorrect use of "$this" and undefined offsets. Part two gets into a few more complex messages about return type hinting, the constant scalar expression and using temporary expressions in a write context. Finally, part three looks at messaging around redefinition of identical parameters, bit shifting by a negative number, named constructor deprecation and strict typing. Each part of the series covers a few more than just the ones listed here too, so be sure to check each for more helpful error messages and solutions.

tagged: php7 error message help series part1 part2 part3 resolve information

Link: http://www.exakat.io/php-7-error-messages-part-1/

Zumba Tech Blog:
Caching CakePHP 2.x routes
Oct 28, 2014 @ 15:47:02

On the Zumba Tech Blog today there's a new post with some helpful hints around caching routes in CakePHP 2.x to help optimize the requests and response time even further.

At Zumba we are continuously looking for optimization in our applications. These optimizations help to reduce the server loads, consequently reducing the number of servers and saving money. Besides that, it gives a better user experience for the end user by serving content faster and in some cases saving on consumer bandwidth (specially for mobile users). This week we profiled our app using Xdebug profiler and we identified the router was responsible for a big part of the request time. [...] In order to optimize the routing time, we started looking at options to optimize our routing process. After some research and deep checking in our codebase as well as CakePHP’s code, we found we could cache the routes easily.

Taking a cue from how FastRoute does their caching, their implementation uses a temporary file with the routes completely resolved and written out for easier handling. Since the routing is relatively static, this method works well and can be much faster than resolving them every time. They talk about some of the work done to optimize their method and some of the issues they came across during the process.

tagged: cakephp framework cache route file resolve

Link: http://tech.zumba.com/2014/10/26/cakephp-caching-routes/

Josh Holmes' Blog:
Resolving PHP Version Conflicts while Developing for Azure
Jun 03, 2010 @ 14:15:22

Josh Holmes has a new post to his blog today with a tip on resolving version conflicts while developing PHP applications on an Azure installation.

A little while back I wrote a blog post titled Easy Setup for PHP On Azure Development. One of the things that I touched on is the PHP version conflicts. I had a much better idea which I’ve tried and have working so I thought I’d blog that here. What I had you doing in the Easy Setup for PHP On Azure Development is renaming the directory for PHP from something like C:PHP or C:Program FilesPHP to something else so that it wasn’t in the %PATH% so there wasn’t a conflict.

You don't have to do it this way, though - there's another option that involves editing the web.config file on the Azure side to tell wit there the correct PHP install lives. He also explains how you can test your WebRole code locally instead of having to upload it each time by setting up a virtual directory in your project.

tagged: version conflict azure development resolve

Link:


Trending Topics: