PHPackages                             sebastian/de-legacy-fy - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. sebastian/de-legacy-fy

AbandonedArchivedLibrary[Testing &amp; Quality](/categories/testing)

sebastian/de-legacy-fy
======================

Tool for dealing with legacy PHP code

2.0.0(8y ago)771.1k4[3 issues](https://github.com/sebastianbergmann/de-legacy-fy/issues)BSD-3-ClausePHPPHP ^5.6 || ^7.0

Since Jun 27Pushed 8y ago4 watchersCompare

[ Source](https://github.com/sebastianbergmann/de-legacy-fy)[ Packagist](https://packagist.org/packages/sebastian/de-legacy-fy)[ Docs](https://github.com/sebastianbergmann/de-legacy-fy)[ RSS](/packages/sebastian-de-legacy-fy/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (5)Versions (4)Used By (0)

de-legacy-fy
============

[](#de-legacy-fy)

[Legacy code is code without tests.](http://c2.com/cgi/wiki?WorkingEffectivelyWithLegacyCode)Over the years I have helped many a team introduce (unit) testing into a legacy code base, making it "less legacy" step by step.

The `de-legacy-fy` command-line tool is an attempt to put concepts and ideas that proved to be effective at dealing with legacy PHP applications into code and make them as reusable as possible.

Installation
------------

[](#installation)

### PHP Archive (PHAR)

[](#php-archive-phar)

The easiest way to obtain de-legacy-fy is to download a [PHP Archive (PHAR)](https://secure.php.net/phar) that has all required dependencies of de-legacy-fy bundled in a single file:

```
$ wget https://phar.phpunit.de/de-legacy-fy.phar
$ chmod +x de-legacy-fy.phar
$ mv de-legacy-fy.phar /usr/local/bin/de-legacy-fy

```

You can also immediately use the PHAR after you have downloaded it, of course:

```
$ wget https://phar.phpunit.de/de-legacy-fy.phar
$ php de-legacy-fy.phar

```

### Composer

[](#composer)

You can add this tool as a local, per-project, development-time dependency to your project using [Composer](https://getcomposer.org/):

```
$ composer require --dev sebastian/de-legacy-fy

```

You can then invoke it using the `vendor/bin/de-legacy-fy` executable.

Usage Examples
--------------

[](#usage-examples)

### Generating characterization tests using execution trace data

[](#generating-characterization-tests-using-execution-trace-data)

[Characterization Tests are an attempt to lock existing behavior into an untested or undocumented system.](http://c2.com/cgi/wiki?CharacterizationTest) They are described briefly in Michael Feathers' book ["Working Effectively With Legacy Code"](http://c2.com/cgi/wiki?WorkingEffectivelyWithLegacyCode), among other places.

We can automatically generate a [data provider](http://phpunit.de/manual/current/en/writing-tests-for-phpunit.html#writing-tests-for-phpunit.data-providers) for a PHPUnit-based characterization test using [execution trace](http://xdebug.org/docs/execution_trace) data that we can collect with [Xdebug](http://xdebug.org/).

Consider the following rather contrived and simple example:

```
