Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mixin Information Provided by Packages #1529

Open
tpetry opened this issue Feb 26, 2024 · 2 comments
Open

Mixin Information Provided by Packages #1529

tpetry opened this issue Feb 26, 2024 · 2 comments

Comments

@tpetry
Copy link

tpetry commented Feb 26, 2024

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.

@tpetry tpetry changed the title Autocomplete Information Provided by Packages Mixin Information Provided by Packages Feb 26, 2024
@mfn
Copy link
Collaborator

mfn commented Feb 26, 2024

But how would ide-helper do this? Can you give an example how you imagine ide-helper helps here?

@tpetry
Copy link
Author

tpetry commented Feb 26, 2024

The IDE helper would (additionally to its normal work) scan the root directory of each installed package in the vendors package. When it finds an ide-helper.json file (this is the current name by the Laravel Idea plugin) it evaluates the information. It would then write (for example) a Builder class in _ide_helper.php file the methods it found in Illuminate\\Contracts\\Database\\Query\\Builder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants