Last active
August 29, 2015 14:22
-
-
Save shgysk8zer0/47fdf867459541e57c27 to your computer and use it in GitHub Desktop.
PHP SPL Autoloader
This file contains 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
# Configure PHP's autoloader and set include_path | |
<IfModule env_module> | |
SetEnv AUTOLOAD_DIR classes | |
SetEnv AUTOLOAD_EXTS .php | |
SetEnv AUTOLOAD_FUNC spl_autoload | |
</IfModule> | |
# Loads the autoloader script before executing main PHP file | |
php_value auto_prepend_file ./autoloader.php |
This file contains 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 | |
set_include_path( | |
realpath(getenv('AUTOLOAD_DIR')) . | |
PATH_SEPARATOR . get_include_path() | |
); | |
spl_autoload_extensions(getenv('AUTOLOAD_EXTS')); | |
spl_autoload_register(getenv('AUTOLOAD_FUNC')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
PHP Autoloader using .htaccess
include_path
and autoloader usinggetenv