My First Project
1.static page
1.1 URL Secret
http://example.com/[controller-class]/[controller-method]/[arguments]
Take it for example:domain name +project name, controller-class / controller-method / arguments.
=> https//localhost/CI4/welcome/login/1
part 1:domain name+project name
controller-class:welcome
controller-method:login
argument:1
2.MVC workflow
There is mutual communciation between each two of these three components except from view and model.But more precisely the input from user is most provided via view instead of controller.To put it another way there are mutual communiciation between view and user.
3.Controller
3.1 definition
what does controller do?processing request and ask for data backwards to Model as well as forwarding data to View.
3.2 URL secret(V.2)
such as some private or privileged parts,we can put all the relevant functionalities into one specific folder.
CI4/Shop/check/parrmeter_1/…;
CI4/Mall/Shop/check/parameter_1/…;
3.3 Different folder Same name of php files
use … as …;
=>a hint behind this principle: codeigniter may track php file and inside method by namespace.
/app/controllers/mall/shop.php
<?php
namespace App\Controllers\mall;
use App\Controllers\BaseController;
class Shop extends BaseController
{
public function index()
{
return view('shop');
}
public function product(){
return view('product');
}
public function check($parameter , $parameter2){
echo 'the parameter_01 is :' . $parameter . 'as well as the second parameter is '.$parameter2.';';
//return view('check_'. $parameter);
}
public function getInfo(){
echo 'this is the protected method getInfo()';
}
}
/app/controllers/shop.php
<?php
namespace App\Controllers;
use App\Controllers\mall\shop as MallShop;
class Shop extends BaseController
{
public function index()
{
return view('shop');
}
public function product(){
return view('product');
}
public function check($parameter , $parameter2){
echo 'the parameter_01 is :' . $parameter . 'as well as the second parameter is '.$parameter2.';';
echo '<br>';
$mallshop = new MallShop();
$mallshop->check($parameter,$parameter2);
//return view('check_'. $parameter);
}
public function getInfo(){
echo 'this is the protected method getInfo()';
}
}