laravel-ide-helper
laravel-ide-helper copied to clipboard
Mixin Information Provided by Packages
The Laravel Idea plugin recently added support for packages to register mixins to existing Laravel classes that can't use the simple mixin methods (as the underlying driver needs to be replaced). With this new feature packages can finally enable autocomplete and proper jump-to-code functionality where it was impossible until now.
It would be nice if the IDE helper could support this json file or invent their own configuration file. Packages would then place this config at the root dir and the meta file generation would merge their information. The configuration file for my Laravel PostgreSQL driver for example looks like this:
{
"$schema": "https://laravel-ide.com/schema/laravel-ide-v2.json",
"helperCode": {
"classMixins": [
{
"classFqn": "Illuminate\\Contracts\\Database\\Query\\Builder",
"mixinFqn": "Tpetry\\PostgresqlEnhanced\\Query\\Builder"
},
{
"classFqn": "Illuminate\\Database\\Query\\Builder",
"mixinFqn": "Tpetry\\PostgresqlEnhanced\\Query\\Builder"
},
{
"classFqn": "Illuminate\\Database\\Schema\\Blueprint",
"mixinFqn": "Tpetry\\PostgresqlEnhanced\\Schema\\Blueprint"
},
{
"classFqn": "Illuminate\\Database\\Schema\\ColumnDefinition",
"mixinFqn": "Tpetry\\PostgresqlEnhanced\\Schema\\ColumnDefinition"
},
{
"classFqn": "Illuminate\\Database\\Schema\\IndexDefinition",
"mixinFqn": "Tpetry\\PostgresqlEnhanced\\Schema\\IndexDefinition"
},
{
"classFqn": "Illuminate\\Support\\Facades\\Schema",
"mixinFqn": "Tpetry\\PostgresqlEnhanced\\Support\\Facades\\Schema"
}
]
}
}
All these mixins are currently impossible for e.g. Eloquent drivers/packages as they need to replace the existing driver instead of just exexuting QueryBuilder::mixin
. And there is even no way currently no way to extend the IndexDefinition
class with mixin methods. But with custom drivers it is possible but then auto-suggest is lost.