Created
December 4, 2012 20:48
-
-
Save dongilbert/4208509 to your computer and use it in GitHub Desktop.
Auto Loading Custom Libraries
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Proposal to auto load custom libraries and register them with the | |
| * application for use. Assume the directory structure below: | |
| * | |
| * /libraries | |
| * - import.php | |
| * - /joomla | |
| * - /easel // The custom library | |
| * - setup.php // This file get's automatically included | |
| * - /controller | |
| * - /helper | |
| * - /joverride | |
| * | |
| * This could be accomplished by adding something like the below | |
| * to the `JLoader::setup()` method. | |
| */ | |
| $iterator = new DirectoryIterator(JPATH_PLATFORM); | |
| foreach ($iterator as $fileinfo) | |
| { | |
| // If we find a folder, see if there is a setup.php file. | |
| if ($fileinfo->getType() === 'dir') | |
| { | |
| $it = new DirectoryIterator($fileinfo->getPathname()); | |
| foreach ($it as $finfo) | |
| { | |
| if ($finfo->getFilename() === 'setup.php') | |
| { | |
| include $finfo->getPathname(); | |
| } | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php // File: /libraries/easel/setup.php | |
| define('EE_PATH', __DIR__); | |
| JLoader::registerPrefix('EE', EE_PATH); | |
| JLoader::registerPrefix('J', EE_PATH . '/joverride'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment