PHP code example of darsyn / class-finder

1. Go to this page and download the library: Download darsyn/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/ */

    

darsyn / class-finder example snippets




use Darsyn\ClassFinder\ClassFinder;

$finder = new ClassFinder;
$finder->setRootDirectory(__DIR__);

$subDir = 'Models';
$suffix = 'Entity';
$parent = 'Framework\\ActiveRecordEntity';

$classes = $finder->findClasses($subDir, $suffix, $parent);
foreach ($classes as $class) {
	echo $class . "\n";
}

/**
 * Example Output:
 *
 * Models\UserEntity
 * Models\GroupEntity
 * Models\CustomerEntity
 */



use Darsyn\ClassFinder\BundleClassFinder;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class DefaultController extends Controller
{
	public function indexAction()
	{
		$kernel = $this->container->get('kernel');
		$finder = new BundleClassFinder($kernel);
		// Find all container-aware commands across all bundles:
		$containerAwareCommands = $finder->findClasses(
			'Command',
			'Command',
			'Symfony\\Bundle\\FrameworkBundle\\Command\\ContainerAwareCommand'
		);
	}
}