Install
Reflect may be installed in several ways, choose your favorite.
Minimal Requirements
Before you install PHP Reflect, you will need an operating system with PHP 5.3.0 or later installed, and four loaded extensions: Reflection, tokenizer, pcre, SPL.
Using PEAR
Once all of the dependencies have been installed, you can then install PHP Reflect using the standard PEAR installer. Run the following commands as root (on Linux, OSX, and other UNIX-like operating systems) or as a user with administrator privileges on Windows.
$ pear channel-discover bartlett.laurent-laville.org
$ pear install -o php_reflect
Using Composer
Put a file named composer.json at the root of your project, with the content below:
{
"require": {
"pear-bartlett/PHP_Reflect": "2.0.*"
},
"repositories": [
{
"type": "pear",
"url": "http://bartlett.laurent-laville.org"
}
]
}
And run the following command:
$ php composer.phar install
Using PHP Archive (phar)
wget http://bartlett.laurent-laville.org/get/phpreflect.phar
chmod +x phpreflect.phar
Using on Linux distributions
PHP Reflect could be installed as RPM, using the package installer.
In Fedora, from official repository.
In Enterprise Linux (RHEL, CentOS, Scientific Linux, Oracle Linux, …), from the EPEL repository.
# yum install php-bartlett-PHP-Reflect
Autoloaders
Reflect does not provides any native autoloader.
It’s up to you to choose what is be the best strategy :
-
If you have installed Reflect 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, except if you want to add some user components.
-
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.
<?php
require_once 'Symfony/Component/ClassLoader/UniversalClassLoader.php';
use Symfony\Component\ClassLoader\UniversalClassLoader;
$loader = new UniversalClassLoader();
$loader->registerNamespaces(array(
'Bartlett' => __DIR__ . DIRECTORY_SEPARATOR . 'src',
'Symfony' => __DIR__ . DIRECTORY_SEPARATOR . 'vendor',
));
$loader->register();
You are now ready to parse your first data source.