Download the PHP package ray/aop without Composer

On this page you can find all versions of the php package ray/aop. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package aop

Ray.Aop

Aspect Oriented Framework

Scrutinizer Code Quality codecov Type Coverage Continuous Integration Total Downloads

ray-di logo

[Japanese]

Ray.Aop package provides method interception. This feature enables you to write code that is executed each time a matching method is invoked. It's suited for cross cutting concerns ("aspects"), such as transactions, security and logging. Because interceptors divide a problem into aspects rather than objects, their use is called Aspect Oriented Programming (AOP).

A Matcher is a simple interface that either accepts or rejects a value. For Ray.AOP, you need two matchers: one that defines which classes participate, and another for the methods of those classes. To make this easy, there's factory class to satisfy the common scenarios.

MethodInterceptors are executed whenever a matching method is invoked. They have the opportunity to inspect the call: the method, its arguments, and the receiving instance. They can perform their cross-cutting logic and then delegate to the underlying method. Finally, they may inspect the return value or exception and return. Since interceptors may be applied to many methods and will receive many calls, their implementation should be efficient and unintrusive.

Example: Forbidding method calls on weekends

To illustrate how method interceptors work with Ray.Aop, we'll forbid calls to our pizza billing system on weekends. The delivery guys only work Monday thru Friday so we'll prevent pizza from being ordered when it can't be delivered! This example is structurally similar to use of AOP for authorization.

To mark select methods as weekdays-only, we define an attribute.

...and apply it to the methods that need to be intercepted:

Next, we define the interceptor by implementing the org.aopalliance.intercept.MethodInterceptor interface. When we need to call through to the underlying method, we do so by calling $invocation->proceed():

Finally, we configure everything using the Aspect class:

Putting it all together, (and waiting until Saturday), we see the method is intercepted and our order is rejected:

PECL Extension

Ray.Aop also supports a PECL extension. When the extension is installed, you can use the weave method to apply aspects to all classes in a directory:

With the PECL extension:

To use these features, simply install the PECL extension and Ray.Aop will automatically utilize it when available. PHP 8.1+ is required for the PECL extension.

Installing the PECL extension

PHP 8.1 or higher is required to use the PECL extension. For more information, see ext-rayaop.

Configuration Options

When creating an Aspect instance, you can optionally specify a temporary directory:

If not specified, the system's default temporary directory will be used.

This concludes the basic usage of Ray.Aop. For more detailed information and advanced usage, please refer to the full documentation.

Own matcher

You can have your own matcher. To create contains matcher, You need to provide a class which have two method. One is matchesClass for class match. The other one is matchesMethod method match. Both return the boolean result of matched.

Interceptor Details

In an interceptor, a MethodInvocation object is passed to the invoke method:

$invocation->proceed() invokes the next interceptor in the chain. If no more interceptors are present, it calls the target method. This chaining allows multiple interceptors for a single method, executing in the order bound.

Example execution flow for interceptors A, B, and C:

  1. Interceptor A (before)
  2. Interceptor B (before)
  3. Interceptor C (before)
  4. Target method
  5. Interceptor C (after)
  6. Interceptor B (after)
  7. Interceptor A (after)

This chaining mechanism allows you to combine multiple cross-cutting concerns (like logging, security, and performance monitoring) for a single method.

With the MethodInvocation object, you can:

Annotation/Attribute

Ray.Aop can be used either with doctrine/annotation in PHP 7/8 or with an Attributes in PHP8.

AOP Alliance

The method interceptor API implemented by Ray.Aop is a part of a public specification called AOP Alliance.

Installation

The recommended way to install Ray.Aop is through Composer.

PHP8 attributes only (recommended)

Integrated DI framework

Stability

Ray.Aop follows semantic versioning and ensures backward compatibility. Released in 2015, version 2.0 and its successors have maintained compatibility while evolving with PHP, and we remain committed to this stability.



All versions of aop with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2 || ^8.0
ext-hash Version *
ext-tokenizer Version *
doctrine/annotations Version ^1.12 || ^2.0
koriym/attributes Version ^1.0.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ray/aop contains the following files

Loading the files please wait ....