I want to convert my MVC framework to conform to the PSR-0 standards, but I am having a devil of a time trying to wrap my head around namespaces and how it works. I am using the suggested SplClassLoader class. Below is my file structure, and what I am trying to accomplish.

index.php
application
system
---------Classes
----------------Autoloader.php
----------------Extension.php
---------config
----------------helper.php

index.php:

require( SYS_PATH . 'config/constants.php');
require( SYS_PATH . 'application.php');
require( SYS_PATH . 'Classes/Autoloader.php');

use Classes\Autoloader;
$classLoader = new Autoloader('Classes', BASE_PATH . 'system');
$classLoader->register();

$app = new Bootstrap();

Extension.php:

<?php if ( ! defined('BASE_PATH')) exit('No direct script access allowed');

namespace Classes;

class Extension {

        public __construct() {
             echo 'This Extension class is working';
        }

}

helper.php

<?php if ( ! defined('BASE_PATH')) exit('No direct script access allowed');

use Classes\Extension as Ext;
$apphelp = new Ext();
$apphelp->helper(array('gettext'));

The helper.php file is automatically loaded through a registry.php file, so there are no issues there. Now that all that is place, I am getting the following error:
Fatal error: Class 'Classes\Extension' not found in /Applications/MAMP/htdocs/framework/system/config/helper.php on line 21

I can't figure out what I am doing wrong. Like I said, I am still trying to understand namespaces, but I thought I was making progress, but I've been struggling with this for two days now. I know that "namespace" is supposed to come first in the code, and I did make that change even though it doesn't look so above, but I still receive errors. Any help is greatly appreciated.

I came across this SO thread, not sure if yours is the same issue though.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.