Skip to content

Commit 4c6b64e

Browse files
committed
Update readme with new namespaces for custom annotations
1 parent 5d7215f commit 4c6b64e

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

readme.md

+13-8
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,13 @@ class MailHandler {
177177

178178
}
179179
```
180-
or if you prefer to use attributes, set `$useAttribute` to `true` and do this.
180+
or if you prefer to use attributes, set `$useAttribute` to `true` and do this. Note that unlike annotations, a use statement is required for the attribute.
181181

182182
```php
183183
<?php namespace App\Handlers\Events;
184184

185-
use App\User;use Collective\Annotations\Events\Attributes\Attributes\Hears;
185+
use App\User;
186+
use Collective\Annotations\Events\Attributes\Attributes\Hears;
186187

187188
class MailHandler {
188189

@@ -290,8 +291,6 @@ As well as defining middleware inline in the route definition tags (`@Get`, `@Po
290291
}
291292
```
292293

293-
294-
295294
Or on a whole controller, with the same only/exclude filter syntax that you can use elsewhere in laravel:
296295

297296
```php
@@ -460,15 +459,19 @@ This is the equivalent of calling `Route::model('users', 'App\Users')`.
460459

461460
<a name="custom-annotations"></a>
462461
## Custom Annotations
462+
_Please Note: the namespaces have been updated in version 8.1 in order to allow PHP 8 attribute support._
463463

464-
If you want to register your own annotations, create a namespace containing subclasses of `Collective\Annotations\Routing\Annotations\Annotations\Annotation` - let's say `App\Http\Annotations`.
464+
If you want to register your own annotations, create a namespace containing subclasses of `Collective\Annotations\Routing\Meta` - let's say `App\Http\Annotations`.\
465+
(_For version 8.0 and older, extend `Collective\Annotations\Routing\Annotations\Annotations\Annotation`_)
465466

466467
Then, in your annotations service provider, override the `addRoutingAnnotations( RouteScanner $scanner )` method, and register your routing annotations namespace:
467468

468469
```php
469470
<?php namespace App\Providers;
470471

471-
use Collective\Annotations\Routing\Annotations\Scanner as RouteScanner;
472+
use Collective\Annotations\Routing\Scanner as RouteScanner;
473+
# For version 8.0 and older use this instead of the above:
474+
# use Collective\Annotations\Routing\Annotations\Scanner as RouteScanner;
472475

473476
/* ... then, in the class definition ... */
474477

@@ -483,7 +486,7 @@ use Collective\Annotations\Routing\Annotations\Scanner as RouteScanner;
483486
}
484487
```
485488

486-
Your annotation classes must must have the `@Annotation` class annotation (see the following example).
489+
Your annotation classes must have the `@Annotation` class annotation (see the following example).
487490

488491
There is an equivalent method for event annotations: `addEventAnnotations( EventScanner $scanner )`.
489492

@@ -496,7 +499,9 @@ In a namespace - in this example, `App\Annotations`:
496499
```php
497500
<?php namespace App\Http\Annotations;
498501

499-
use Collective\Annotations\Routing\Annotations\Annotations\Annotation;
502+
use Collective\Annotations\Routing\Meta;
503+
# For version 8.0 and older use this instead of the above:
504+
# use Collective\Annotations\Routing\Annotations\Annotations\Annotation;
500505
use Collective\Annotations\Routing\Annotations\MethodEndpoint;
501506
use ReflectionMethod;
502507

0 commit comments

Comments
 (0)