从目录中的目录中查找php文件

I have code for find php files from one directory.

$files = glob('./application/controllers/*.{php}', GLOB_BRACE);

Is there any way to find php files from directory within directory.

I mean, if there are some folders in controllers folder and inside those folders php files are there. then, how can I detect those files too.

You can use Nette Finder (https://packagist.org/packages/nette/finder) and do

$files = Finder::findFiles('*.php')->from('./application/controllers/');
foreach ($files as $file) {
    echo "$file
";
}