laravel-idea/plugin

[Feature Request]: Add possibility to disable facades aliases generation to _ide_helper_facades.php

Closed this issue ยท 12 comments

Feature Description

Feature Description
Hello.

I have disabled aliases for facades in config/app.php:

'aliases' => [],

But plugin still generates code assists for aliases in _ide_helper_facades.php:

namespace {
    class App extends Illuminate\Support\Facades\App {}
    class Arr extends Illuminate\Support\Arr {}
    ...
}

I think that some people also disable some or all aliases and then receive errors like "Class "Str" not found" when code assist suggests \Str instead of \Illuminate\Support\Str.

I asked about this some time ago (Issue #752) but after recent updates it started to generate helpers again. I think the best solution here will be an option in plugin settings like "Do not generate helper code for global Laravel facades".

Thank you for this great plugin!

I made some changes in aliases fetching just yesterday) I'll try to fix that somehow. Thank you.

It stopped working at least several weeks ago.
Also with Laravel 11, it may be harder to find out really declared Facades, so specific plugin setting for this situation may be easier to implement.

Packages can declare facade aliases by the composer.json "extras" section. You don't want to see them too?)

Yes. Magical global classes is bad for architecture. Actually all magic is bad, but some of it can be tolerated =)

@adelf I can't seem to find the setting for this? Did I misunderstand and this wasn't added as a setting? ๐Ÿ‘€

The reason why I want to disable it is that it will block auto-import of the facades, because the global facade has the same name.

It's not released yet. I hope to do it next week.

Ah that makes sense, thank you. ๐Ÿ‘ You are doing an awesome work!

Fixed in Laravel Idea 8.2

After upgrading to Laravel Idea 8.2, I had to do the following to make it actually work

1 ) Uncheck Laravel -> Helper Code Parameters -> Generate Facades helper code

image

2 ) Manually delete vendor/_laravel_idea/_ide_helper_facades.php

3 ) Regenerate Helper Code

I'm sorry, forgot to say. You can turn off this option, and the facades helper code will be generated without aliases.

image

Thank you for this work :) Really nice for auto import!

@adelf Thank you! Works perfectly!