Controller or its method is not found - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Controller or its method is not found (/showthread.php?tid=87164) |
Controller or its method is not found - Kisumy - 03-21-2023 Hello, I have a problem with my CodeIgniter4 and i dont understand. The Error : 404 - File Not Found Controller or its method is not found: \App\Controllers\Cconteneur::chercher But my Method is already into my Controller. Controller : namespace App\Controllers; use App\Models\Mconteneurs; class Cconteneurs extends BaseController { public function index() { $model = new Mconteneurs(); $data['result'] = $model->getAllWithPager(); $data['pager'] = $model->pager; $page['contenu'] = view('v_conteneurs', $data); return view('Commun/v_template', $page); } public function chercher() { $model = new Mconteneurs(); $texte = $this->request->getGet('recherche'); if ($texte != NULL) { $data['result'] = $model->getSearchWithPager($texte); $data['pager'] = $model->pager; $page['contenu'] = view('v_conteneurs', $data); return view('Commun/v_template', $page); } else { $data['result'] = "Désolé, votre recherche n'a rien donné."; } } } Method : namespace App\Models; use CodeIgniter\Model; class Mconteneurs extends Model { protected $table ='conteneur'; protected $primaryKey = 'Id'; protected $returnType = 'array'; public function getAll() { $requete = $this->select('*') ->orderBy('Id', 'ASC'); return $requete->findAll(); } public function getAllWithPager() { $requete = $this->select('Id, AddrEmplacement'); return $requete->paginate(8); } public function getSearchWithPager($search) { $requete = $this->select('Id, AddrEmplacement') ->like(['AddrEmplacement' => $search]); return $requete->paginate(8); } } And the view : <script src="<?php base_url() ?>js/js_conteneurs.js" defer></script> <article> <div id="contSection1"> <h1 id="titreConteneur">TOUT LES <span id="colorTitreConteneurs">CONTENEURS</span></h1> <hr size="2" color="#00862d" noshade> <div id="listeConteneur"> <form action="<?php echo base_url('Cconteneur/chercher'); ?>" method="get"> <input type="text" name="recherche" placeholder="Ville ou Adresse désirée" id="carreRecherche"> <input type="submit" value="Rechercher" id="boutonRecherche"> </form> <div> <?php if ($result != NULL) { foreach ($result as $row) { echo ' <div id="styleConteneurs"> <p> ' . $row["Id"] . ' - ' . $row["AddrEmplacement"] . ' </p> <a href="#">Plus d\'information</a> </div> '; } } else { echo 'Erreur détecté.'; } ?> </div> <div id="contSection2"> <?php echo $pager->links(); ?> </div> </div> </div> </article> That happen when i do an research, I dont know why cause as you can see my method "chercher" is created in my controller. Ty for the help RE: Controller or its method is not found - kenjis - 03-23-2023 How do you configure Routes.php? Do you use auto routing? RE: Controller or its method is not found - kilishan - 03-23-2023 You have a typo. Your class is the plural version, Cconteneurs, while the route is looking for the singular version, \App\Controllers\Cconteneur::chercher. RE: Controller or its method is not found - InsiteFX - 03-23-2023 Saw that myself, tipical error. Thanks @kilishan. RE: Controller or its method is not found - Kisumy - 03-30-2023 (03-23-2023, 09:19 PM)kilishan Wrote: You have a typo. Your class is the plural version, Cconteneurs, while the route is looking for the singular version, \App\Controllers\Cconteneur::chercher. Ty so much !! |