Skip to content

Instantly share code, notes, and snippets.

@toopay
Created October 15, 2012 06:51
Show Gist options
  • Save toopay/3891122 to your computer and use it in GitHub Desktop.
Save toopay/3891122 to your computer and use it in GitHub Desktop.
SplClassLoader Example
<?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();
@seanlindo
Copy link

What are the contents of Request.php or Response.php? This would be helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment