Created
October 15, 2012 06:51
-
-
Save toopay/3891122 to your computer and use it in GitHub Desktop.
SplClassLoader Example
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 | |
// Let say we have these directory structure, that follow PSR-0 spec : | |
// | |
// system | |
// - framework | |
// - Http | |
// - Request.php | |
// - Response.php | |
// test.php | |
// SplClassLoader.php | |
// | |
// Then we could utilize it as : | |
require_once('SplClassLoader.php'); | |
$loader = new SplClassLoader('framework', 'system/framework'); | |
$loader->register(); | |
// Now we could call any classes within | |
// framework namespace without the need to include each files/classes | |
// as easy as : | |
$request = new Http\Request(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What are the contents of Request.php or Response.php? This would be helpful.