Problème Configuration controller

Par Sean78, il y a 12 ans


Bonjour à tous, je débute sur CakePHP.
Je suis entrain de suivre le tutoriel "Formation vidéo: Apprendre CakePHP":

Not Found

The requested URL /cakephp/posts/index/ was not found on this server.

J'ai recommencer plusieurs fois toutes les étapes je ne vois ce que j'ai raté.

Merci d'avance de vos aides?

23 réponses

Grimp, il y a 12 ans

Salut, copie ton controller pour voir!

Sean78, il y a 12 ans

Bonsoir Grimp,
j'ai le fichier PostsController.php qui est dans le dossier Controller:
le code est le suivant comme dans le tuto:
<?php
class PostsController extends AppController {
Public function index () {
}
}

je n'arrive vraiment pas à voir ou est l'erreur?!
Merci Grimp

antho07, il y a 12 ans

Bonjour, l'url rewrting est-il activé sur ton serveur?

bien cordialement

Antho

Sean78, il y a 12 ans

Salut Antho, je travail en local (wampserver, Apache/2.4.4 (Win64) PHP/5.4.12 et cakephp 2.3.6) , comment fait-on stp pour activer "l'URL REWRITING"?

Merci Antho

antho07, il y a 12 ans

clic gauche sur l icone de wamp => apache =>httpd.conf

Enlève le # devant LoadModule rewrite_module modules/mod_rewrite.so

enregistre puis relance wamp

cordialement

Antho

Sean78, il y a 12 ans

Salut antho, ça devient déprimant! j'ai une fenêtre blanche. je ne sais quoi faire.

bonne journée.

antho07, il y a 12 ans

Bonjour, heu quand tu arrives où ?

Sean78, il y a 12 ans

Salut,
en cliquant sur "Afficher code source" je tombe sur ce bout de code:

<h2> Variables du View</h2>
<ul class="neat-array depth-0"><li><strong>class</strong>PostsController</li><li><strong>plugin</strong>(null)</li><li><strong>code</strong>404</li><li><strong>url</strong>/cakephp/posts/index</li><li><strong>name</strong>Controller class PostsController could not be found.</li><li><strong>error</strong>exception 'MissingControllerException' with message 'Controller class PostsController could not be found.' in C:\wamp\www\cakephp\lib\Cake\Routing\Dispatcher.php:156
Stack trace:
#0 C:\wamp\www\cakephp\app\webroot\index.php(110): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))

antho07, il y a 12 ans

Reprenons tu as touché à rien dans la config des routes de cakePHP ?

Tu as mis dans app/controller le fichier PostsController.php?
tu as dans app/view un dossiers posts dans lequel tu as mis un fichier index.ctp

et tu essayes de joindre localhost/{nomsite}/posts ?

Sean78, il y a 12 ans

URL /cakephp/posts/index/

antho07, il y a 12 ans

Dans le fichier httpd.conf (accessible en cliquant sur l icone wamp puis apache et httpd.conf , la ligne "LoadModule rewrite_module modules/mod_rewrite.so" est bien décommentée ?(sans # devant)

Enfin tu as bien redemarrer wamp après avoir fait le changement?

Sean78, il y a 12 ans

oui c'est ça!

antho07, il y a 12 ans

Derniere chose, dans click gauche wamp , apache => apache module,
rewrite module est bien coché? (la petite mouette noire)

antho07, il y a 12 ans

Si cela ne marche toujours dis moi je te proposerai un truc

Sean78, il y a 12 ans

c'est bien coché.

Sean78, il y a 12 ans

Missing Controller
Error: PostsController could not be found.

Error: Create the class PostsController below in file: app\Controller\PostsController.php

antho07, il y a 12 ans

la même erreur .. ok

Sean78, il y a 12 ans

Merci antho!!je t'ajoute!

Sean78, il y a 12 ans

EUREKA!!!!!!!
Comme je suis nulllll des fois!!!!!Merci ANTHO!!!!!!!!

antho07, il y a 12 ans

??

Sean78, il y a 12 ans

Je viens de t'ajouter. je n'avais pas mis le fichier postscontroller.php dans le dossier controller mais il était dans un dossier "posts" qui lui était dans controller.

antho07, il y a 12 ans

Bah voilà.. pour m'ajouter tu me trouveras pas sur skype avec l'adresse que je t'ai donné..

Sean78, il y a 12 ans

la vraie erreur venait du rewrite! pcq le fichier était en effet auparavant dans controller, mais après je testais tout n'importe quoi et il c'est trouvé dans un dossier post. Encore merci à toi!!!