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

Christian Scheb:
Introducing Tombstones for PHP
Sep 17, 2015 @ 12:49:23

Christian Scheb has posted about an interesting idea in this article on his site - creating "tombstones" in your application to help you determine what code in your application is "dead".

Earlier this year I took over that project at my new company. [...] The repository was cluttered by many files, that could assumed to be dead code. Unfortunately, you never know. [...] The mission was clear: Cleaning up the project, without breaking things.

[...] I searched the web and came across that interesting concept of tombstones. If you haven’t heard of tombstones yet, I highly recommend this article and watching the video of David Schnepper’s ignite talk. A tombstone is basically an executable marker in your code (in the PHP world: a function call), which is placed in fragments of code, that you’ve assumed to be dead. Then, everything is deployed to production and, when a tombstone is invoked, it writes some data to a log. After a while, the logs will enable you to identify dead and undead code (called “Vampires”) in your project.

Not finding a good tool to help with this in an existing codebase, he created a library that makes it simpler to both mark the "tombstones" in your code and another to analyze the results. He includes an example of what the report might look like, showing both the used and unused bits of code where the tombstone code was placed.

tagged: tombstones dead code library analyzer marker

Link: http://www.christianscheb.de/archives/717

Allan MacGregor:
TDD is not Dead
Sep 08, 2015 @ 10:30:01

Allan MacGregor has a post to his site with some of his thoughts on why TDD isn't dead and is still a viable option to help reduce bugs and improve software quality.

So, where does this whole TDD is DEAD thing came from? Well, it all started with let's say a provocative talk and follow up blog post by David Heinemeier Hansson (@DHH) where he expressed his frustration with testing and put into question the value of TDD. [...] TDD is not dead, not really. And it won't really ever be dead, it will change or be replaced with something better; in fact it already has, and in my Magento Extension Test Driven Development book we focus on Behavior Driven Development, an approach that emerged from the original TDD methodology.

He goes through each of the points that DHH mentions in his post and offers some of his own thoughts on the topic:

  • Developers make you feel like your is dirty if you don't practice TDD
  • Driving design from unit tests is not a good idea
  • TDD notion of "fast tests" is shortsighted
  • 100% coverage is silly.
  • TDD created test-induced design damage.

He ends with the most common misconception about testing in general too: i"t's too much work/it will make my development slower." He also looks at some of these kinds of comments specifically targeted at Magento 2.

tagged: tdd testdriven development dead opinion dhh

Link: http://coderoncode.com/testing/magento/2015/09/03/tdd-is-not-dead.html

Derick Rethans:
Dead Code
Jun 18, 2014 @ 10:49:56

In his latest post Derick Rethans talks about something that plagues every project, PHP or otherwise, after its grown to a large enough size: dead code. He's been asked why his Xdebug tool finds this code in places where people don't expect, so he figured he'd answer it once and for all.

The explanation for this is rather simple. Xdebug checks code coverage by adding hooks into certain opcodes. Opcodes are the building blocks of oparrays. PHP converts each element in your script - main body, method, function - to oparrays when it parses them. The PHP engine then executes those oparrays by running some code for each opcode. Opcodes are generated, but they are not optimised. Which means that it does not remove opcodes that can not be executed.

