Learn CodeIgniter 4 Framework Tutorials #3 Create Controller & Configure Routes

preview_player
Показать описание
In this video we'll see:

Learn CodeIgniter 4 Framework Tutorials #3 Create Controller & Configure Routes

About CodeIgniter 4 Controllers & Routes

Controllers act as glue code, marshaling data back and forth between the view (or the user that’s seeing it) and the data storage.

Controllers are typically stored in /app/Controllers

We can use the name of the Controller like

Basic code of a Controllers:
-----------------------------------------------
namespace App\Controllers;

class SiteController extends BaseController
{
public function test()
{
return view("site/test"); //views/site/test
}

public function aboutUs()
{
echo view("site/about-us");
}
}

While Defining Controllers we need extend Parent Controller as Base Controller

Routes in CodeIgniter 4
----------------------------------------------------------
Routes in CodeIgniter have gone through a pretty big upgrade from version 3 to 4.

Route Basics
As a refresher, in version 3 routes were specified in a simple array, where each key was the "URI from" and the value of the element was where it should be routed to. It was simple, elegant, worked great, and looked something like this:

$route['join'] = 'home/register';
$route['login'] = 'home/login';
$route['products/(:any)/details'] = 'products/show/$1';

Some Examples of defining routes in that file

$routes-get('/', 'Home::index');
$routes-get("/test", "SiteController::test");
$routes-get("/about-us", "SiteController::aboutUs");
$routes-get("/contact-us", "First::contactUs");

#codeigniter4
#learncodeigniter4
#onlinewebtutor
#codeigniter4Framework

SOCIAL :
===============

Other Tutorials
===============
Wordpress Customizations:
---------------------------------
and many more...

Javascript framework:
----------------------------------

PHP Frameworks:
----------------------------------

Tags:
----------------------------------
learn codeigniter 4,
step by step codeigniter 4,
codeigniter 4 tutorials,
codeigniter 4 beginners tutorials,
learn codeigniter 4 framework,
learn codeigniter 4 step by step,
codeigniter4,
online web tutor codeigniter 4,
codeigniter 4 framework,
online web tutor

Thanks
Online Web Tutor
Keep learning and Sharing :)
Рекомендации по теме
Комментарии
Автор

Hi,

Best place to learn CodeIgniter 4 theory and complete basics.

How can we work with the database in CodeIgniter 4 and what are the methods to work?

OnlineWebTutor
Автор

Thanks Mr. Sanjay.. I lernt a lot.. in your lessons...

advancewebdevelopment
Автор

you are great boss.. i have lost much of time to find this routes->get() anyone are not there in youtube who is talking about this problem brother... please adjust with my language...

Virbhadraa
Автор

Thanks for the excellent tutorial on ci4 . For me if i use code/localhost:8080 is working after starting spark server. But if i use localhost/code it fails saying localhost refused to connect. What settings i have to change. I have changed the baseurl in config.php page. But no change. What settings i have to make

ssentps
Автор

Hello Sanjay your tutorial is excellent. I need one clarification. For me code/localhost:8080 is working. code is my project name. But if i type localhost/code in browser it is not working saying that localhost refused to connect. What setting i have to change

ssentps
Автор

getting error 404 file not found : Can't find a route for 'get: /test'. -- Test is controller name

manishasalunke
Автор

How can I create custom controller in sub-directory & call from routes ?

abubakarwazihtushar
Автор

Forbidden
You don't have permission to access this resource.

Apache/2.4.46 (Win64) OpenSSL/1.1.1g PHP/7.4.10 Server at localhost Port 80


getting this error

abdulsameer
welcome to shbcf.ru