1 pièce(s) jointe(s)
[Silex] ClassNotFoundException Attempted to load class
Bonjour à tous!
J'ai un petit soucis avec l'activité sur le livre. Je n'arrive pas à trouver mon erreur malgré plusieurs heures de recherches sur Internet. J'ai un message du type classnotfound:
Code:
1 2
| Attempted to load class "BookDAO" from namespace "Bookiii\DAO".
Did you forget a "use" statement for another namespace? |
Voici l'architecture de mon appli:
Pièce jointe 287995
J'ai bien psr-4 dans comoser
Code:
1 2 3 4 5 6 7 8 9 10 11
|
{
"require": {
"silex/silex": "~2.0",
"doctrine/dbal": "~2.5",
"twig/twig": "~1.28"
},
"autolaod": {
"psr-4": {"Bookiii\\": "src"}
}
} |
Le fichier app.php contient les données suivantes:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| <?php
use Symfony\Component\Debug\ErrorHandler;
use Symfony\Component\Debug\ExceptionHandler;
// Register global error and exception handlers
ErrorHandler::register();
ExceptionHandler::register();
// Register service providers.
$app->register(new Silex\Provider\DoctrineServiceProvider());
$app->register(new Silex\Provider\TwigServiceProvider(), array(
'twig.path' => __DIR__.'/../views',
));
// Register services.
$app['dao.book'] = function ($app) {
return new Bookiii\DAO\BookDAO($app['db']);
}; |
Je n'ai qu'une route pour l'instant
Code:
1 2 3 4 5
| // Home page
$app->get('/', function () use ($app) {
$books = $app['dao.book']->findBooks();
return $app['twig']->render('index.html.twig', array('books' => $books));
}); |
La classe Book (POPO) (extrait)
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| namespace Bookiii\Domain;
class Book
{
/**
* Book id
*
* @var integer
*/
private $id;
/**
* Book title
*
* @var string
*/
private $title; |
L'accès aux données (extrait)
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| namespace Bookiii\DAO;
use Doctrine\DBAL\Connection;
use Bookiii\Domain\Book;
class BookDAO
{
/**
* Database Connexion
*
* @var \Doctrine\DBAL\Connection
*/
private $db; |
Il y a-t-il erreur quelque part?
Merci d'avance.