PHPackages                             dmp/aop-bundle - 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. dmp/aop-bundle

ActiveSymfony-bundle

dmp/aop-bundle
==============

Adds AOP capabilities to Symfony6

1.0.1(7mo ago)05412Apache-2.0PHPPHP &gt;=8.1

Since Sep 27Pushed 7mo agoCompare

[ Source](https://github.com/Armenian/aop-bundle)[ Packagist](https://packagist.org/packages/dmp/aop-bundle)[ RSS](/packages/dmp-aop-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (4)Versions (4)Used By (2)

======== Overview
=================

[](#overview)

This bundle adds AOP capabilities to Symfony 5.

If you haven't heard of AOP yet, it basically allows you to separate a cross-cutting concern (for example, security checks) into a dedicated class, and not having to repeat that code in all places where it is needed.

In other words, this allows you to execute custom code before, and after the invocation of certain methods in your service layer, or your controllers. You can also choose to skip the invocation of the original method, or throw exceptions.

Installation
------------

[](#installation)

Checkout a copy of the code::

```
composer require dmp/aop-bundle

```

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

[](#configuration)

```
jms_aop:
    cache_dir: %kernel.cache_dir%/jms_aop

```

Usage
-----

[](#usage)

In order to execute custom code, you need two classes. First, you need a so-called pointcut. The purpose of this class is to make a decision whether a method call should be intercepted by a certain interceptor. This decision has to be made statically only on the basis of the method signature itself.

The second class is the interceptor. This class is being called instead of the original method. It contains the custom code that you would like to execute. At this point, you have access to the object on which the method is called, and all the arguments which were passed to that method.

Examples
--------

[](#examples)

1. Logging

```

In this example, we will be implementing logging for all methods that contain
"delete".

Pointcut
^^^^^^^^

::
