We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
from @tobimori via discord
this is basically everything needed (i use the same finder component), you can optimise it for your code
$finder = (new Finder())->files() ->name(static::PHP) ->in($dir); foreach ($finder as $file) { $pattern = strtolower($file->getRelativePathname()); $pattern = preg_replace('~(.*)' . preg_quote('.php', '~') . '~', '$1' . '', $pattern, 1); // replace extension at end $pattern = preg_replace('~(.*)' . preg_quote('index', '~') . '~', '$1' . '', $pattern, 1); // replace index at end, for root of folder, but not in paths etc. $route = require $file->getRealPath(); // check if return is actually an array (if additional stuff is specified, e.g. method or language) or returns a function if (is_array($route) || $route instanceof \Closure) { $this->registry[] = array_merge( [ 'pattern' => '/' . $pattern, 'action' => $route instanceof \Closure ? $route : null ], is_array($route) ? $route : [] ); } }
The text was updated successfully, but these errors were encountered:
bnomei
No branches or pull requests
from @tobimori via discord
The text was updated successfully, but these errors were encountered: