Consultez la FAQ sur le ZF avant de poster une question
Vous n'êtes pas identifié.
Bonjour,
Je rencontre actuellement un problème inexplicable, j'ai l'erreur suivante :
Fatal error: Class 'Application\Model\Users' not found in /var/www/....../module/Application/Module.php on line 68
Voici mon fichier Module.php
[lang=php] <?php namespace Application; use Zend\Mvc\MvcEvent; use Zend\Mvc\ModuleRouteListener; use Application\Model\Users; use Application\Model\UsersTable; use Zend\Db\ResultSet\ResultSet; use Zend\Db\TableGateway\TableGateway; use Zend\ModuleManager\Feature\ConfigProviderInterface; use Zend\ModuleManager\Feature\AutoloaderProviderInterface; class Module { public function onBootstrap(MvcEvent $e) { } public function getConfig() { return include __DIR__ . '/config/module.config.php'; } public function getAutoloaderConfig() { } public function getServiceConfig() { return array( 'factories' => array( 'Application\Model\UsersTable' => function ($sm) { $tableGateway = $sm->get('UsersTableGateway'); $table = new UsersTable($tableGateway); return $table; }, 'UsersTableGateway' => function ($sm) { $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter'); $resultSetPrototype = new ResultSet(); $resultSetPrototype->setArrayObjectPrototype(new Users()); return new TableGateway('table_users', $dbAdapter, null, $resultSetPrototype); } ) ); } }
Voici mon fichier Users.php
[lang=php] <?php namespace Application\Model; class Users { public $_id_users; public $_id_customer; public $_login_users; public $_password_users; public $_firstname_users; public $_lastname_users; public function exchangeArray($data) { $this->_id_users = (!empty($data['id_users'])) ? $data['id_users'] : null; $this->_id_customer = (!empty($data['id_customer'])) ? $data['id_customer'] : null; $this->_login_users = (!empty($data['login_users'])) ? $data['login_users'] : null; $this->_password_users = (!empty($data['password_users'])) ? $data['password_users'] : null; $this->_firstname_users = (!empty($data['firstname_users'])) ? $data['firstname_users'] : null; $this->_lastname_users = (!empty($data['lastname_users'])) ? $data['lastname_users'] : null; } public function getId() { return $this->_id_users; } public function setId($id) { $this->_id_users = $id; return $this; } public function getId_Customer() { return $this->_id_customer; } public function setId_Customer($id_customer) { $this->_id_customer = $id_customer; return $this; } public function getLogin() { return $this->_login_users; } public function setLogin($login) { $this->_login_users = $login; return $this; } public function getPassword() { return $this->_password_users; } public function setPassword($password) { $this->_password_users = sha1($password); return $this; } public function getFirstname() { return $this->_firstname_users; } public function setFirstname($firstname) { $this->_firstname_users = $firstname; return $this; } public function getLastname() { return $this->_lastname_users; } public function setLastname($lastname) { $this->_lastname_users = $lastname; return $this; } public function toArray() { return array( 'id_users' => $this->_id_users, 'id_customer' => $this->_id_customer, 'login_users' => $this->_login_users, 'password_users' => $this->_password_users, 'firstname_users' => $this->_firstname_users, 'lastname_users' => $this->_lastname_users ); } }
Voici mon fichier UsersTable.php
[lang=php] <?php namespace Application\Model; use Zend\Db\TableGateway\TableGateway; class UsersTable { public $_tableGateway; public function __construct(TableGateway $tableGateway) { $this->_tableGateway = $tableGateway; } public function fetchAll() { return $this->select(); } public function getUsers($id) { if ($id === null) { $row = null; } else { $row = $this->select(array( 'id' => (int) $id ))->current(); } if (!$row) { throw new \Exception("Cannot get row $id in table $this->_table"); } return $row; } }
Une idée ?
Dernière modification par an0nym21 (29-07-2013 16:16:07)
Hors ligne
Salut, essaies de remplacer ton new Users() par new \Application\Model\Users() pour voir.
Hors ligne
Merci pour ta réponse.
Je viens de tester, mais rien n'y fait j'ai toujours le même message d'erreur...
Hors ligne
Bon, je ne sais pas si je dois mettre la résolution de ce sujet, j'ai un peu honte ^^
Mais mon dossier 'Model' était en fait dans src/Model au lieu de src/Application/Model ....
Désolé
Hors ligne