I want Implemente the namespace autoloading with composer and PSR-0, and I don't know why it dosen't work.
there is my file structure:
src
|app
| world
| World.php
| user
| User.php
vendor
Test.php
composer.json
in World.php
<?php
namespace world;
class World {
public function hello() {
return "hello world";
}
}
?>
in User.php
<?php
namespace user;
class User {
public function hello() {
return "hello user";
}
}
?>
in composer.json
{
"autoload": {
"psr-0": {
"my": "src/app"
}
}
}
and when I test this in Test.php :
<?php
require 'vendor/autoload.php';
class Myworld {
public function testhello() {
$w = new my\librairie\World();
echo $w->hello();
$u = new my\user\User();
echo $u->hello();
}
}
$m = new Myworld();
$m->testhello();
?>
I get this error :
Fatal error: Class 'my\user\User' not found
Fatal error: Class 'my\world\World' not found
what I miss !? Any advice would be welcome! thanks.