How to call the controller method using the route in CodeIgniter 4

Route is an important file for developer. We can see it in App\Config\Route.php. In this file we can manage our routing. Route.php is the file, where we can easily make relation between controller, its functions and URL. Let’s have a sample of route. How to call the controller method using the route in CodeIgniter 4
$routes->add('/homepage', 'MyController::MyFunction');
Explanation: The above line is divided in 3 parts to understand.
The first part is ‘/homepage’, This part indicate the URL which is pass in URL section. Here we use ‘homepage’ that means if we use /homepage in URL section then this route will trigger.
The second part is controller name. Here we pass controller name as ‘MyController’ that means if we use ‘/homepage as a URL than it will go in MyController.
Third part is the place of function or method name. Here we use MyFunction as function name which should be present in MyController.
So in short the above line indicate that if we use ‘homepage’ in URL than it will internally go inside controller named ‘MyController’ and definitely there will be many functions inside this controller so it will trigger ‘MyFunction’ and perform the action whatever is there inside this function.
Example below
<?php namespace App\Controllers;

class MyControllerextends Controller{

public function MyFunction(){

return view('View_Page');

}

}

How to call the controller method using the route in CodeIgniter 4expoundsofttechsolution
How to get the current URL of Laravel in controller and view?