• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Controller in for sub-directory

#1
Question 
Hello!

I try create controller in sub-directory, but get 404 error.
I just follow documentation https://codeigniter4.github.io/CodeIgnit...irectories and create folder "one" and file in folder "Hello.php":

PHP Code:
<?php namespace App\Controllers;

class 
Hello extends BaseController
{

    public function method()
    {
        echo 'success';
    }



App/Controllers/one/hello/method

Codeigniter has been installed in sub-directory site.com/backend
Now i try call controller by link site.com/backend/one/hello/method and i get 404 error - "Controller or its method is not found: App\Controllers\One::hello".

How to create controller files correctly in sub-diectory?

Thank you!
Reply

#2
Your Hello controller needs the proper namespace ...
Code:
<?php namespace App\Controllers\one;
Reply

#3
(09-07-2019, 05:50 AM)ciadmin Wrote: Your Hello controller needs the proper namespace ...
Code:
<?php namespace App\Controllers\one;

Thank you!

It worked!
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.