PHPackages                             soyhuce/next-ide-helper - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. soyhuce/next-ide-helper

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

soyhuce/next-ide-helper
=======================

Laravel ide helper rebuilt under steroids

2.2.3(11mo ago)4756.2k—1.9%6[6 PRs](https://github.com/Soyhuce/next-ide-helper/pulls)3MITPHPPHP ^8.3CI passing

Since May 15Pushed 1mo ago4 watchersCompare

[ Source](https://github.com/Soyhuce/next-ide-helper)[ Packagist](https://packagist.org/packages/soyhuce/next-ide-helper)[ Docs](https://github.com/soyhuce/next-ide-helper)[ GitHub Sponsors](https://github.com/soyhuce)[ RSS](/packages/soyhuce-next-ide-helper/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (16)Versions (76)Used By (3)

Laravel ide helper rebuilt under steroids
=========================================

[](#laravel-ide-helper-rebuilt-under-steroids)

[![Latest Version on Packagist](https://camo.githubusercontent.com/0955134052330f58bd0166f6495abce3bb38d05c02d1023206af446c601c68fa/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736f79687563652f6e6578742d6964652d68656c7065722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/soyhuce/next-ide-helper)[![GitHub Tests Action Status](https://camo.githubusercontent.com/7a24c14a2eef0bba5c495f98561c423bd1a938f13c50dad3cbcef1268bbfa9f4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f736f79687563652f6e6578742d6964652d68656c7065722f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/soyhuce/next-ide-helper/actions/workflows/run-tests.yml)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/8329eacc10b96ee3fe0d7acd3e1edc8354fdf1d868a73844e7de3e03142cff61/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f736f79687563652f6e6578742d6964652d68656c7065722f7068707374616e2e796d6c3f6272616e63683d6d61696e266c6162656c3d7068707374616e267374796c653d666c61742d737175617265)](https://github.com/soyhuce/next-ide-helper/actions/workflows/phpstan.yml)[![GitHub PHPStan Action Status](https://camo.githubusercontent.com/969e70aac2912d9f34213b74e759b4ada856abe5dc9edb44173794a203ae369f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f736f79687563652f6e6578742d6964652d68656c7065722f7068702d63732d66697865722e796d6c3f6272616e63683d6d61696e266c6162656c3d7068702d63732d6669786572267374796c653d666c61742d737175617265)](https://github.com/soyhuce/next-ide-helper/actions/workflows/php-cs-fixer.yml)[![Total Downloads](https://camo.githubusercontent.com/06a372b33adecf1d149a919052f37e208aabdd675da0493a682c78a7e757dcdb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736f79687563652f6e6578742d6964652d68656c7065722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/soyhuce/next-ide-helper)

This package aims to be an easy extendable ide-helper generator.

It was inspired by the great work of [barryvdh/laravel-ide-helper](https://github.com/barryvdh/laravel-ide-helper).

It provides completion for Eloquent magic (model attributes, scopes, relations, ...), registered macros of Macroable classes, container instances, ...

- [Installation](#installation)
- [Usage](#usage)
    - [Models](#models)
        - [Attributes](#attributes)
        - [Custom Collection](#custom-collection)
        - [Query Builder](#query-builder)
        - [Relations](#relations)
        - [Mixin style helper](#mixin-style-helper)
        - [Eloquent Builders](#eloquent-builders)
        - [Extensions](#extensions)
    - [Macros](#macros)
    - [Phpstorm meta](#phpstorm-meta)
    - [Factories](#factories)
    - [Aliases](#aliases)
    - [Generate all](#generate-all)
    - [Custom application bootstrap](#custom-application-bootstrap)
    - [Custom content in docblock](#custom-content-in-docblock)
- [Contributing](#contributing)
- [License](#license)

Installation
============

[](#installation)

You should install this package using composer :

```
composer require --dev soyhuce/next-ide-helper
```

You may want to publish configuration file :

```
php artisan vendor:publish --tag=next-ide-helper-config
```

You're done !

Usage
=====

[](#usage)

Models
------

[](#models)

The command `php artisan next-ide-helper:models` will generate multiple elements to help your ide understand what you are doing. This package needs you to have access to a migrated database.

It will add docblock to your classes and will create an `_ide_models.php` file. This file **must not** be included but only analyzed by your ide.

### Attributes

[](#attributes)

The command resolves model attributes from the database. They are added to your model class docblock. If the attribute has a cast, the package will cast properly the attribute.

```
/**
 * @property int $id
 * @property string $name
 * @property string $email
 * @property \Illuminate\Support\Carbon|null $email_verified_at
 * @property string $password
 * @property string|null $remember_token
 * @property \Illuminate\Support\Carbon $created_at
 * @property \Illuminate\Support\Carbon $updated_at
 */
class User extends \Illuminate\Database\Eloquent\Model
{
    // ...
    protected $casts = [
        'email_verified_at' => 'datetime',
    ];
}
```

Attribute casting will also work with custom casts :

```
use App\Email;

class EmailCast implements \Illuminate\Contracts\Database\Eloquent\CastsAttributes
{
    public function get($model, $key, $value, $attributes): Email
    {
        return new Email($value);
    }

    // ...
}

class User extends Model
{
    protected $casts = [
        'email' => EmailCast::class,
    ];
}
```

This will produce `@property \App\Email $email`

Note that the type must be defined as return type or in docblock's `@return` of the `get` method.

The command also adds attributes from accessors as read-only properties :

```
/**
 * @property-read string $upper_name
 */
class User extends Model
{
    public function getUpperNameAttribute(): string
    {
        return Str::upper($this->name);
    }
}
```

### Custom collection

[](#custom-collection)

In case your model defines a custom collection, the command will add `all` method on the model's docblock to re-define return type :

```
use \App\Collections\UserCollection;

/**
 * @method static \App\Collections\UserCollection all(array|mixed $columns = ['*'])
 */
class User extends Model
{
    public function newCollection(array $models = []): UserCollection
    {
        return new UserCollection($models);
    }
}
```

### Query Builder

[](#query-builder)

If your model defines a custom Eloquent builder, the command will add some tags on the model docblock.

```
use App\Builder\UserBuilder;
/**
 * @method static \App\Builder\UserBuilder query()
 * @mixin \App\Builder\UserBuilder
 */
class User extends Model
{
    public function newEloquentBuilder($query)
    {
        return new UserBuilder($query);
    }
}
```

It will also add some tags on the builder to help your ide :

- where clauses based on model attributes
- return values for result values

```
use Illuminate\Database\Eloquent\Builder;

/**
 * @method \App\Builder\UserBuilder whereId(int|string $value)
 * @method \App\Builder\UserBuilder whereName(string $value)
 * @method \App\Builder\UserBuilder whereEmail(string $value)
 * @method \App\Builder\UserBuilder whereEmailVerifiedAt(\Illuminate\Support\Carbon|string|null $value)
 * @method \App\Builder\UserBuilder wherePassword(string $value)
 * @method \App\Builder\UserBuilder whereRememberToken(string|null $value)
 * @method \App\Builder\UserBuilder whereCreatedAt(\Illuminate\Support\Carbon|string $value)
 * @method \App\Builder\UserBuilder whereUpdatedAt(\Illuminate\Support\Carbon|string $value)
 * @method \App\User create(array $attributes = [])
 * @method \Illuminate\Database\Eloquent\Collection|\App\User|null find($id, array $columns = ['*'])
 * @method \Illuminate\Database\Eloquent\Collection findMany($id, array $columns = ['*'])
 * @method \Illuminate\Database\Eloquent\Collection|\App\User findOrFail($id, array $columns = ['*'])
 * @method \App\User findOrNew($id, array $columns = ['*'])
 * @method \App\User|null first(array|string $columns = ['*'])
 * @method \App\User firstOrCreate(array $attributes, array $values = [])
 * @method \App\User firstOrFail(array $columns = ['*'])
 * @method \App\User firstOrNew(array $attributes = [], array $values = [])
 * @method \App\User forceCreate(array $attributes = [])
 * @method \Illuminate\Database\Eloquent\Collection get(array|string $columns = ['*'])
 * @method \App\User getModel()
 * @method \Illuminate\Database\Eloquent\Collection getModels(array|string $columns = ['*'])
 * @method \App\User newModelInstance(array $attributes = [])
 * @method \App\User updateOrCreate(array $attributes, array $values = [])
 * @template TModelClass
 * @extends \Illuminate\Database\Eloquent\Builder
 */
class UserBuilder extends Builder
{
}
```

If your model does not define a custom builder, `next-ide-helper:models` will create fake classes in `_ide_models.php`with the docblocks to provides auto-completion.

### Scopes

[](#scopes)

All scopes of your models will be added as method of their builder (in the custom query builder or in `_ide_models.php`) .

```
class User extends Model
{
    public function scopeWhereVerified($query, bool $verified = true): void
    {
        $query->whereNull('email_verified_at', 'and', !$verified);
    }
}
```

[![](docs/model_scope_autocomplete.png)](docs/model_scope_autocomplete.png)

This will produce `@method \App\Builder\UserBuilder whereVerified(bool $verified = true)` on your custom builder.

Note that your ide can complain with `Non-static method 'whereVerified' should not be called statically, but the class has the '__magic' method.` if you just call `User::whereVerified()`. That's why we advise you to use `User::query()->...`.

### Relations

[](#relations)

The models command will also resolve relations of your model and provide a lot of completion helpers.

```
/**
 * @property-read \Illuminate\Database\Eloquent\Collection $posts
 */
class User extends Model
{
    public function posts(): HasMany
    {
        return $this->hasMany(Post::class);
    }
}

class Post extends Model
{
    public function scopeWherePublished($query): void
    {
        return $query->whereNotNull('published_at');
    }
}
```

[![](docs/scope_for_relation_autocomplete.png)](docs/scope_for_relation_autocomplete.png)

Custom builders and custom collections are also correctly resolved by the ide :

[![](docs/collection_for_relation_autocomplete.png)](docs/collection_for_relation_autocomplete.png)

### Larastan friendly tags

[](#larastan-friendly-tags)

In case you use PHPStan or Larastan, you can have more information about the collections defining `models.larastan_friendly` config to `true`.

With this config, you will get the extra tags in you models

```
/**
 * @phpstan-method static \App\Collections\UserCollection all(array|mixed $columns = ['*'])
 */
class User extends Model {}
```

and in your custom builders

```
/**
 * @phpstan-method \Illuminate\Database\Eloquent\Collection|\App\User|null find($id, array $columns = ['*'])
 * @phpstan-method \Illuminate\Database\Eloquent\Collection findMany($id, array $columns = ['*'])
 * @phpstan-method \Illuminate\Database\Eloquent\Collection|\App\User findOrFail($id, array $columns = ['*'])
 * @phpstan-method \Illuminate\Database\Eloquent\Collection get(array|string $columns = ['*'])
 * @phpstan-method \Illuminate\Database\Eloquent\Collection getModels(array|string $columns = ['*'])
 * @template TModelClass
 * @extends \Illuminate\Database\Eloquent\Builder
 */
class UserBuilder extends Builder {}
```

### Mixin style helper

[](#mixin-style-helper)

Instead of adding every tag in the model, this package can add a `@mixin` tag in the model docblock. The mixin will be located in the configured ide helper file.

```
/**
 * @mixin \IdeHelper\App\Models\__User
 */
class User extends \Illuminate\Database\Eloquent\Model
{
    // ...
}
```

To enable this feature, you need to set `models.use_mixin` to `true` in your config file.

You can still have model's attributes added to your model docblock by setting `models.mixin_attributes` to `true`.

```
/**
 * @property int $id
 * @property string $name
 * @property string $email
 * @property \Illuminate\Support\Carbon|null $email_verified_at
 * @property string $password
 * @property string|null $remember_token
 * @property \Illuminate\Support\Carbon $created_at
 * @property \Illuminate\Support\Carbon $updated_at
 * @mixin \IdeHelper\App\Models\__User
 */
class User extends \Illuminate\Database\Eloquent\Model
{
    // ...
}
```

#### PHPStan gotchas

[](#phpstan-gotchas)

While this feature is convenient, it has some drawbacks. We strongly encourage you to define `models.mixin_attributes` to `true` as PHPStan does not read properties from the mixin class.

You may also have analysis errors like `PHPDoc tag @mixin contains unknown class \IdeHelper\App\Models\__User`. To solve this, you can add the following to your `phpstan.neon` file:

```
parameters:
  scanFiles:
    - ide_helper/models.php
```

### Eloquent builders

[](#eloquent-builders)

This package tries to automate as much as possible, but sometimes it cannot guess everything.

When using custom Eloquent builders for your model, it cannot guess if the builder is a specific one (used only for one model) or a generic one (used for multiple models). For the package to understand which builders are generic, you will have to define them in `models.generic_builder` config array.

### Extensions

[](#extensions)

Sometimes, the command cannot resolve or anticipate every way everything are resolved.

That's why this package provides a way to customize some resolution logic adding your custom resolver in `next-ide-helper.models.extensions` config.

Macros
------

[](#macros)

This package provides a `next-ide-helper:macros`. The command resolves all registered macros and generates a `_ide_macros.php` file which provides auto-completion for `Macroable` macros.

For example :

```
use Illuminate\Support\Collection;

Collection::macro('mapToUpper', function(): Collection {
    return $this->map(fn(string $item) => \Illuminate\Support\Str::upper($item));
});
```

Thanks to `_ide_macros.php` file, we have auto-completion for the `mapToUpper` method :

[![](docs/macro_autocomplete.png)](docs/macro_autocomplete.png)

Just like `_ide_models.php`, the `_ide_macros.php` file must not be included but only analyzed by your ide.

Phpstorm meta
-------------

[](#phpstorm-meta)

The command `php artisan next-ide-helper:meta` will generate a `.phpstorm.meta.php` file. It will provide completion for container bindings and some laravel helpers

[![](docs/optional_autocomplete.png)](docs/optional_autocomplete.png)[![](docs/app_autocomplete.png)](docs/app_autocomplete.png)

Factories
---------

[](#factories)

The command `php artisan next-ide-helper:factories` will add docblocks to your factories in order to correctly type some methods. It will also explicit magic methods for model relations.

For example, if you have

```
class User extends Model
{
    public function role(): BelongsTo
    {
        return $this->belongsTo(Role::class);
    }

    public function posts(): HasMany
    {
        return $this->hasMany(Post::class);
    }

    public function newCollection(array $models = [])
    {
        return new UserCollection($models);
    }
}
```

this command will generate the docblock in `UserFactory`:

```
/**
 * @method \App\User createOne($attributes = [])
 * @method \App\User|\App\Collections\UserCollection create($attributes = [], ?\Illuminate\Database\Eloquent\Model $parent = null)
 * @method \App\User makeOne($attributes = [])
 * @method \App\User|\App\Collections\UserCollection make($attributes = [], ?\Illuminate\Database\Eloquent\Model $parent = null)
 * @method \App\User newModel(array $attributes = [])
 * @method \Database\Factories\UserFactory forRole($attributes = [])
 * @method \Database\Factories\UserFactory hasPosts($count = 1, $attributes = [])
 * @extends \Illuminate\Database\Eloquent\Factories\Factory
 */
class UserFactory extends Factory
{
    //
}
```

Aliases
-------

[](#aliases)

Sometimes we don't want to use fully qualified class names but prefer to use Laravel aliases.

The command `php artisan next-ide-helper:aliases` will create a file which can be understood by your ide.

It will then provide auto-completion, syntax hightlight, ... for the aliases defined in your `config/app.php` file as well as the ones defined by the package you use.

Generate all
------------

[](#generate-all)

You can generate all next-ide-helper files using `next-ide-helper:all`.

It will generate for you :

- Models
- Macros
- Phpstorm meta
- Aliases
- Factories (if you are using Laravel 8 class based model factories)

Custom application bootstrap
----------------------------

[](#custom-application-bootstrap)

Sometimes you may want to bootstrap the environment before the command is executed. For example in a multi-tenant multi-database application, you need to bootstrap your tenant connection in order to let this package resolve table columns.

In that case, you just have to create your own bootstrapper and configure the package to use it :

```
class MultitenantBootstrapper implements \Soyhuce\NextIdeHelper\Contracts\Bootstrapper
{
    private Tenancy $tenancy;

    public function __construct(Tenancy $tenancy)
    {
        $this->tenancy = $tenancy;
    }

    public function bootstrap() : void
    {
        $tenant = \App\Tenant::firstOrFail();

        $this->tenancy->connect($tenant);
    }
}
// Note that this code is completely fictive.
```

Now, you just have to add it in you `next-ide-helper.php` config file :

```
'bootstrapper' => \App\Support\MultitenantBootstrapper::class,
```

Your bootstrapper benefits from laravel dependency injection in its constructor.

Custom content in docblock
--------------------------

[](#custom-content-in-docblock)

Some command will reset your docblock. If you want some content not to be erased, you must add a `@generated` tag in the docblock to tell nest-ide-helper where to insert its content.

For exemple,

```
/**
 * Comment that will not be overwritten after docblock generation
 *
 * @author John Doe
 * @package Foo Bar
 * @deprecated since 1.0.0
 * @api
 *
 * @generated
 * [the content generated by next-ide-helper will be inserted here]
 */
class SomeModel extends Model {}
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Bastien Philippe](https://github.com/bastien-phi)
- [Laravel team and all contributors for laravel/vs-code-extension](https://github.com/laravel/vs-code-extension)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

60

—

FairBetter than 99% of packages

Maintenance73

Regular maintenance activity

Popularity43

Moderate usage in the ecosystem

Community23

Small or concentrated contributor base

Maturity86

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 87.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~26 days

Recently: every ~17 days

Total

71

Last Release

335d ago

Major Versions

0.19.4 → 1.0.02024-12-30

1.1.0 → 2.0.02025-03-20

PHP version history (6 changes)0.1.0PHP ^7.4

0.3.0PHP ^7.4|^8.0

0.6.2PHP ^8.0

0.11.0PHP ^8.1

0.16.0PHP ^8.2

1.0.0PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/206cfbf866a463f7e7d1e86946d59b82f4191b9c89f9981fb03eeb264d77af79?d=identicon)[SoyHuCe](/maintainers/SoyHuCe)

---

Top Contributors

[![bastien-phi](https://avatars.githubusercontent.com/u/10199039?v=4)](https://github.com/bastien-phi "bastien-phi (319 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (18 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (12 commits)")[![ElRochito](https://avatars.githubusercontent.com/u/1737307?v=4)](https://github.com/ElRochito "ElRochito (7 commits)")[![zKoz210](https://avatars.githubusercontent.com/u/28255085?v=4)](https://github.com/zKoz210 "zKoz210 (5 commits)")[![edwinvdpol](https://avatars.githubusercontent.com/u/9265514?v=4)](https://github.com/edwinvdpol "edwinvdpol (4 commits)")[![karinarastsinskagia](https://avatars.githubusercontent.com/u/32904307?v=4)](https://github.com/karinarastsinskagia "karinarastsinskagia (1 commits)")

---

Tags

hacktoberfestlaravelphpdoclaravelidephpstormautocompletion

###  Code Quality

TestsPest

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/soyhuce-next-ide-helper/health.svg)

```
[![Health](https://phpackages.com/badges/soyhuce-next-ide-helper/health.svg)](https://phpackages.com/packages/soyhuce-next-ide-helper)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[fumeapp/modeltyper

Generate TypeScript interfaces from Laravel Models

196277.9k](/packages/fumeapp-modeltyper)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[bjuppa/laravel-blog

Add blog functionality to your Laravel project

483.3k2](/packages/bjuppa-laravel-blog)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
