Skip to content

Commit 29b2c61

Browse files
committed
Update doc
1 parent c82729a commit 29b2c61

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

README.md

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,16 @@
33

44
This package provides a [Rector](https://github.com/rectorphp/rector) rule to automatically convert most Scribe v3 docblock tags to v4 PHP 8 attributes.
55

6-
This package will smartly transform the following tags to their attribute equivalents:
6+
This package **will** smartly transform the following tags on controller methods to their attribute equivalents:
77

8-
- `header`
9-
- `urlParam`, `queryParam`, and `bodyParam`
10-
- `responseField`
11-
- `response`
12-
- `responseFile`
8+
- `header`, `urlParam`, `queryParam`, and `bodyParam`
9+
- `responseField`, `response` and `responseFile`
1310
- `apiResource`,`apiResourceCollection`, and `apiResourceModel`
1411
- `transformer`, `transformerCollection`, and `transformerModel`
1512
- `subgroup`
1613
- `authenticated` and `unauthenticated`
1714

18-
It won't transform `@group` tags or endpoint titles and descriptions (because they can look ugly as attributes).
15+
It **won't** transform `@group` tags or endpoint titles and descriptions (because they can look ugly as attributes).
1916

2017
It will only work on methods in classes. Unfortunately, attributes can't be added to inline (closure) routes in a neat way.
2118

@@ -39,24 +36,24 @@ Example:
3936
+ #[Subgroup('Getting started', 'Get started doing stuff')]
4037
+ #[Header('Test', 'Value')]
4138
+ #[Response(status: 204, description: '204, Nothing to see here')]
42-
+ #[ResponseFromApiResource('App\Http\Resources\UserResource', 'App\Models\User', collection: true, factoryStates: ['admin'], with: ['sideProjects', 'friends'], simplePaginate: 12)]
39+
+ #[ResponseFromApiResource(UserResource::class, User::class, collection: true, factoryStates: ['admin'], with: ['sideProjects', 'friends'], simplePaginate: 12)]
4340
+ #[ResponseFromFile('responses/not_found.json', status: 404, merge: '{"resource": "user"}', description: '404, User not found')]
4441
public function doSomething()
4542
```
4643

4744
## Usage
48-
- Make sure the minimum PHP version in your `composer.json` is 8.0 (ie you should have `"php": ">= 8.0"` or similar in your `"require"` section).
45+
- Make sure the minimum PHP version in your `composer.json` is 8 (ie you should have `"php": ">= 8.0"` or similar in your `"require"` section).
4946
- Install this package
5047
```sh
5148
composer require knuckleswtf/scribe-tags2attributes --dev
5249
```
5350

54-
- Create a `rector.php` file in the root of your project
51+
- Run the Rector `init` command to create a `rector.php` file in the root of your project
5552
```sh
5653
./vendor/bin/rector init
5754
```
5855

59-
- Put this in the generated `rector.php` (delete whatever's in it):
56+
- Put this in the generated `rector.php` (delete whatever's in the file):
6057
```php
6158
<?php
6259

@@ -68,20 +65,20 @@ Example:
6865
__DIR__ . '/app/Http/Controllers', // <- replace this with wherever your controllers are
6966
]);
7067
$rectorConfig->importNames();
71-
$rectorConfig->rule(Knuckles\Scribe\Docblock2Attributes\RectorRule::class);
68+
$rectorConfig->rule(\Knuckles\Scribe\Tags2Attributes\RectorRule::class);
7269
};
7370
```
7471

7572
- 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`.
7673
```sh
77-
./vendor/bin/rector process --dry-run --clear-cache
74+
./vendor/bin/rector process --dry-run --clear-cache
7875
```
7976

8077
- When you're ready, run the command.
8178
```sh
82-
./vendor/bin/rector process --clear-cache
79+
./vendor/bin/rector process --clear-cache
8380
```
84-
- Finally, make sure to add the attribute strategies to your `config/scribe.php`:
81+
- Make sure to add the attribute strategies to your `config/scribe.php`:
8582
```diff
8683
'strategies' => [
8784
'metadata' => [

0 commit comments

Comments
 (0)