using the SplClassLoader I keep getting class not found
error. I tried various sources, copied their exact folder structure and naming but still not found
.
My structure
application
- Router
- Exceptions
- HttpException.php
- Klein.php
index.php
SplClassLoader.php
index.php
$loader = new SplClassLoader('application', 'application');
$loader->register();
$klein = new \router\Klein();
Klein.php
namespace application\router;
class Klein{
__construct()
HttpException.php
namespace Klein\Exceptions;
use RuntimeException;
class HttpException extends RuntimeException implements HttpExceptionInterface
{
How do I include both these with the classLoader?
The exact error is:
Fatal error: Class 'router\Klein' not found in /home/i366963/domains/[domain]/private_html/public/index.php on line 44
line 44 is $klein = new \router\Klein();
Suggestion:
$loader = new SplClassLoader('application', 'application');
$loader->register();
$klein = new application\Router\Klein();
giving error:
Warning: require(application/application/Router/Klein.php): failed to open stream: No such file or directory in /home/i366963/domains/[domain]/private_html/SplClassLoader.php on line 140
Fatal error: require(): Failed opening required 'application/application/Router/Klein.php' (include_path='.:/usr/local/lib/php') in /home/i366963/domains/[domain]/private_html/SplClassLoader.php on line 140