Recently, I'm diving into symfony's class loader component. However, I need to solve an issue. I have the following folder structure;
-> project
-> public
-> index.php
-> package
-> Request.php
In index.php
I'm using the following statements to load the class loader of Symfony;
define ('ROOT', dirname(dirname(__FILE__)));
$paths = array(
'system' => ROOT . '/package'
);
$namespaces = array(
'MyNamespace' => $paths['system']
);
require $paths['vendor'] .
'/symfony/class-loader/Symfony/Component/ClassLoader/UniversalClassLoader.php';
use Symfony\Component\ClassLoader\UniversalClassLoader;
$autoload = new UniversalClassLoader();
$autoload->registerNamespaces($namespaces);
$autoload->register();
use MyNamespace\Request;
Request::create();
In Request.php
, I have the following code;
namespace MyNamespace;
class Request
{
static public function create()
{
}
}
However, in index.php file, It says that Request class can't be found
So, What am I doing wrong here ? Any ideas ?