PHPackages                             tasmaniski/laminas-current-route - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. tasmaniski/laminas-current-route

ActiveLibrary[Templating &amp; Views](/categories/templating)

tasmaniski/laminas-current-route
================================

View Helper for reading current route info: Controller, Action, Module name

3.0.2(6y ago)3612.2k↓33.3%11[2 issues](https://github.com/tasmaniski/laminas-current-route/issues)MITPHPPHP &gt;=5.6CI failing

Since Oct 6Pushed 3y ago3 watchersCompare

[ Source](https://github.com/tasmaniski/laminas-current-route)[ Packagist](https://packagist.org/packages/tasmaniski/laminas-current-route)[ Docs](https://github.com/tasmaniski)[ RSS](/packages/tasmaniski-laminas-current-route/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (3)Versions (10)Used By (0)

[![Licence](https://camo.githubusercontent.com/b2f671e0ca3e43d0564d65bd14a07e673c5d88d107a813b4e52ec35785c0bb10/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7461736d616e69736b692f6c616d696e61732d63757272656e742d726f757465)](https://camo.githubusercontent.com/b2f671e0ca3e43d0564d65bd14a07e673c5d88d107a813b4e52ec35785c0bb10/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7461736d616e69736b692f6c616d696e61732d63757272656e742d726f757465)[![PHP version](https://camo.githubusercontent.com/1b709c62146da63af97c21b6b85d350fae028cca88cb29e8585192ad3cc93184/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7461736d616e69736b692f6c616d696e61732d63757272656e742d726f757465)](https://camo.githubusercontent.com/1b709c62146da63af97c21b6b85d350fae028cca88cb29e8585192ad3cc93184/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7461736d616e69736b692f6c616d696e61732d63757272656e742d726f757465)

```
IMPORTANT NOTE:
If you find this package useful,
please click on a star button and let me know,
so I will gladly continue with the updates.
```

Laminas MVC - Current Route Helper
==================================

[](#laminas-mvc---current-route-helper)

View Helper for reading **Controller, Module, Action and Route name** in any view(.phtml) file including layout.phtml

Install
=======

[](#install)

Add in you **composer.json** file:

```
{
    "require": {
        "tasmaniski/laminas-current-route": "^3.0"
    }
}
```

After running: *composer update*

You need to register new module. Add in file **config/application.config.php**:

```
'modules' => array(
    '...',
    'CurrentRoute'
),

```

Use
===

[](#use)

Use this view helper in your view files(.html) including layout.phtml

```
// get current route info
$this->currentRoute()->getController();               // return current controller name
$this->currentRoute()->getAction();                   // return current action name
$this->currentRoute()->getModule();                   // return current module name
$this->currentRoute()->getRoute();                    // return current route name

// or simply check with current info
$this->currentRoute()->matchController('index');      // match "index" with current controller name
$this->currentRoute()->matchAction('index');          // match "index" with current action name
$this->currentRoute()->matchModule('application');    // match "application" with current module name
$this->currentRoute()->matchRoute('home');            // match "home" with current route name

```

### Real world example

[](#real-world-example)

```
