Welcome Guest, Not a member yet? Register   Sign In
Controller not found
#1

this is the first time I use Codeigniter 4

I'm already installed codeigniter 4 with composer or manual

already copy index.php and .htaccess to root when manual install and run

already run with php start spark serve too

already set baseurl  http://localhost/ci4

welcome_message is success run when I Write in URL localhost:8080 or localhost/ci4

but when I write in URL  localhost:8080/home/index  with spark serve, show 404 - File Not Found

and when I write in URL  localhost/ci4/home/index  still show 404 - File Not Found

anyone please help me....
Reply
#2

the urls you have outlined work on my web app on desktop and running using php spark serve:
Code:
app/Config/Routes.php I have
$routes->setAutoRoute(false);
$routes->get('/', 'Home::index');


//controller home i have :
public function Index()
    {
                
$this->cachePage(DAY);
        //got above from foundations book
        
        $data = [
                'title'  => 'home page ',
                
        ];
            
       echo view('home',$data);
      
        
    }

i didn't touch .htaccess , i did  get latest  index.php from vendor/public directory and stick it in  webapp/public
also latest spark executable from vendor and replace the one in web root, with it . Thats all
CMS CI4     I use Arch Linux by the way 

Reply
#3

(08-12-2022, 12:17 AM)dreamer Wrote: already copy index.php and .htaccess to root when manual install and run

Please don't copy these files. You don't need to do.

You need to define routes.
See https://codeigniter4.github.io/CodeIgnit...ting-rules
Reply




Theme © iAndrew 2016 - Forum software by © MyBB