Download the PHP package knuckleswtf/scribe-tags2attributes without Composer
On this page you can find all versions of the php package knuckleswtf/scribe-tags2attributes. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download knuckleswtf/scribe-tags2attributes
More information about knuckleswtf/scribe-tags2attributes
Files in knuckleswtf/scribe-tags2attributes
Package scribe-tags2attributes
Short Description Automatically convert most Scribe v3 docblock tags to v4 PHP 8 attributes
License MIT
Homepage http://github.com/knuckleswtf/scribe-tags2attributes
Informations about the package scribe-tags2attributes
Scribe
This package provides a Rector rule to automatically convert most Scribe v3 docblock tags to v4 PHP 8 attributes.
This package will smartly transform the following tags on controller methods to their attribute equivalents:
header,urlParam,queryParam, andbodyParamresponseField,responseandresponseFileapiResource,apiResourceCollection, andapiResourceModeltransformer,transformerCollection, andtransformerModelsubgroupauthenticatedandunauthenticated
It won't transform @group tags or endpoint titles and descriptions (because they can look ugly as attributes).
It will only work on methods in classes. Unfortunately, attributes can't be added to inline (closure) routes in a neat way.
Example:
Usage
- Make sure the minimum PHP version in your
composer.jsonis 8 (ie you should have"php": ">= 8.0"or similar in your"require"section). -
Install this package
-
Run the Rector
initcommand to create arector.phpfile in the root of your project -
Put this in the generated
rector.php(delete whatever's in the file): -
Do a dry run. This will tell Rector to print out the changes that will be made, without actually making them. That way you can inspect and verify that it looks okay. We also recommend doing a
git commit. -
When you're ready, run the command.
- Make sure to add the attribute strategies to your
config/scribe.php:
All done! You can delete the rector.php file and run composer remove knuckleswtf/scribe-tags2attributes.