Setup

Configuring your project and get ready for your first analyse.

1. Install

CompatInfo may be installed in several ways, choose your favorite.

CompatInfo takes advantage of new features in PHP 5.3 or greater.

Minimal Requirements

Before you install PHP CompatInfo, you will need an operating system with PHP 5.3.0 or later installed, and four loaded extensions: Reflection, tokenizer, pcre, SPL.

Using PEAR

As PHP-Parser 1.0 is not planned to be distributed as a PEAR package (read discussion), CompatInfo 3.0 will not be available on the PEAR Bartlett Channel.

Using Composer

Put a file named composer.json at the root of your project, with at least, content below:

{
    "require": {
        "bartlett/php-compatinfo": ">=3.0"
    }
}

And run the following command:

$ php composer.phar install

Using PHP Archive (phar)

wget http://bartlett.laurent-laville.org/get/phpcompatinfo.phar
chmod +x phpcompatinfo.phar

2. Autoloaders

CompatInfo does not provides any native autoloader.

It’s up to you to choose what is be the best strategy :

  • If you have installed CompatInfo with Composer, it must have generated a vendor/autoload.php file you should used.

  • If you use the phar version, you don’t need autoloader, all dependencies are embeded.

  • The basic PHP version requires an autoloader that can load classes that follow the PSR-0 class naming standard.

I recommend using Symfony ClassLoader component.

Here are a minimum example, if you used a forked copy of GitHub source.

Symfony UniversalClassLoader
<?php
require_once 'Symfony/Component/ClassLoader/UniversalClassLoader.php';

use Symfony\Component\ClassLoader\UniversalClassLoader;

$loader = new UniversalClassLoader();
$loader->registerNamespaces(array(
    'Symfony\\Component\\Finder'          => $vendorDir . '/symfony/finder',
    'Symfony\\Component\\EventDispatcher' => $vendorDir . '/symfony/event-dispatcher',
    'Symfony\\Component\\Console'         => $vendorDir . '/symfony/console',
    'Symfony\\Component\\ClassLoader'     => $vendorDir . '/symfony/class-loader',
    'Bartlett\\Reflect'                   => $vendorDir . '/bartlett/php-reflect/src',
    'Bartlett\\Tests\\CompatInfo'         => $baseDir . '/tests',
    'Bartlett'                            => $baseDir . '/src',
));
$loader->register();

You are now ready to analyse your first data source.

Go to next chapter: Quick Start