amir9480 / vscode-laravel-extra-intellisense

This extension adds extra autocompletion for laravel projects to VSCode.
https://marketplace.visualstudio.com/items?itemName=amiralizadeh9480.laravel-extra-intellisense
MIT License
3.44k stars 55 forks source link
autocomplete intellisense laravel vscode vscode-extension vscode-for-laravel

Laravel Extra Intellisense

This extension provides Laravel routes, views and ... autocomplete for VSCode.

Autocomplete

Route names and route parameters

Routes

Views and variables

Views

Configs

Configs

Translations and translation parameters

Translations

Laravel mix function

Mix

Validation rules

Validation rules

View sections and stacks

View sections

Env

env

Route Middlewares

Middlewares

Configuration

LaravelExtraIntellisense.customValidationRules:

Your custom validation rules snippets.

Example:

"LaravelExtraIntellisense.customValidationRules": {
    "mobile": "mobile",
    "distance_gt": "distance_gt:${0:1km}"
}

LaravelExtraIntellisense.phpCommand

Command to run PHP codes to interact with your Laravel application.

Default: php -r \"{code}\"

Note: {code} is PHP code generated by extension and should be wrapped with "".

LaravelExtraIntellisense.basePath

Base path of your Laravel application. useful if your Laravel project is not at the root of you project directory.

If the base path starts with . (like ./src) it will be considered a relative path otherwise it will be considered an absolute path.

LaravelExtraIntellisense.basePathForCode

Same as LaravelExtraIntellisense.basePath but this one using for require_once in generated PHP codes.

LaravelExtraIntellisense.viewDirectorySeparator

You also can use / instead of . as directory separator for view autocomplete.

LaravelExtraIntellisense.modelsPaths

Array of paths including your models. (Default: ["app", "app/Models"])

LaravelExtraIntellisense.modelVariables

Variable names that should provide autocomplete with specific model class. Finding variable type (especially in views) is not easy so you need to manually define variable types.

Example: The Following setting provides auto completion each time you type discountedProduct-> with App\Models\Product model attributes.

"LaravelExtraIntellisense.modelVariables": {
    "discountedProduct": "App\\Models\\Product"
}

All camelCase and snake_case of model names provide autocomplete by default. For example productDiscount and product_discount provides member autocomplete from App\Models\ProductDiscount model.

LaravelExtraIntellisense.modelAttributeCase

Change model attribute names case to snake_case, camelCase or default. (Default = default)

LaravelExtraIntellisense.modelAccessorCase

Change model accessor names case to snake_case, camelCase or default. (Default = snake)

LaravelExtraIntellisense.disableBlade

If you want to disable blade directives autocomplete set this to true.

LaravelExtraIntellisense.disableAuth

If you want to disable authorization autocomplete set this to true

LaravelExtraIntellisense.disableErrorAlert

Hide error alerts when extension can't get data from your application.

Sample config to use docker

This is a simple configuration to use via Laradock.

"LaravelExtraIntellisense.phpCommand": "docker exec -w /var/www/your-project -u laradock laradock_workspace_1 php -r \"{code}\"",
"LaravelExtraIntellisense.basePathForCode": "/var/www/your-project"

Another sample for Laravel Sail.

"LaravelExtraIntellisense.basePathForCode": "/var/www/html",
"LaravelExtraIntellisense.phpCommand": "docker-compose exec -w /var/www/html YOUR_SERVICE_NAME php -r \"{code}\""

Default YOUR_SERVICE_NAME for Laravel sail is laravel.test.

It is possible to use this extension with other docker images or even other virtual machines.

Security Note

This extension runs your Laravel application automatically and periodically to get the information needed to provide autocomplete.

So if you have any unknown errors in your log make sure the extension not causing it.

Also if you writing any sensitive code in your service providers, disable the extension temporarily to prevent unwanted application executing.

Release Notes

0.6.x

0.5.x

0.4.x

0.3.x

0.2.x

0.1.x

0.0.x

Recommended extensions

Credits