2017 © Pedro Peláez
 

library phphd

Search unused code

image

olegkolt/phphd

Search unused code

  • Wednesday, August 27, 2014
  • by olegkolt
  • Repository
  • 1 Watchers
  • 0 Stars
  • 10 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

PHPHD - PHP Hunt for Decedent

Found unused code in your project, (*1)

PHPHD is a library that provides collection and rendering functionality for PHP code coverage information. PHPHD uses xdebug for collecting information. PHPHD is similar to the PHP_CodeCoverage, but PHPHD much faster and can be used in web sites., (*2)

Requirements

  • PHP 5.3.3 is required but using the latest version of PHP is highly recommended
  • Xdebug 2.1.3 is required but using the latest version of Xdebug is highly recommended

Installation

To add PHPHD as a local, per-project dependency to your project, simply add a dependency on olegkolt/phphd to your project's composer.json file. Here is a minimal example of a composer.json file that just defines a dependency on PHPHD:, (*3)

{
    "require": {
        "olegkolt/phphd": "dev-master"
    }
}

Using the PHPHD API

Collect coverage data

<?php

use PHPHD\DataSource\Serialize;
use PHPHD\Collect

$dataSrc = new Serialize('/tmp/phphd/data.dump'); // data.dump - file for saving code coverage data
$collector = new Collect($dataSrc, __DIR__ . '/lib'); // Second argument is code directory path
$collector->startCollection();

// your job

$collector->save();

Or just add this code to the entry point of your application:, (*4)

<?php

use PHPHD\DataSource\Serialize;
use PHPHD\Collect

Collect::register(
    Serialize('/tmp/phphd/data.dump'), // Dump file path
    __DIR__ . '/lib' // Code directory path
);

Collect::register from the second sample uses register_shutdown_function for saving code coverage data., (*5)

Report code coverage data

<?php

use PHPHD\View\Html;
use PHPHD\DataSource\Serialize;

$dataSrc = new Serialize('/tmp/phphd/data.dump');
$html = new Html($dataSrc);
$html->output();

The Versions

27/08 2014

dev-master

9999999-dev

Search unused code

  Sources   Download

MIT

The Requires

  • php >=5.3
  • ext-xdebug >=2.1.4

 

The Development Requires

by Oleg Koltunov