Download the PHP package barryvdh/laravel-ide-helper without Composer

On this page you can find all versions of the php package barryvdh/laravel-ide-helper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-ide-helper

IDE Helper Generator for Laravel

Tests Packagist License Latest Stable Version Total Downloads Fruitcake

Complete PHPDocs, directly from the source

This package generates helper files that enable your IDE to provide accurate autocompletion. Generation is done based on the files in your project, so they are always up-to-date.

The 3.x branch supports Laravel 10 and 11. For older version, use the 2.x releases.

Installation

Require this package with composer using the following command:

[!NOTE]
If you encounter version conflicts with doctrine/dbal, please try: composer require --dev barryvdh/laravel-ide-helper --with-all-dependencies

This package makes use of Laravels package auto-discovery mechanism, which means if you don't install dev dependencies in production, it also won't be loaded.

If for some reason you want manually control this:

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

Usage

Check out this Laracasts video for a quick introduction/explanation!

Note: You do need CodeComplice for Sublime Text: https://github.com/spectacles/CodeComplice

Automatic PHPDoc generation for Laravel Facades

You can now re-generate the docs yourself (for future updates)

Note: bootstrap/compiled.php has to be cleared first, so run php artisan clear-compiled before generating.

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.

You can configure your composer.json to do this each time you update your dependencies:

You can also publish the config file to change implementations (ie. interface to specific class) or set defaults for --helpers.

The generator tries to identify the real class, but if it cannot be found, you can define it in the config file.

Some classes need a working database connection. If you do not have a default working connection, some facades will not be included. You can use an in-memory SQLite driver by adding the -M option.

If you use real-time facades in your app, those will also be included in the generated file using a @mixin annotation and extending the original class underneath the facade.

Note: this feature uses the generated real-time facades files in the storage/framework/cache folder. Those files are generated on-demand as you use the real-time facade, so if the framework has not generated that first, it will not be included in the helper file. Run the route/command/code first and then regenerate the helper file and this time the real-time facade will be included in it.

You can choose to include helper files. This is not enabled by default, but you can override it with the --helpers (-H) option. The Illuminate/Support/helpers.php is already set up, but you can add/remove your own files in the config file.

Automatic PHPDoc generation for macros and mixins

This package can generate PHPDocs for macros and mixins which will be added to the _ide_helper.php file.

But this only works if you use type hinting when declaring a macro.

Automatic PHPDocs for models

If you don't want to write your properties yourself, you can use the command php artisan ide-helper:models to generate PHPDocs, based on table columns, relations and getters/setters.

Note: this command requires a working database connection to introspect the table of each model

By default, you are asked to overwrite or write to a separate file (_ide_helper_models.php). You can write the comments directly to your Model file, using the --write (-W) option, or force to not write with --nowrite (-N).

Alternatively using the --write-mixin (-M) option will only add a mixin tag to your Model file, writing the rest in (_ide_helper_models.php). The class name will be different from the model, avoiding the IDE duplicate annoyance.

Please make sure to back up your models, before writing the info.

Writing to the models should keep the existing comments and only append new properties/methods. It will not update changed properties/methods.

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

With the --write-mixin (-M) option

Model Directories

By default, models in app/models are scanned. The optional argument tells what models to use (also outside app/models).

You can also scan a different directory, using the --dir option (relative from the base path):

You can publish the config file (php artisan vendor:publish) and set the default directories.

Ignore Models

Models can be ignored using the --ignore (-I) option

Or can be ignored by setting the ignored_models config

Magic where* methods

Eloquent allows calling where<Attribute> on your models, e.g. Post::whereTitle(…) and automatically translates this to e.g. Post::where('title', '=', '…').

If for some reason it's undesired to have them generated (one for each column), you can disable this via config write_model_magic_where and setting it to false.

Magic *_count properties

You may use the ::withCount method to count the number results from a relationship without actually loading them. Those results are then placed in attributes following the <columname>_count convention.

By default, these attributes are generated in the phpdoc. You can turn them off by setting the config write_model_relation_count_properties to false.

Generics annotations

Laravel 9 introduced generics annotations in DocBlocks for collections. PhpStorm 2022.3 and above support the use of generics annotations within @property and @property-read declarations in DocBlocks, e.g. Collection<User> instead of Collection|User[].

These can be disabled by setting the config use_generics_annotations to false.

Support @comment based on DocBlock

In order to better support IDEs, relations and getters/setters can also add a comment to a property like table columns. Therefore a custom docblock @comment is used:

Dedicated Eloquent Builder methods

A new method to the eloquent models was added called newEloquentBuilder Reference where we can add support for creating a new dedicated class instead of using local scopes in the model itself.

If for some reason it's undesired to have them generated (one for each column), you can disable this via config write_model_external_builder_methods and setting it to false.

Custom Relationship Types

If you are using relationships not built into Laravel you will need to specify the name and returning class in the config to get proper generation.

Found relationships will typically generate a return value based on the name of the relationship.

If your custom relationships don't follow this traditional naming scheme you can define its return type manually. The available options are many and morphTo.

Model Hooks

If you need additional information on your model from sources that are not handled by default, you can hook in to the generation process with model hooks to add extra information on the fly. Simply create a class that implements ModelHookInterface and add it to the model_hooks array in the config:

The run method will be called during generation for every model and receives the current running ModelsCommand and the current Model, e.g.:

Automatic PHPDocs generation for Laravel Fluent methods

If you need PHPDocs support for Fluent methods in migration, for example

After publishing vendor, simply change the include_fluent line in your config/ide-helper.php file into:

Then run php artisan ide-helper:generate, you will now see all Fluent methods recognized by your IDE.

Auto-completion for factory builders

If you would like the factory()->create() and factory()->make() methods to return the correct model class, you can enable custom factory builders with the include_factory_builders line in your config/ide-helper.php file. Deprecated for Laravel 8 or latest.

For this to work, you must also publish the PhpStorm Meta file (see below).

PhpStorm Meta for Container instances

It's possible to generate a PhpStorm meta file to add support for factory design pattern. For Laravel, this means we can make PhpStorm understand what kind of object we are resolving from the IoC Container. For example, events will return an Illuminate\Events\Dispatcher object, so with the meta file you can call app('events') and it will autocomplete the Dispatcher methods.

Note: You might need to restart PhpStorm and make sure .phpstorm.meta.php is indexed.

Note: When you receive a FatalException: class not found, check your config (for example, remove S3 as cloud driver when you don't have S3 configured. Remove Redis ServiceProvider when you don't use it).

You can change the generated filename via the config meta_filename. This can be useful for cases where you want to take advantage of PhpStorm's support of the directory .phpstorm.meta.php/: all files placed there are parsed, should you want to provide additional files to PhpStorm.

License

The Laravel IDE Helper Generator is open-sourced software licensed under the MIT license


All versions of laravel-ide-helper with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-json Version *
barryvdh/reflection-docblock Version ^2.1.1
composer/class-map-generator Version ^1.0
illuminate/console Version ^10 || ^11
illuminate/database Version ^10.38 || ^11
illuminate/filesystem Version ^10 || ^11
illuminate/support Version ^10 || ^11
nikic/php-parser Version ^4.18 || ^5
phpdocumentor/type-resolver Version ^1.1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package barryvdh/laravel-ide-helper contains the following files

Loading the files please wait ....