• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Understanding routes

#1
Hello, i'm new in CI and i just started my app.My question is about routes, if i have :

PHP Code:
$route['something/(:any)'] = 'Login/test/$1'

And if i request 'something' without anything, i must to make another route like this : $route['something'] = 'Login/test'; and finally to look like this:


PHP Code:
$route['something'] = 'Login/test/$1';

$route['something/(:any)'] = 'Login/test/$1'


Or is another way to make this?

My controller is:

PHP Code:
class Login extends CI_Controller{

    public function index(){
        $this->load->view('login_view');
    }
public function 
test(string $ceva){

        if(isset($ceva)){
            echo "avem setat {$ceva} <br />";
        }
        echo "sunt si aici";
    }

Reply

#2
Hello,

I think that this is a CI3 question posted in the CI4 section :-)

If you are talking about CI4, you can use " $routes->resource('something'); ". It will create all routes for you and solve your problem: https://codeigniter4.github.io/userguide...stful.html

Anyway, the "app/Config/Routes.php" file says:
// We get a performance increase by specifying the default
// route since we don't have to scan directories.

So I prefer to define all routes manually. I don't know if this is the right reasoning to have though :-)
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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