Skip to content

Commit 2a41415

Browse files
authored
Add TLDR section, update options (#1639)
1 parent a7fc73e commit 2a41415

File tree

1 file changed

+20
-35
lines changed

1 file changed

+20
-35
lines changed

README.md

+20-35
Original file line numberDiff line numberDiff line change
@@ -33,42 +33,27 @@ Require this package with composer using the following command:
3333
composer require --dev barryvdh/laravel-ide-helper
3434
```
3535

36-
> [!NOTE]
37-
> If you encounter version conflicts with doctrine/dbal, please try:
38-
> `composer require --dev barryvdh/laravel-ide-helper --with-all-dependencies`
39-
40-
This package makes use of [Laravels package auto-discovery mechanism](https://medium.com/@taylorotwell/package-auto-discovery-in-laravel-5-5-ea9e3ab20518), which means if you don't install dev dependencies in production, it also won't be loaded.
41-
42-
If for some reason you want manually control this:
43-
- add the package to the `extra.laravel.dont-discover` key in `composer.json`, e.g.
44-
```json
45-
"extra": {
46-
"laravel": {
47-
"dont-discover": [
48-
"barryvdh/laravel-ide-helper"
49-
]
50-
}
51-
}
52-
```
53-
- Add the following class to the `providers` array in `config/app.php` (`bootstrap/providers.php` for Laravel 11+):
54-
```php
55-
Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class,
56-
```
57-
If you want to manually load it only in non-production environments, instead you can add this to your `AppServiceProvider` with the `register()` method:
58-
```php
59-
public function register()
60-
{
61-
if ($this->app->isLocal()) {
62-
$this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class);
63-
}
64-
// ...
65-
}
66-
```
67-
68-
> Note: Avoid caching the configuration in your development environment, it may cause issues after installing this package; respectively clear the cache beforehand via `php artisan cache:clear` if you encounter problems when running the commands
6936

7037
## Usage
7138

39+
### TL;DR
40+
41+
Run this to generate autocompletion for Facades. This creates _ide_helper.php
42+
43+
```
44+
php artisan ide-helper:generate
45+
```
46+
47+
Run this to add phpdocs for your models. Add -RW to Reset existing phpdocs and Write to the models directly.
48+
```
49+
php artisan ide-helper:models -RW
50+
```
51+
52+
If you don't want the full _ide_helper.php file, you can run add `--write-eloquent-helper` to the model command to generate small version, which is required for the `@mixin \Eloquent` to be able to add the QueryBuilder methods.
53+
54+
If you don't want to add all the phpdocs to your Models directly, you can use `--nowrite` to create a seperate file. The `--write-mixin` option can be used to only add a `@mixin` to your models, but add the generated phpdocs in a seperate file. This avoids having the results marked as duplicate.
55+
56+
7257
_Check out [this Laracasts video](https://laracasts.com/series/how-to-be-awesome-in-phpstorm/episodes/15) for a quick introduction/explanation!_
7358

7459
- `php artisan ide-helper:generate` - [PHPDoc generation for Laravel Facades ](#automatic-phpdoc-generation-for-laravel-facades)
@@ -86,8 +71,6 @@ You can now re-generate the docs yourself (for future updates)
8671
php artisan ide-helper:generate
8772
```
8873

89-
> Note: `bootstrap/compiled.php` has to be cleared first, so run `php artisan clear-compiled` before generating.
90-
9174
This will generate the file `_ide_helper.php` which is expected to be additionally parsed by your IDE for autocomplete. You can use the config `filename` to change its name.
9275

9376
You can configure your `composer.json` to do this each time you update your dependencies:
@@ -149,6 +132,8 @@ The class name will be different from the model, avoiding the IDE duplicate anno
149132

150133
> Please make sure to back up your models, before writing the info.
151134
135+
> You need the _ide_helper.php file to add the QueryBuilder methods. You can add --write-eloquent-helper/-E to generate a minimal version. If this file does not exist, you will be prompted for it.
136+
152137
Writing to the models should keep the existing comments and only append new properties/methods. It will not update changed properties/methods.
153138

154139
With the `--reset (-R)` option, the whole existing PHPDoc is replaced, including any comments that have been made.

0 commit comments

Comments
 (0)