rdx / laravelcollective-annotations
Route Annotations for The Laravel Framework.
Installs: 4 149
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 73
Open Issues: 1
Requires
- php: ^8.2
- illuminate/console: ^11.0
- illuminate/filesystem: ^11.0
- illuminate/support: ^11.0
Requires (Dev)
- illuminate/database: ^11.0
- mockery/mockery: ^1.0
- phpunit/phpunit: ^9.0
Replaces
- dev-9.0-fork
- 9.1
- 8.3
- v8.2
- v8.1
- 8.0.x-dev
- dev-master / 8.0.x-dev
- v8.0.2
- v8.0.1
- v8.0
- 7.0.x-dev
- v7.0
- 6.0.x-dev
- v6.0.2
- 6.0.1
- v6.0
- 5.8.x-dev
- v5.8.1
- v5.8
- 5.7.x-dev
- v5.7.1
- v5.7
- 5.6.x-dev
- v5.6.1
- v5.6
- 5.5.x-dev
- v5.5.1
- v5.5
- 5.4.x-dev
- v5.4.3
- v5.4.2
- v5.4.1
- v5.4.0
- 5.3.x-dev
- v5.3.0
- 5.2.x-dev
- v5.2.1
- v5.2
- 5.1.x-dev
- v5.1.2
- v5.1.1
- v5.1.0
- 5.0.x-dev
- v5.0.9
- v5.0.8
- v5.0.7
- v5.0.6
- v5.0.5
- v5.0.4
- v5.0.3
- v5.0.2
- v5.0.1
- v5.0.0
- dev-9.0-fork-tests
- dev-8.0-fork
- dev-8.0-arrayaccess-types
- dev-8.0-laravel9
- dev-8.0-model-binding-pattern
- dev-8.0-scan-models-in-namespace
This package is auto-updated.
Last update: 2025-01-12 01:54:10 UTC
README
This is a laravelcollective/annotations
drop-in replacement
To use this package instead of laravelcollective/annotations
as a perfect drop-in replacement, do
this in your project:
composer require rdx/laravelcollective-annotations
- if your project explicitly required
annotations
:composer remove laravelcollective/annotations
This will install rdx/laravelcollective-annotations
and pretend it IS laravelcollective/annotations
,
and all other packages will believe laravelcollective/annotations
is installed, because Composer is awesome.
UPGRADE to 9.0 (PHP Attributes instead of doctrine/annotations
)
- Download and set up
rector/rector
, see config below. - Add rule
Collective\Annotations\Rector\AnnotationsToAttributesRector
to Rector set. - Run Rector with debug enabled, see command below.
- Manually fix skipped conversions due to complicated annotation syntax, see complicated example below.
- Run your cs fixer to import all FQCN, see
php-cs-fixer
rule below. - Remove
$useAttributes
from yourAnnotationsServiceProvider
, because that doesn't exist anymore.
Example Rector config
return RectorConfig::configure() ->withPaths([ __DIR__ . '/app/Http/Controllers', ]) ->withRules([ AnnotationsToAttributesRector::class, ]) ;
Run Rector command
vendor/bin/rector process -v --debug --no-diffs app/Http/
This will print all analyzed files, and potential errors, and might include WARNING
lines for
skipped methods, like:
WARNING: getPhaseDownload contains unconverted {} properties
Too complicated annotation
@Get("/some/{thing}/download.{ext}", as="thing.download", where={"ext"="json|pdf|xlsx"})
The path isn't a problem, nor the as=
, but the where=
contains another inner structure, and that
won't be converted correctly, so they're broken now, so you have to fix those right after.
php-cs-fixer rule
I assume you have php-cs-fixer
set up. Add this rule temporarily:
[ 'fully_qualified_strict_types' => [ 'import_symbols' => true, 'phpdoc_tags' => [], ], ]
and run fix
only for the Controllers dir:
vendor/bin/php-cs-fixer fix app/Http/Controllers/
This will convert all the Rector added FQCN to imports, but only those, only in the Controllers
dir.
If php-cs-fixer
skips files and complains about "errors reported during linting", the Rector rule
isn't good enough, and something is broken:
Files that were not fixed due to errors reported during linting before fixing:
1) /var/www/myproject/app/Http/Controllers/MyController.php
You'll have to fix those manually.