Getting Started

How to get started with your first reflexion

This simple tutorial will demonstrate how to parse a simple file or a directory.

Parsing with default options
<?php
require_once 'Bartlett/PHP/Reflect/Autoload.php';

$source = '/path/to/source_file.php';

try {
    $reflect = new PHP_Reflect();
    $reflect->scan($source);

    $classes    = $reflect->getClasses();
    // OR
    $classes    = $reflect['classes'];

    $interfaces = $reflect->getInterfaces();
    // OR
    $interfaces = $reflect['interfaces'];

    $traits     = $reflect->getTraits();
    // OR
    $traits     = $reflect['traits'];

    $functions  = $reflect->getFunctions();
    // OR
    $functions  = $reflect['functions'];

    $constants  = $reflect->getConstants();
    // OR
    $constants  = $reflect['constants'];

    $namespaces = $reflect->getNamespaces();
    // OR
    $namespaces = $reflect['namespaces'];

} catch (Exception $e) {
    echo 'Caught exception: ' . $e->getMessage() . PHP_EOL;
?>