He gets down to the opcode level and shows some output from vld on how things are being executed (and what's not). Using a simple "foo" function example, he shows the execution flow and how the "branches" of executions work through the code. In his case, the "dead code" marker is coming from the line with a closing brace from an "if" statement. He points out that it entirely depends on the lines executed as to what is marked as "dead code".

tagged: dead code xdebug path flow branch vld

Link: http://derickrethans.nl/dead-code.html

Design Aeon:
Check Dead Links From Database Using PHP CURL
Jun 18, 2012 @ 09:45:55

On DesignAeon.com there's a recent tutorial posted showing you how to extract URLs from your database and determine which ones are "dead" automatically with the help of cURL.

Checking Deadlinks From the database manually is a Headache ,So why not use a script which return the http status of the particular link and tell us if the link is dead or not.So how do we check the dead links from the database ? How do we programatically check whether the link is dead or not ? To check broken or dead links from Database we will use curl .

Included in the post is a sample script that extracts the URLs from a field in the database (you'd need some extra smarts if you're pulling it from content) and running it though a "checklink" function. If the call to curl_getinfo returns false, the link is marked dead.

tagged: dead link url curl check automatic tutorial database

Link:

Derick Rethans' Blog:
More source analysis with VLD
Feb 23, 2010 @ 10:49:26

Derick Rethans has been working on some updates to a tool he's developed, VLD, to make it more helpful and effecting in optimizing the opcodes in your scripts and find the dead opcodes and paths. He talks about these updates in this recent post.

Recently I've been working on some new functionality to visualise all the code paths that make up each function. These new routines sit on top of the routines that do dead code analysis. These new routines sit on top of the routines that do dead code analysis. Every branch instruction (such as if, but also for and foreach) is analysed and a list of branches is created. [...] Once all the branches and their links are found, another algorithm runs to figure out which paths can be created out of all the branches.

He illustrates with a few examples, showing both the command that was executed and the resulting output with the new path information of a simple test file using a "for" loop and an "if/else" conditional.

tagged: vld opcode visualize dead path

Link:

Hasin Hayder's Blog:
International PHP-Magazine - Is it dead?
Jan 28, 2008 @ 08:59:00

Hasin Hayder asks a question in his latest blog post that some in the PHP community have been wondering for a while now - is the International PHP Magazine dead?

I am a subscriber of International PHP Magazine for years. I bought the subscription looking at the back issues. They were sexy, resourceful and yup, very good. But I think these guys don't care about the magazine anymore. It became just a funny stuff for them. All the readers/subscribers and viewers doesn’t bring any value to them. Look what they are doing actually...

He points out six things that the magazine and its staff are doing including RoR articles in an issue, content on the site that's way out of date and the smaller size of recent issues. Comments to the post point out that there has been issues released but that the magazine is published by a non-technical company that just might be pushing this particular publication aside.

tagged: international magzine dead issue content old

Link:

Tectonic.co.za:
PHP is dead. Long live PHP!
Jul 21, 2006 @ 05:53:53

In this post from Jason Norwood-Young, he shares his opinions on the lifespan of PHP - that maybe, just maybe, PHP has passed its prime.

A friend recently told me that PHP is on its way out, Ruby on Rails is where it's at. I scoffed. I chuckled. Then I gave it some thought. Could PHP have had its day?

[After my research] I have to conclude that my friend might be right in one respect – PHP has had its day. If the trend continues, it means that PHP will one day not be the hottest thing on the web like it is right now.

He's not abandoning ship just yet, though - he notes that:

PHP still has plenty of legs, and it will take quite a bit to wind it. I'm not sure what will take its place, but somehow I don't think Ruby on Rails will be the successor. PHP's advantage over the rest is that it's a web application, through and through. It doesn't try to also be a desktop application language, a server application language, a widget application language... it just spits out web pages fast and efficiently.

tagged: dead lifespan rubyonrails usage trend dead lifespan rubyonrails usage trend

Link:

Tectonic.co.za:
PHP is dead. Long live PHP!
Jul 21, 2006 @ 05:53:53

In this post from Jason Norwood-Young, he shares his opinions on the lifespan of PHP - that maybe, just maybe, PHP has passed its prime.

A friend recently told me that PHP is on its way out, Ruby on Rails is where it's at. I scoffed. I chuckled. Then I gave it some thought. Could PHP have had its day?

[After my research] I have to conclude that my friend might be right in one respect – PHP has had its day. If the trend continues, it means that PHP will one day not be the hottest thing on the web like it is right now.

He's not abandoning ship just yet, though - he notes that:

PHP still has plenty of legs, and it will take quite a bit to wind it. I'm not sure what will take its place, but somehow I don't think Ruby on Rails will be the successor. PHP's advantage over the rest is that it's a web application, through and through. It doesn't try to also be a desktop application language, a server application language, a widget application language... it just spits out web pages fast and efficiently.

tagged: dead lifespan rubyonrails usage trend dead lifespan rubyonrails usage trend

Link: