Download the PHP package ngmy/laravel.aop without Composer
On this page you can find all versions of the php package ngmy/laravel.aop. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ngmy/laravel.aop
More information about ngmy/laravel.aop
Files in ngmy/laravel.aop
Package laravel.aop
Short Description Laravel.Aop integrates Ray.Aop with Laravel.
License MIT
Homepage https://github.com/ngmy/Laravel.Aop
Informations about the package laravel.aop
Laravel.Aop
Laravel.Aop integrates Ray.Aop with Laravel. It provides fast AOP by static weaving.
Installation
First, you should install Laravel.Aop via the Composer package manager:
You will be asked if you trust the olvlvl/composer-attribute-collector
package, so you should press y
.
Next, you should configure the olvlvl/composer-attribute-collector
package.
[!TIP] Please see the composer-attribute-collector documentation to learn how to configure the
olvlvl/composer-attribute-collector
package.
Then, you should publish the Laravel.Aop configuration file using the vendor:publish
Artisan command. This command
will publish the aop.php
configuration file to your application's config
directory:
Finally, you should add the @php artisan aop:compile --ansi
script to the post-autoload-dump
event hook of the
composer.json
file:
Usage
First, you should define the attribute.
For example, let's define the Transactional
attribute:
Next, you should define the interceptor.
For example, let's define the TransactionalInterceptor
interceptor:
[!TIP] Please see the Ray.Aop documentation to learn more about the interceptor.
Then, you should register the attribute and the interceptor in the intercept
configuration option of the
config/aop.php
configuration file.
For example, let's register the Transactional
attribute and the TransactionalInterceptor
interceptor:
Then, you should annotate the methods that you want to intercept with the attribute.
For example, let's annotate the createUser
method of the UserService
class with the Transactional
attribute:
Finally, you should run the dump-autoload
Composer command to compile the AOP classes:
[!IMPORTANT] After changing the
intercept
configuration option or changing the annotation of the methods, you should compile the AOP classes again.
Now, the methods annotated with the attribute will be intercepted by the interceptor.
In this example, the createUser
method of the UserService
class will be intercepted by the
TransactionalInterceptor
and will be executed in a transaction.
[!IMPORTANT] The methods annotated with the attribute are intercepted by the interceptor only when the class instance is dependency resolved from the service container. If the class instance is created directly, the methods are not intercepted.
Changelog
Please see the changelog.
License
Laravel.Aop is open-sourced software licensed under the MIT license.
All versions of laravel.aop with dependencies
laravel/framework Version ^9.0 || ^10.0 || ^11.0
olvlvl/composer-attribute-collector Version *
ray/aop Version *
symfony/finder Version *