I'd like to develop Joomla components with VS Code. With PHP Intelephense enabled, all my file show errors because I use Joomla classes and functions. (And it would also be convenient to have auto complete for Joomla functions)
To solve the same problem with WordPress, one can just add wordpress
to the intelephense.stubs
array in the settings. Unfortunately there are no stubs for Joomla, but it is possible to add your own stub files.
Is there a way to generate a stubs file for Joomla, or does it already exist and can be downloaded?
Additional remark
I develop the extension in a separate directory, so I have all of the files in one place and the editor and git is not cluttered with the Joomla files. Therefore the editor doesn't see the Joomla classes and functions.
The setting intelephense.environment.includePaths
seems to be a solution for this issue.
But I'm still wondering if there is a way to do via the stubs approach (the way it's solved for WordPress), so I don't have to add the includePaths
for every project.
Update
Running build/stubGenerator.php
script results in this error (on Linux)
Error: Failed to start application: Class Joomla\CMS\Filesystem\Support\StringController does not exist%
If I change the file name of ./joomla-cms-staging/libraries/src/Filesystem/Support/Stringcontroller.php
to StringController.php
, the script finishes without an error. But the generated file (stubs.php
) doesn't appear to be complete (at least to me). Every entry looks like this (total of 1877 lines):
/**
* @deprecated 5.0 Use Joomla\... instead.
*/
class ... extends Joomla\... {}