Skip to content

Commit

Permalink
Update PECL extension use in README files
Browse files Browse the repository at this point in the history
The PECL extension code usage examples in both the English and Japanese README files have been updated to be more descriptive. Furthermore, detailed installation instructions for the PECL extension, including the requirement of PHP 8.1 or higher, have been added.
  • Loading branch information
koriym committed Jul 7, 2024
1 parent 0bcea46 commit bbb90c7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
20 changes: 16 additions & 4 deletions README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,30 @@ chargeOrder not allowed on weekends!
```

## PECL拡張

Ray.Aopは[PECL拡張](https://github.com/ray-di/ext-rayaop)もサポートしています。拡張機能がインストールされている場合、weaveメソッドを使用してディレクトリ内のすべてのクラスにアスペクトを適用できます。

```php
$aspect->weave(__DIR__ . '/src');

$billing = new RealBillingService; // インターセプターが適用されます
$aspect = new Aspect();
$aspect->bind(
(new Matcher())->any(),
(new Matcher())->annotatedWith(NotOnWeekends::class),
[new WeekendBlocker()]
);
$aspect->weave(__DIR__ . '/src'); // ディレクトリ内でマッチャーに一致するすべてのクラスにアスペクトを織り込みます。
$billing = new RealBillingService();
echo $billing->chargeOrder(); // インターセプターが適用されます。
```

PECL拡張機能を使用すると:

通常のnewキーワードを使用してコードのどこでも新しいインスタンスを作成できます。
インターセプションはfinalクラスやメソッドでも動作します。
これらの機能を使用するには、PECL拡張機能をインストールするだけで、Ray.Aopが自動的に利用します。
これらの機能を使用するには、PECL拡張機能をインストールするだけで、Ray.Aopが自動的に利用します。

### PECL拡張のインストール

PECL拡張機能の利用にはPHP 8.1以上が必要です。詳細は[ext-rayaop](https://github.com/ray-di/ext-rayaop?tab=readme-ov-file#installation)を参照してください。

## 設定オプション
Aspectインスタンスを作成する際に、オプションで一時ディレクトリを指定できます。
Expand Down
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,26 @@ chargeOrder not allowed on weekends!
Ray.Aop also supports a [PECL extension](https://github.com/ray-di/ext-rayaop). When the extension is installed, you can use the `weave` method to apply aspects to all classes in a directory:

```php
$aspect->weave(__DIR__ . '/src');

$billing = new RealBillingService; // Interceptors applied
$aspect = new Aspect();
$aspect->bind(
(new Matcher())->any(),
(new Matcher())->annotatedWith(NotOnWeekends::class),
[new WeekendBlocker()]
);
$aspect->weave(__DIR__ . '/src'); // Weave the aspects to all classes in the directory that match the matcher.
$billing = new RealBillingService();
echo $billing->chargeOrder(); // Interceptors applied
```

With the PECL extension:
- You can create new instances anywhere in your code using the normal `new` keyword.
- Interception works even with `final` classes and methods.

To use these features, simply install the PECL extension and Ray.Aop will automatically utilize it when available.
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](https://github.com/ray-di/ext-rayaop?tab=readme-ov-file#installation).

## Configuration Options

Expand Down

0 comments on commit bbb90c7

Please sign in to comment.