My component is using phpExcel library; I put it into /libraries/phpexcel/Classes. This is an independent (and quite big) library, so I thought, that it would be wise to tell the admin where to put it before component installation. And in the install script of the component check the existence of the lib.

I import the library using this code:

//Include PHPExcel classes

Is it the correct way to use an external library?

1 Answer 1


If you're only ever using a library within a single component then there's no reason not to include it in a folder in the component - this is the way that distributed components will generally handle it. That being said, you can put anything you like in the libraries folder and Joomla won't mind, the issue is how you go about loading the classes. Joomla allows you to autoload via prefixes or namespaces like this:


But if you wish to use a composer autoloader for external packages with your component you may be interested in this approach here:

How to add a composer package without modifying the core composer.json file

Hopefully one of these approaches will suit.

  • I added the code I use for importing.
    – user4035
    Commented Feb 4, 2018 at 1:05

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.