PHPackages                             popov/zfc-current - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. popov/zfc-current

ActiveZf-module[Utility &amp; Helpers](/categories/utility)

popov/zfc-current
=================

Plugin and Helper for get current controller, action, route, request and much more

0.2.0(8y ago)3302MITPHPPHP &gt;=5.5

Since Jun 23Pushed 7y ago1 watchersCompare

[ Source](https://github.com/popovserhii/zfc-current)[ Packagist](https://packagist.org/packages/popov/zfc-current)[ RSS](/packages/popov-zfc-current/feed)WikiDiscussions master Synced yesterday

READMEChangelog (2)DependenciesVersions (4)Used By (0)

\#ZF2 Current Module This plugin allow get current namespace, module, controller, action, route, router and request through Controller Plugin or View Helper.

Instalation
-----------

[](#instalation)

Add package to your composer.json

```
{
    "require": {
        "popovsergiy/zfc-current": "dev-master"
    }
}
```

And update your vendors

```
$ php composer.phar update popovsergiy/zfc-current
```

Don't forget Add `'Popov\Current'` to `config/application.config.php`

```
return [
    'modules' => [
    	// ...
    	'Popov\Current'
    ]
]
```

Usage
-----

[](#usage)

This library has Controller Plugin and View Helper which allow simple access to main ZF2 varialbes.

### Controller usage

[](#controller-usage)

```
namespace YourModule\Controller

use Zend\Mvc\Controller\AbstractActionController;

class PostController extends AbstractActionController {

  public function indexAction() {
    $this->current('controller'); // post - controller name in module.config.php
    $this->current('action'); // index
    $this->current('module'); // YourModule
    $this->current('route'); // RouteMatch object
    $this->current('request'); // Request object

    $this->current()->currentModule(\Other\Module\Model\Entity::class); // Other\Module
  }
}
```

### View Usage

[](#view-usage)

```
// your-module/post/index.phtml

Current controller :
