Search code examples
phpcodeigniterroutesphpstorm

PHPStorm and CodeIgniter routing issue


I started studying CodeIgniter Web Framework and I am trying to work with PHPStorm 8.0.3 on Kubuntu 14.04. When I unzip CodeIgniter downloaded archive to root Apache folder /var/www/html and go to

localhost/index.php 

then it works okay and I see "Welcome to CodeIgniter!" page. Also I can use

localhost/index.php/welcome/index 

and see the same page as it should be.

When I created a new PHP project in PHPStorm and try

localhost:63342/codeignitor/index.php/ 

then I see welcome page, but if I use

localhost:63342/codeignitor/index.php/welcome/index

then I get 404 page. Also all my own controllers are not available and cause 404.

I can call my own controller only if I make it default

$route['default_controller'] = 'mycontroller';

I think that this problem occurs because the URL contains name of my project /codeignitor/, but I'm not sure about it. So I need your advice how to set CodeIgniter environment in PHPStorm correctly to solve this problem. Thank you!


Solution

  • Codeigniter uses the URL to determine routing, therefore /codeigniter/index.php/welcome/index and /index.php/welcome/index are not equal paths. I would recommend using one or the other, and adjusting your /index.php and /config/routes.php to accommodate for your desired path.

    References:

    Codeigniter Subfolder