Hello,

I'm having an issue with the PHP plugin in VSCode by Devsense. I'm using a framework called Adianti Framework and I would like to make the plugin recognize the autoload of my classes without having to import all the Adianti classes manually. However, even after trying to configure the plugin, my framework's classes are still not being recognized by the plugin. I would like to know if there is any way to make the plugin recognize my classes automatically without having to import each one of them manually.

Thank you in advance for your help.

Best regards,

Augusto


    "The framework I'm using, Adianti, already has an autoload configured, so I don't need to manually import its classes, for example 'use Adianti\Database\TTransaction;'. However, if I don't include these imports, Visual Studio Code doesn't recognize the framework's classes, as shown in the attached image. Is there a way to tell Visual Studio Code that I don't need these imports, or to specify the location of the 'lib' folder where these classes are stored, so that the editor can recognize them?"

    AugustoCesardaCostaMarques I see!

    Adianti does an autoload, lookups at its translation table, and creates a class alias in run time. Sadly this can't be handled by the PHP Editor in general, since it does not know that for example TPage is an alias to Adianti\Control\TPage. (the namespace is a part of the class name in PHP, we can't simply ignore it)

    We could implement a "smart" mechanism that would recognize Adianti, but it would take some time for us to do.

    I can suggest two workarounds for now:

    • create a dummy file (for example) .\adianti.stubs.php, and put specific class_alias() in there, i.e.:
        <?php
        class_alias('Adianti\Control\TPage', 'TPage');
        class_alias('Adianti\Widget\Util\TActionLink', 'TActionLink');
        // ...
    • or, just add the use imports to your files. They won't break anything.

    I hope it helps. And we'll look into better support of Adianti in the future update.

    8 days later

    Thank you very much for the support. The Adianti Framework community, which already comprises thousands of developers, is grateful for the solution. We will have a massive migration to DEVSENSE.

      Write a Reply...