PHPackages                             goaop/goaop-laminas-module - 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. [Framework](/categories/framework)
4. /
5. goaop/goaop-laminas-module

ActiveLibrary[Framework](/categories/framework)

goaop/goaop-laminas-module
==========================

Integration module for Go! AOP Framework

v3.2.0(4y ago)11244[2 PRs](https://github.com/goaop/goaop-laminas-module/pulls)MITPHPCI failing

Since Jul 20Pushed 4y ago3 watchersCompare

[ Source](https://github.com/goaop/goaop-laminas-module)[ Packagist](https://packagist.org/packages/goaop/goaop-laminas-module)[ GitHub Sponsors](https://github.com/lisachenko)[ RSS](/packages/goaop-goaop-laminas-module/feed)WikiDiscussions master Synced yesterday

READMEChangelog (3)Dependencies (11)Versions (7)Used By (0)

GoAopModule
===========

[](#goaopmodule)

[![GitHub release](https://camo.githubusercontent.com/a01cc017ee13cb488a99617ad7d5236ca705a79715e7525b0ea24bb951d93920/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f64616e6e796d657965722f676f616f702d6c616d696e61732d6d6f64756c652e737667)](https://github.com/dannymeyer/goaop-laminas-module/releases/latest)[![Minimum PHP Version](https://camo.githubusercontent.com/dd6bad85ee03cf570f4cf82ab69a80396fdbf48050af932f8f23aa551b0d1e5a/687474703a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230352e352d3838393242462e737667)](https://php.net/)[![License](https://camo.githubusercontent.com/0c905924202d4d8529df1c2fbe40626008a5d39ecbcfd657b96ffd2deaf757e8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f64616e6e796d657965722f676f616f702d6c616d696e61732d6d6f64756c652e737667)](https://packagist.org/packages/dannymeyer/goaop-laminas-module)

The GoAopModule adds support for Aspect-Oriented Programming via Go! AOP Framework for Laminas Framework 2 applications.

Overview
--------

[](#overview)

Aspect-Oriented Paradigm allows to extend the standard Object-Oriented Paradigm with special instruments for effective solving of cross-cutting concerns in your application. This code is typically present everywhere in your application (for example, logging, caching, monitoring, etc) and there is no easy way to fix this without AOP.

AOP defines new instruments for developers, they are:

- Joinpoint - place in your code that can be used for interception, for example, execution of single public method or accessing of single object property.
- Pointcut is a list of joinpoints defined with a special regexp-like expression for your source code, for example, all public and protected methods in the concrete class or namespace.
- Advice is an additional callback that will be called before, after or around concrete joinpoint. For PHP each advice is represented as a `\Closure` instance, wrapped into the interceptor object.
- Aspect is a special class that combines pointcuts and advices together, each pointcut is defined as an annotation and each advice is a method inside this aspect.

You can read more about AOP in different sources, there are good articles for Java language and they can be applied for PHP too, because it's general paradigm. Installation
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

[](#you-can-read-more-about-aop-in-different-sources-there-are-good-articles-for-java-language-and-they-can-be-applied-for-php-too-because-its-general-paradigminstallation)

GoAopModule can be easily installed with composer. Just ask a composer to download the bundle with dependencies by running the command:

```
$ composer require goaop/goaop-laminas-module
```

Add the `Go\Laminas\Framework` to your list of modules in the config/application.config.php `modules` array:

```
// config/application.config.php

    // This should be an array of module namespaces used in the application.
    'modules' => array(
        'Go\Laminas\Framework',
        'Application',
    ),
```

Configuration
-------------

[](#configuration)

The default configuration in the `config/module.config.php` file. Copy this file to your own config directory to modify the values.

Configuration can be used for additional tuning of AOP kernel and source code whitelistsing/blacklisting.

```
// config/module.config.php

$moduleConfig = [
    /*
     |--------------------------------------------------------------------------
     | AOP Debug Mode
     |--------------------------------------------------------------------------
     |
     | When AOP is in debug mode, then breakpoints in the original source code
     | will work. Also engine will refresh cache files if the original files were
     | changed.
     | For production mode, no extra filemtime checks and better integration with opcache
     |
     */
    'debug' => false,

    /*
     |--------------------------------------------------------------------------
     | Application root directory
     |--------------------------------------------------------------------------
     |
     | AOP will be applied only to the files in this directory, change it if needed
     */
    'appDir' => $basicDirectory,

    /*
     |--------------------------------------------------------------------------
     | AOP cache directory
     |--------------------------------------------------------------------------
     |
     | AOP engine will put all transformed files and caches in that directory
     */
    'cacheDir' => $basicDirectory . '/data/cache/aspect',

    /*
     |--------------------------------------------------------------------------
     | Cache file mode
     |--------------------------------------------------------------------------
     |
     | If configured then will be used as cache file mode for chmod
     */
    'cacheFileMode' => 0770 & ~umask(),

    /*
     |--------------------------------------------------------------------------
     | Controls miscellaneous features of AOP engine
     |--------------------------------------------------------------------------
     |
     | See \Go\Aop\Features enumeration for bit mask
     */
    'features' => 0,

    /*
     |--------------------------------------------------------------------------
     | White list of directories
     |--------------------------------------------------------------------------
     |
     | AOP will check this list to apply an AOP to selected directories only,
     | leave it empty if you want AOP to be applied to all files in the appDir
     */
    'includePaths' => [
        $basicDirectory . '/module'
    ],

    /*
     |--------------------------------------------------------------------------
     | Black list of directories
     |--------------------------------------------------------------------------
     |
     | AOP will check this list to disable AOP for selected directories
     */
    'excludePaths' => [],

    /**
     |--------------------------------------------------------------------------
     | AOP container class
     |--------------------------------------------------------------------------
     |
     | This option can be useful for extension and fine-tuning of services
     */
    'containerClass' => GoAspectContainer::class,
];
```

Defining new aspects
--------------------

[](#defining-new-aspects)

Aspects are services in the Laminas application and loaded into the AOP container by the integration module after putting them into the `goaop_aspect` section in the `application.config.php file`. Here is an example how to implement a logging aspect that will log information about public method invocations in the module/ directory.

Definition of aspect class with pointcut and logging advice

```
