phpstorm Dynamically creating an external library
Answered
How to include an external library in phpstorm?
I tried this
Path path = getOrCreateVersionPath(version);
LibraryTable table = LibraryTablesRegistrar.getInstance().getLibraryTable(project);
Library library = table.getLibraryByName(LIB_NAME);
if (library == null) {
library = LibraryUtil.createLibrary(table, LIB_NAME);
}
Library.ModifiableModel model = library.getModifiableModel();
model.addRoot(VfsUtil.getUrlForLibraryRoot(path), OrderRootType.CLASSES);
model.commit();
This works in IDEA, but doesn't work in phpstorm
For phpstorm, it works like this
<extensions defaultExtensionNs="com.jetbrains.php">
<libraryRoot id="mylib" runtime="false" path="/src" />
</extensions>
But I need to dynamically change source versions depending on user settings
Please sign in to leave a comment.
Hi, Prihod! We have a set of API to allow to add libraries from plugins, please check out `com.jetbrains.php.config.library.PhpLibraryRoot`, `com.jetbrains.php.config.library.PhpLibraryRoot#EP_NAME`, `com.jetbrains.php.config.library.PhpLibraryRootProvider`. This should help to achieve what you need!
If I use
the files are not visible in “External Libraries”, although they are indexed.
I did it like this