CodeIgniter Forums
controller of _remap seem to fail. - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=31)
+--- Thread: controller of _remap seem to fail. (/showthread.php?tid=72860)

Pages: 1 2


controller of _remap seem to fail. - rfrkk - 02-20-2019

I build a controller: care.php in App\Controllers\wheels,
for simple testing _remap, the code is as follows.

Assuming the URL is 127.0.0.1/myproject/wheels/care/a1, it will get a1 string.
But,assuming the URL is 127.0.0.1/myproject/wheels/care/bb123, the result will appear "Method App\Controllers\wheels\Care::bb123() does not exis",
it is not as directed to the contentProcess function as I expected,
Please give me help.

PHP Code:
namespace App\Controllers\wheels;
 
use 
CodeIgniter\Controller;
 
class 
Care extends Controller {
 
 
   public function _remap($method, ...$params) {
 
       if (method_exists($this$method)) {
 
           return $this->$method(); // go to a1
 
       }else{
 
            return $this->contentProcess();//go to contrntProcess
 
       }
 
   }
 
 
   protected function contentProcess() {
 
       echo 'contentProcess';
 
   }
 
 
   protected function a1() {
 
       echo "a1";
 
   }
 




RE: controller of _remap seem to fail. - kilishan - 02-20-2019

What does the relevant route for that look like?


RE: controller of _remap seem to fail. - rfrkk - 02-20-2019

(02-20-2019, 09:21 PM)kilishan Wrote: What does the relevant route for that look like?

I don't set any relevant route for wheels, it just has default code in route.php


PHP Code:
$routes->get('/''Home::index'); 



RE: controller of _remap seem to fail. - rfrkk - 02-20-2019

(02-20-2019, 09:21 PM)kilishan Wrote: What does the relevant route for that look like?

PS:  I use codeigniter 4.0.0 alpha5 version, thank you.


RE: controller of _remap seem to fail. - rfrkk - 02-21-2019

I found this error just when I started development mode.
It maybe have bugs, maybe it?


RE: controller of _remap seem to fail. - ciadmin - 02-21-2019

Suggestions:
1) Your controller class and source file need to be UCfirst, i.e.
2) the error message says that CI cannot find a bb123() method inside the Care class
3) Is your document root correct? It should be the public folder inside your project. I interpret an URL like yours as looking for App/Controllers/myproject/wheel/Care, which may not be what you intend


RE: controller of _remap seem to fail. - rfrkk - 02-22-2019

I found the bugs that is route.php of ci debug tool.

I update all packages by Zip compressed file for you testing , thank you.

download


RE: controller of _remap seem to fail. - kilishan - 03-02-2019

Sorry - as a general practice I won't download random files from the internet. If you'd like to submit a PR for the fix, that would be great.


RE: controller of _remap seem to fail. - rfrkk - 03-02-2019

(03-02-2019, 12:15 PM)kilishan Wrote: Sorry - as a general practice I won't download random files from the internet. If you'd like to submit a PR for the fix, that would be great.

How to submit a PR for the fix ? Thank you.


RE: controller of _remap seem to fail. - kilishan - 03-03-2019

Here are some docs to help out. I believe there's a link in there to find more information.