mardi 13 mai 2014

php - autoload compositeur - classe introuvable exception - Stack Overflow


I am pulling my hairs out on this one, and that does not happen frequently.


I am trying to use composers autoloader, with a directory of mine. The autoloader works perfectly with another directory.


I am using the following filestructure


-Root
| application
| Module
| Users
| Users.php

The Users.php contains the following code


<?php
namespace Module\Users;

class Users {
public function test() { return "Testing hippie-yaay!"; }
}

The composer.json contains the following psr-0 autoload


"psr-0":{"Module\\": "application/"}

which in the autoloader_namespaces.php compiles to the following


'Module\\' => array($baseDir . '/application'),

Which then again, is totally correct (Ive tested this by echoing out the basedir -application string. It is totally correct.


now. In my main class i do the following


<?php
namespace System\Core;
use Module\Users\Users;

class Initiater {
public function bootSystem() {
$u = new Users();
}
}

(this is basically what i do, ofcourse the other psr-0 autoloads i were talking about at the top are over this one, working just fine.)


I then get the following error.


Fatal error: Class 'Module\Users\Users' not found in

FYI: I tried with just "use Module\Users;" and "new \Module\Users\Users();" both returning the same error.


I hope one of you knows whats going on here. Best regards. Jonas



I am pulling my hairs out on this one, and that does not happen frequently.


I am trying to use composers autoloader, with a directory of mine. The autoloader works perfectly with another directory.


I am using the following filestructure


-Root
| application
| Module
| Users
| Users.php

The Users.php contains the following code


<?php
namespace Module\Users;

class Users {
public function test() { return "Testing hippie-yaay!"; }
}

The composer.json contains the following psr-0 autoload


"psr-0":{"Module\\": "application/"}

which in the autoloader_namespaces.php compiles to the following


'Module\\' => array($baseDir . '/application'),

Which then again, is totally correct (Ive tested this by echoing out the basedir -application string. It is totally correct.


now. In my main class i do the following


<?php
namespace System\Core;
use Module\Users\Users;

class Initiater {
public function bootSystem() {
$u = new Users();
}
}

(this is basically what i do, ofcourse the other psr-0 autoloads i were talking about at the top are over this one, working just fine.)


I then get the following error.


Fatal error: Class 'Module\Users\Users' not found in

FYI: I tried with just "use Module\Users;" and "new \Module\Users\Users();" both returning the same error.


I hope one of you knows whats going on here. Best regards. Jonas


0 commentaires:

Enregistrer un commentaire