I have a little routing problem, that i can't solve in Codeigniter 4.
I try adding a parameter at deleting list item. But get the following error messages.
Error message at post routing: Controller or its method is not found:
AppControllersUserfeed::delete
Error message at add or get routing: Controller or its method is not found:
AppControllersPages::index
controllers file directory:
the relevant part of the Route file (it's in the Config directory):
$routes->get('/', 'Pages/Home::index');
$routes->get('userfeed', 'Pages/UserFeed::index');
$routes->post('userfeed/add', 'Pages/UserFeed::add');
//$routes->add('userfeed/(:any)', 'Pages/UserFeed::delete');//this works fine
$routes->get('userfeed/(:any)', 'Pages/UserFeed::delete');//this works fine
//$routes->get('userfeed/(:any)', 'Pages/UserFeed::delete/$1');//this is not work, which is the goal
//$routes->post('userfeed/(:any)', 'Pages/UserFeed::delete/$1');//this is not work
//$routes->add('userfeed/(:any)', 'Pages/UserFeed::delete/$1');//this is not work
...
the relevant part of the controller:
namespace AppControllersPages;
use AppControllersMainCtrl;
...
class UserFeed extends MainCtrl{
....
public function delete($id=FALSE)
{
var_dump('wooot?');
var_dump($id);
}
}
the view part:
....
<a class="badge badge-secondary" href="<?php echo base_url('userfeed/delete/'.$rss['id']);?>" >T?r?l</a>
....
But if i make a copy from this controller in the root controller directory, it's working.
$routes->get('userfeed/delete/(:any)', 'UserFeed2::delete/$1');//it's working fine
If need more information let it with me know.
Thanks your help! :)
Note: Thank God, found the problem. :)
And one guess, one reward. =)
question from:
https://stackoverflow.com/questions/66052836/parameter-passing-through-routing-problem-in-codeigniter-4 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…