i`m using codeigniter 4 and try to use a controller from other controller
i have 2 controllers in Controllers folder, Home.php dan Shop.php
Home.php
<?php
namespace App\Controllers;
class Home extends BaseController
{
public function index()
{
return view('welcome_message');
}
function validation()
{
$shop = new Shop();
echo $shop->product('laptop', 'brand');
}
}
and Shop.php
<?php
namespace App\Controllers;
class Shop extends BaseController
{
public function index()
{
return view('shop');
}
public function product($type, $product_id)
{
echo "this is a $type and $product_id";
}
}
when i try to load localhost:8080/home/validation
the result still : Whoops! We seem to have hit a snag. Please try again later...
how to do the right way ? thank you