You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: readme.md
+13-8
Original file line number
Diff line number
Diff line change
@@ -177,12 +177,13 @@ class MailHandler {
177
177
178
178
}
179
179
```
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.
181
181
182
182
```php
183
183
<?php namespace App\Handlers\Events;
184
184
185
-
use App\User;use Collective\Annotations\Events\Attributes\Attributes\Hears;
185
+
use App\User;
186
+
use Collective\Annotations\Events\Attributes\Attributes\Hears;
186
187
187
188
class MailHandler {
188
189
@@ -290,8 +291,6 @@ As well as defining middleware inline in the route definition tags (`@Get`, `@Po
290
291
}
291
292
```
292
293
293
-
294
-
295
294
Or on a whole controller, with the same only/exclude filter syntax that you can use elsewhere in laravel:
296
295
297
296
```php
@@ -460,15 +459,19 @@ This is the equivalent of calling `Route::model('users', 'App\Users')`.
460
459
461
460
<aname="custom-annotations"></a>
462
461
## Custom Annotations
462
+
_Please Note: the namespaces have been updated in version 8.1 in order to allow PHP 8 attribute support._
463
463
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`_)
465
466
466
467
Then, in your annotations service provider, override the `addRoutingAnnotations( RouteScanner $scanner )` method, and register your routing annotations namespace:
467
468
468
469
```php
469
470
<?php namespace App\Providers;
470
471
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;
472
475
473
476
/* ... then, in the class definition ... */
474
477
@@ -483,7 +486,7 @@ use Collective\Annotations\Routing\Annotations\Scanner as RouteScanner;
483
486
}
484
487
```
485
488
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).
487
490
488
491
There is an equivalent method for event annotations: `addEventAnnotations( EventScanner $scanner )`.
489
492
@@ -496,7 +499,9 @@ In a namespace - in this example, `App\Annotations`:
496
499
```php
497
500
<?php namespace App\Http\Annotations;
498
501
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;
500
505
use Collective\Annotations\Routing\Annotations\MethodEndpoint;
0 commit comments