Install a composer package

14 views
Skip to first unread message

GhiaMar

unread,
Jul 11, 2022, 3:38:49 PM7/11/22
to Joomla! General Development
Hi1 I need to install a composer package for my current J! 4 development, I plan to just run composer in my component admin folder, is that the correct way?

Thanks!

GhiaMar

unread,
Jul 11, 2022, 5:04:24 PM7/11/22
to Joomla! General Development
Well I just figured it out. Steps:

1- Created a new lib folder inside my administrator/components/com_xxxxxx folder
2- In command line cd to that new folder then ran composer require xxxxx/xxxxxxxxx
3- Required the new dependency in file administrator/components/com_xxxxxx/services/provider.php like this:
* @license GNU General Public License version 3, or later
*/

defined('_JEXEC') or die;

require_once JPATH_ADMINISTRATOR . '/components/com_xxxxxx/lib/vendor/autoload.php';

use Joomla\CMS\Component\Router\RouterFactoryInterface;
use Joomla\CMS\Dispatcher\ComponentDispatcherFactoryInterface;
use Joomla\CMS\Extension\ComponentInterface;
...

That's it, I can now use any package installed in administrator/components/com_xxxxxx/lib
Reply all
Reply to author
Forward
0 new messages