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

Peter Petermann:
Composer – What You Should Know
Jul 26, 2016 @ 17:56:21

Peter Petermann has shared a few of his thoughts about right and wrong things to do when using Composer in your PHP-based applications. He offers suggestions based on some of the more wide-spread (but wrong, in his opinion) practices he's seen in several projects.

Last year I wrote a piece called “a few thoughts about composer and how people use it“. In that post I had a list of things which are problematic about how composer is used. That post got widely recognized, linked an visited, but in general those issues still exist.

However lately I’ve had even more people asking questions (either on related forums, irc or even irl) about problems that stem from issue number 2: people are using composer as an installer (and sometimes Number 3 because of Number 2). In that Post I already gave a quick opinion on how workflows with composer should look like, In this post I’ll try to give a few more pointers on how to use composer without creating a mess.

He then breaks up the remainder of the post into various practices he's seen and calling out developers for doing including:

  • starting a project vs installing
  • globally installed composer packages
  • tagging and building

With each of his points he makes suggestions about what's wrong about the practice as well as some suggestions about how things could be done better.

tagged: composer opinion bad practices suggestion correct

Link: https://devedge.wordpress.com/2016/07/23/composer-what-you-should-know/

Leve.rs:
Array Manipulation in PHP, the Correct Way
Nov 08, 2013 @ 16:08:04

On the Leve.rs blog there's a recent post showing what they consider is the right way to work with arrays in PHP. It shows three things you can do to use PHP's own functionality to more correctly perform some common array operations.

More often than not, when PHP developers debug others’ code, the majority of each method is taken up by array manipulations. Spending this much time on array manipulations is a huge hassle when trying to understand any given method. In order to speed up the debugging process, it’s important to start writing array manipulations the correct way, first. Here are a few examples of code I have either written myself or had to fix in the past. It is time every PHP developer knows how to manipulate arrays properly!

Their three tips relate to:

  • Merging Arrays
  • Array Value Manipulation (with array_walk)
  • Array Value Manipulation (append with the plus sign, "+")
tagged: array manipulation correct merge value walk plus

Link: http://leve.rs/blog/correct-array-manipulation-in-php/

Gregory Szorc's Blog:
PHP Now Using Proper HTTP Status Codes on Error
Aug 23, 2007 @ 16:03:00

Gregory Szorc writes today about a fact that's only recently come true in PHP's handling of errors - it seems that it now returns proper HTTP status codes when a problem comes up.

If it encounters a serious error, like a parse error, it just stops and there is nothing you can do about it. If this happens on a hosted web site, you get a blank page served with the HTTP status code of 200. Completely useless to remote connections.

This fix will be included in the next version of PHP - the upcoming 5.2.4 release.

tagged: correct http status error response php5 correct http status error response php5

Link:

Gregory Szorc's Blog:
PHP Now Using Proper HTTP Status Codes on Error
Aug 23, 2007 @ 16:03:00

Gregory Szorc writes today about a fact that's only recently come true in PHP's handling of errors - it seems that it now returns proper HTTP status codes when a problem comes up.

If it encounters a serious error, like a parse error, it just stops and there is nothing you can do about it. If this happens on a hosted web site, you get a blank page served with the HTTP status code of 200. Completely useless to remote connections.

This fix will be included in the next version of PHP - the upcoming 5.2.4 release.

tagged: correct http status error response php5 correct http status error response php5

Link:


Trending Topics: