Welcome Guest, Not a member yet? Register   Sign In
How to Routes for Function with parameter?
#1

I made module with following tree:

module\Blog
module\Blog\Config
module\Blog\Controller
module\Blog\View


I put Blog.php inside module\Blog\Controller with 2 below functions:


Code:
public function index()
{
  echo 'this is index!';
}

public function page($id)
{
    echo 'this is page = ' .$id;
}


and below Routes.php inside module\Blog\Controller

Code:
$routes->get('blog', '\Modules\Blog\Controllers\Blog::index');
$routes->get('blog/page/(:num)', '\Modules\Blog\Controllers\Blog::page\$1');


when I tried to execute http://localhost/blog ==> its working,
but when I try to trigger http://localhost/blog/page/1 ==> return 404 error 

How to declare the routes to pass Controller's function parameter the right way?
Reply


Messages In This Thread
How to Routes for Function with parameter? - by munggaran - 11-18-2020, 02:26 AM



Theme © iAndrew 2016 - Forum software by © MyBB