Is there an easy way to programmatically require all files in a folder?
Probably only by doing something like this:
$files = glob($dir . '/*.php'); foreach ($files as $file) { require($file); }
It might be more efficient to use opendir()
and readdir()
than glob()
.
No short way of doing it, you'll need to implement it in PHP. Something like this should suffice:
foreach (scandir(dirname(__FILE__)) as $filename) { $path = dirname(__FILE__) . '/' . $filename; if (is_file($path)) { require $path; } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With