i have a problem with the public in the url.. my form actions and css/js link cannot be found if i do not include in the source url "public". how do i get about this?
Hi Alex, great tutorial! Could you show us the delete method too? I have an issue 'page not found' when I use $routes->delete('blog/(:num)', 'Admin\Blog::delete/$1)... :-(
I have a qestion , this not working $routes->get('blog/new','Admin/Blog::createNew'); giving 404 error and Controller method is not found: new but this works $routes->get('blog/createNew','Admin/Blog::createNew'); giving the form as output
@@ndoch1 1. You can disable default routing and create only your own specific rules. 2. When you want to overwrite the default rules. Ex: instead of domain.com/shop/product/laptop-hp you want to make it domain.com/product/laptop-hp 3. When you want a route for GET request to be different from POST request. Let's say you have a form domain.com/form, and when it is submitted you want to handle the validation in different method but still the same url. Hope that helps :)
Hi bro, please look at this problem I have ... When I use placeholer in the routes for sub-folder it doesn't work: $routes->get('cerrar-jornada/(:any)', 'admin/Jornada::cerrarJornada/$1'); respond with>>>//404 - File Not Found //Controller or its method is not found: \App\Controllers\admin::index this work: $routes->get('cerrar-jornada', 'admin/Jornada::cerrarJornada');
@@AlexLancer github.com/nacio1/polla3x2 there is the app folder same problem: forum.codeigniter.com/thread-76736-post-376929.html#pid376929 I try using back slash and now the method work->$routes->get('cerrar-jornada/(:any)', 'admin\Jornada::cerrarJornada/$1'); but it returns with 404 error with this in the url : localhost/admin/cerrarjornada/jornada/jornada/jornada/jornada/jornada/jornada/jornada/jornada/jornada/jornada/jornada/jornada/jornada/index
Hi, Alex great tutorial. One question regarding controllers. You seem to be creating controllers by duplicating default one and that uses App\Controllers\BaseController, in the docs however they tell you to create controller using App\Controllers\Controller what is the difference if any?
Hey Bartlomiej, good question! You can use BaseController to preload helpers, libraries, models etc. that you are using in other controllers, so that you don't have to write all the common files that you have over and over. So let's say you have a UserModel.php that you will use in all (or almost all) of your controllers Now you can go inside BaseController and load it there and store it in a variable, let's say protected $userModel; $this->userModel = new UserModel(). No every controller that extends BaseController has this property available just by typing $this->userModel So the point here is, it is not required to extend the BaseController, but if you have controllers that use similar libraries (and other files), you can use BaseController (or create other Controllers that you need based on your logic) to preload all the stuff. Hope that helps!!!
I got the problem with default value of function: - My controller: public function teaching($subject = "CI4") { return "I am teaching : " . $subject; } - My routes $routes->add('teach/(:any)', 'Teacher::teaching/$1') It fine if I pass the parameter localhost:8080/teach/ci4 but it will error when i don't pass the parameter localhost:8080/teach
thank for uploading these nice video
Great video, everything well explained. Thanks
Glad it was helpful!
You great, thanks !!
Hello! I have a little question. When we need to use "routes->add" and when we need use routes->get"? Oh... later in video I get the answer :)
Will you talk about multilingual apps in the future? I wonder what is the proper way of routing that in CodeIgniter 4.
SilverBlaidd, actually yes I want to create a video on that in later episodes and will show how to create a routing also
i have a problem with the public in the url.. my form actions and css/js link cannot be found if i do not include in the source url "public". how do i get about this?
Hi Alex, great tutorial! Could you show us the delete method too? I have an issue 'page not found' when I use $routes->delete('blog/(:num)', 'Admin\Blog::delete/$1)... :-(
thanks Alex .... so what the diffirent between add and get in the route file
->get will work only for GET requests. But if you will submit a form with POST method on that same url, ->get route will not be triggered
I have a qestion , this not working $routes->get('blog/new','Admin/Blog::createNew'); giving 404 error and Controller method is not found: new but this works $routes->get('blog/createNew','Admin/Blog::createNew'); giving the form as output
it should be $routes->get('blog/new', 'Admin\Blog::createNew''); with backward slash
Hi Alex, after I submitted the post form it displays object not found. I'm stuck here. can you help me?
Hey, Clara, it is tough to answer if i can't see the code.
Therefore, pls upload it on github and let me know so that I can check it.
Nice tutorial Alex! But do we have to add routes for every method that we have?
No, there is "auto routing" that works like this: domain.com/controller/method
@@AlexLancer so when exactly do we need to specify it?
@@ndoch1 1. You can disable default routing and create only your own specific rules. 2. When you want to overwrite the default rules. Ex: instead of domain.com/shop/product/laptop-hp you want to make it domain.com/product/laptop-hp
3. When you want a route for GET request to be different from POST request. Let's say you have a form domain.com/form, and when it is submitted you want to handle the validation in different method but still the same url.
Hope that helps :)
Hi bro, please look at this problem I have ...
When I use placeholer in the routes for sub-folder it doesn't work:
$routes->get('cerrar-jornada/(:any)', 'admin/Jornada::cerrarJornada/$1');
respond with>>>//404 - File Not Found
//Controller or its method is not found: \App\Controllers\admin::index
this work:
$routes->get('cerrar-jornada', 'admin/Jornada::cerrarJornada');
Jose, If you still did not find the solution, please upload your code to github so that I can see all the files
@@AlexLancer
github.com/nacio1/polla3x2
there is the app folder
same problem: forum.codeigniter.com/thread-76736-post-376929.html#pid376929
I try using back slash and now the method work->$routes->get('cerrar-jornada/(:any)', 'admin\Jornada::cerrarJornada/$1');
but it returns with 404 error with this in the url :
localhost/admin/cerrarjornada/jornada/jornada/jornada/jornada/jornada/jornada/jornada/jornada/jornada/jornada/jornada/jornada/jornada/index
@@AlexLancer Now works, it was an error with the redirect function. Thanks for answering
and please continue with the content
Hi, Alex great tutorial. One question regarding controllers. You seem to be creating controllers by duplicating default one and that uses App\Controllers\BaseController, in the docs however they tell you to create controller using App\Controllers\Controller what is the difference if any?
Hey Bartlomiej, good question!
You can use BaseController to preload helpers, libraries, models etc. that you are using in other controllers, so that you don't have to write all the common files that you have over and over.
So let's say you have a UserModel.php that you will use in all (or almost all) of your controllers
Now you can go inside BaseController and load it there and store it in a variable, let's say protected $userModel;
$this->userModel = new UserModel().
No every controller that extends BaseController has this property available just by typing $this->userModel
So the point here is, it is not required to extend the BaseController, but if you have controllers that use similar libraries (and other files), you can use BaseController (or create other Controllers that you need based on your logic) to preload all the stuff.
Hope that helps!!!
@@AlexLancer Yes it does! I see the difference clearly now.
Thanks
thanks so much bro
I got this error "Controller or its method is not found: \App\Controllers\AdminBlog::index"
Same issue here
If controller is inside Admin folder syntax should be Admin\Blog::index..
I got the problem with default value of function:
- My controller:
public function teaching($subject = "CI4") {
return "I am teaching : " . $subject;
}
- My routes
$routes->add('teach/(:any)', 'Teacher::teaching/$1')
It fine if I pass the parameter localhost:8080/teach/ci4
but it will error when i don't pass the parameter localhost:8080/teach
add second rule without (:any)
$routes->add('teach/(:any)', 'Teacher::teaching/$1')
$routes->add('teach', 'Teacher::teaching')
@@AlexLancer Thank you so much !
keren
I like your tutorial but problem is text size so I request please make video tutorial with caring of mobile users.