PHP code example of league / construct-finder
1. Go to this page and download the library: Download league/construct-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/ */
league / construct-finder example snippets
use League\ConstructFinder\ConstructFinder;
// Find all constructs
$constructs = ConstructFinder::locatedIn(__DIR__ . '/SomeDirectory')->findAll();
$constructNames = ConstructFinder::locatedIn(__DIR__ . '/SomeDirectory')->findAllNames();
// Find all classes
$constructs = ConstructFinder::locatedIn(__DIR__ . '/SomeDirectory')->findClasses();
$constructNames = ConstructFinder::locatedIn(__DIR__ . '/SomeDirectory')->findClassNames()
// Find all interfaces
$constructs = ConstructFinder::locatedIn(__DIR__ . '/SomeDirectory')->findInterfaces();
$constructNames = ConstructFinder::locatedIn(__DIR__ . '/SomeDirectory')->findInterfaceNames();
// Find all enums
$constructs = ConstructFinder::locatedIn(__DIR__ . '/SomeDirectory')->findEnums();
$constructNames = ConstructFinder::locatedIn(__DIR__ . '/SomeDirectory')->findEnumNames();
// Find all traits
$constructs = ConstructFinder::locatedIn(__DIR__ . '/SomeDirectory')->findTraits();
$constructNames = ConstructFinder::locatedIn(__DIR__ . '/SomeDirectory')->findTraitNames();
use League\ConstructFinder\Construct;
use League\ConstructFinder\ConstructFinder;
// Find all constructs
$constructs = ConstructFinder::locatedIn(__DIR__ . '/SomeDirectory')->findAll();
/** @var Construct $construct */
$construct = $constructs[0];
$name = $construct->name();
$name = (string) $construct;
$type = $construct->type(); // class, trait, interface, enum
use League\ConstructFinder\ConstructFinder;
// Find all constructs
$constructs = ConstructFinder::locatedIn(
__DIR__ . '/SomeDirectory',
__DIR__ . '/AnotherDirectory',
)->findAll();
use League\ConstructFinder\ConstructFinder;
// Find all constructs
$constructs = ConstructFinder::locatedIn(__DIR__ . '/SomeDirectory')
->exclude('*Test.php', '*/Tests/*')
->findAll();