Skip to content

Instantly share code, notes, and snippets.

@toomuchpete
Last active August 29, 2015 14:25
Show Gist options
  • Save toomuchpete/ec2538b23d62fab99c2d to your computer and use it in GitHub Desktop.
Save toomuchpete/ec2538b23d62fab99c2d to your computer and use it in GitHub Desktop.
Module Autoloader
<?php
function loadThingsMagically($folder_path) {
// Cache pre-existing
$preExistingClasses = count(get_declared_classes());
requireAllFromFolder($folder_path);
foreach (array_slice(get_declared_classes(), $preExistingClasses) as $class) {
if (method_exists($class, 'loadCoolModule')) {
$class::loadCoolModule();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment