PHP code example of daycry / class-finder

1. Go to this page and download the library: Download daycry/class-finder library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

daycry / class-finder example snippets




$classes = (new \Daycry\ClassFinder\ClassFinder())->getClassesInNamespace('Daycry');

/**
 * array(
 *   'TestApp1\Foo\Bar',
 *   'TestApp1\Foo\Baz',
 *   'TestApp1\Foo\Foo'
 * )
 */
var_dump($classes);



$classes = (new \Daycry\ClassFinder\ClassFinder())->getClassesInNamespace('Daycry', \Daycry\ClassFinder\ClassFinder::RECURSIVE_MODE);

/**
 * array(
 *   'TestApp1\Foo\Bar',
 *   'TestApp1\Foo\Baz',
 *   'TestApp1\Foo\Foo',
 *   'TestApp1\Foo\Box\Bar',
 *   'TestApp1\Foo\Box\Baz',
 *   'TestApp1\Foo\Box\Foo',
 *   'TestApp1\Foo\Box\Lon\Bar',
 *   'TestApp1\Foo\Box\Lon\Baz',
 *   'TestApp1\Foo\Box\Lon\Foo',
 * )
 */
var_dump($classes);


$config = config('ClassFinder');

$config->finder['classMap'] = false;
$config->finder['files'] = false;

$classes = (new \Daycry\ClassFinder\ClassFinder($config))->getClassesInNamespace('Daycry', \Daycry\ClassFinder\ClassFinder::RECURSIVE_MODE);


$config = config('ClassFinder');

$config->finder['classMap'] = false;
$config->finder['files'] = false;

$classes = (new \Daycry\ClassFinder\ClassFinder($config))->getClassesInNamespace('App', \Daycry\ClassFinder\ClassFinder::RECURSIVE_MODE);

$classes = (new \Daycry\ClassFinder\ClassFinder($config))->getClassesInNamespace('Config', \Daycry\ClassFinder\ClassFinder::RECURSIVE_MODE);


$config = config('ClassFinder');

$config->finder['classMap'] = false;
$config->finder['files'] = false;

$classes = (new \Daycry\ClassFinder\ClassFinder($config))->getClassesInNamespace('Daycry', \Daycry\ClassFinder\ClassFinder::RECURSIVE_MODE | \Daycry\ClassFinder\ClassFinder::ALLOW_CLASSES | \Daycry\ClassFinder\ClassFinder::ALLOW_INTERFACES | \Daycry\ClassFinder\ClassFinder::ALLOW_TRAITS | \Daycry\ClassFinder\ClassFinder::ALLOW_FUNCTIONS );