bachi/typo3-aop

TYPO3 Extension to enable aop programming.

Installs: 1

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 0

Forks: 0

Open Issues: 0

Type:typo3-cms-extension

dev-master 2019-06-16 00:32 UTC

This package is auto-updated.

Last update: 2021-03-16 04:59:41 UTC


README

This extension enables you to use Aspect Oriented Programming in TYPO3. Behind the scenes we use the goaop framework, which is stable and fast.

For more information look at the documentation on goaop documentation.

Why do you need this?

Do you ever need to extend the functionality of a extension or the core itself but no hook or signal slot is in place? With this extension you can hook into every class, no matter what you need.

It gives you to be more flexibility, to find the perfect solution for your case.

Installation

Open a command console, enter your project directory and execute the following command to download the latest stable version of this package:

$ composer require bachi/typo3-aop:@dev

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.

Attention: Installtion through the TYPO3 Extension Installer is not supported, due it's limitation of the autoloading process and dependency management.

How to use

First of all you need to create an Aspect:

namespace Acme\Demo\Aspect\LoggingAspect

use Go\Aop\Aspect;
use Go\Lang\Annotation\Before;

final class LoggingAspect implements Aspect
{
    /**
     * @Before("execution(public Example->*(*))")
     */
    public function beforeMethodExecution(MethodInvocation $invocation)
    {
        // do some stuff.
    }
}

Please be aware, that this aspect implements the Aspect interface!

Now we need to register our aspect into the new container:

# ext_localconf.php
\Baachi\GoAOP\Kernel\TYPO3AspectKernel::registerAspect(\Acme\Demo\Aspect\LoggingAspect::class);

Done! Easy right?

Tuning for production

This extension have an debug mode, ensure that this option is disabled in your production environment.

Also register an cache warmup command. It's strongly encouraged to run this command in your deployment routine.

$ php -dmemory_limit=-1 vendor/bin/typo3 cache:warmup:aop

This command consumes a lot of memory!