Aug 22, 2024
home.php
), accessed via localhost/home
.home.php
: Rename to shop.php
and change class name to Shop
.welcome page
to shop
.views/shop.php
with content <h2>This is a shop</h2>
.localhost/shop
to see the shop page.product
in Shop
controller:
localhost/shop/product
product.php
with content <h2>This is a product</h2>
.echo '<h2>This is a product ' . $type . '</h2>';
localhost/shop/product/laptop
shows "This is a product laptop".protected
for methods that shouldn't be publicly accessible:
protected function admin()
will give a 404 error when accessed directly.controllers
, create admin
folder.shop.php
into admin
folder, rename as Shop.php
.localhost/admin/shop
to check if it works.<h2>This is an admin shop area</h2>
.Shop
and Admin\\Shop
in the same controller.use App\Controllers\Admin\Shop;
Home
controller:
$shop = new Shop();
$adminShop = new AdminShop();