In principle, libraries for Joomla are a useful feature. Unfortunately, in practice they have problems stemming from the way Joomla upgrades them. Some aspects of the problems are described at https://issues.joomla.org/tracker/joomla-cms/35083. There is no sign of this issue being resolved.

In fact, the issue appears to be rather worse than described. Because Joomla handles a library upgrade by uninstalling and then installing the library, it becomes extremely difficult to implement an install script. The trouble is that the install script is loaded for the uninstall of the library, but is then loaded again (from a different place, so not recognised by PHP as being the same) for the install of the library. That results in a PHP compile error because the install script is a duplicate class the second time round.

It is possible in a rather messy way to avoid the install script being loaded the first time, but this approach will then result in failure to run the script if Joomla ever resolves the issue.

The issue report linked above suggests that an alternative is to use a "file" extension instead of a library. But file extensions are even less documented than libraries. The description at https://docs.joomla.org/Extension_types_(general_definitions) is sketchy to say the least.

Is there any information available on how to install a set of files? How to determine where they go? Is there a way to autoload classes in the set of files? Can "files" extensions have language files? Is a "files" extension really a viable alternative to a library?

1 Answer 1


To answer your first two questions this is an example of a manifest for installing a file into the /cli directory, from Joomla 3, that should give you a starting point.

    <?xml version="1.0" encoding="UTF-8"?>
    <extension version="3.9" type="file" method="upgrade">
        <description>CLI files for the Inventory component</description>
            <files target="cli">

There is no real 'smarts' about it, it just gets your file(s) or folder(s) into the desired(target="cli") directory. It isn't an extension as such.

I haven't tried this but you could either provide another <files ....> element to put any language files you need into the /language directory or use the standard method to put language files


They would need to be loaded as part of your code in some way as there is no extensions type processing being associated with them to invoke autoloading.

I don't think the <namespace> element would be available or make sense in a Files manifest so you may have to fall back to the Joomla 3 approach of using a Plugin to to register your 'library(s)' for autoloading.

If you are going to create a plugin as suggested above then you can probably use the plugins' manifest to copy your language and library(s) files at the same time.

Without actually testing out the above I think it is possible, but crude. And given your requirements also include install and uninstall processing you would need to test whether that is invoked when installing a Type=File. I don't see why it shouldn't.

Would probably be better to address the issue identified in https://issues.joomla.org/tracker/joomla-cms/35083 and fix the Library installer process.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.