php - Parameter passing through routing problem in Codeigniter 4

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: \App\Controllers\Userfeed::delete
Error message at add or get routing: Controller or its method is not found: \App\Controllers\Pages::index
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 App\Controllers\Pages;
use App\Controllers\MainCtrl;
...
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. =)
Answer
Solution:
Try this one
$routes->get('userfeed/delete/(:any)', 'Pages\UserFeed::delete/$1');
The difference is the slash used. You must use a backslash () not forward (/)
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: use the option --with-all-dependencies (-w) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.