This site is built with Viewi itself. It is experimental and still in development. If you see any bugs please do not hesitate and open an issue or DM me on Twitter.

Client Router

Client router is a service that allows you to navigate through pages. Inject Viewi\Common\ClientRouter to use it.

It has the following methods:

  • navigateBack()
    Navigates your browser to the previous page. On a server side, navigateBack does nothing.
  • navigate(string $url)
    Navigates your browser to that url. On a server side, navigate currently redirects you to that url.
  • getUrl()
    Returns a current url path without a query, for example: '/', '/users', etc.

How to use:

use Viewi\Common\ClientRouter;

class MemberGuard implements IMiddleware
    private ClientRouter $router;
    public function __construct(ClientRouter $clientRouter)
        $this->router = $clientRouter;
    // ...
    // somewhere in the code
    // or
    // or
    $currentUrl = $this->router->getUrl();