Example #1
0
 public function testGeneratorMultipleFiles()
 {
     $generator = new Autoloader\Generator(__DIR__ . '/fixtures/multiple/');
     $generator->multipleFiles();
     $generator->relativePaths();
     $generator->generate(__DIR__ . '/fixtures/multiple.php');
     $classes = array('foobar_term_1', 'foobar\\term1\\xx1');
     require __DIR__ . "/fixtures/multiple.php";
     foreach ($classes as $class) {
         $this->assertFalse(class_exists($class, false));
         $this->assertTrue(class_exists($class), "Cannot load {$class}");
     }
     $loadedFiles = array_filter(get_included_files(), function ($file) {
         return strpos($file, __DIR__ . "/fixtures/multiple") === 0 && strpos($file, __DIR__ . "/fixtures/multiple/loader:") !== 0;
     });
     $this->assertEquals(3, count($loadedFiles));
 }
Example #2
0
<?php

require "lib/Autoloader/Generator.php";
$generator = new Autoloader\Generator("vendor/");
$generator->generate("generated.php");
if (is_file("generated.php")) {
    echo "The autoloader is generated and saved in generated.php\n";
} else {
    echo "Failed\n";
}