Reputation: 1147
I wonder what is the best way (or at least a good one) to import some Composer libraries into a PyroCMS app, and especially in a module.
I know Phil Sturgeon already proposed a method for CodeIgniter, and PyroCMS is built on top of CodeIgniter. http://philsturgeon.co.uk/blog/2012/05/composer-with-codeigniter
But PyroCMS is dropping CI for Laravel, plus PyroCMS brings an extra layer called modules.
I mean, modules should be self-contained, everything in a single folder. That's why I did not follow Phil Sturgeon's article.
This is an example of how I am doing currently:
my_module/
controllers/
models/
views/
libraries/
Lib1.php
Lib2.php
vendor/
composer.json
...
...
When I need to load some Composer package, I add this in my controller:
require_once __DIR__'../libraries/vendor/autoload.php';
In most cases, that would work fine.
But, I had a problem with one particular package, Guzzle
. It could not find the CAcert files or something... Finally, importing Guzzle with a phar
file saved me.
But I'd prefer to only use Composer if possible. So maybe I am wrong in the way I load the packages. Maybe Composer should not be placed here?
Keep in mind that a module should be able to install itself.
Upvotes: 0
Views: 426
Reputation: 18660
What about if you move to 2.3 release? I'm working with it and it uses composer to handle packages, that's the best. I tried in 2.2.x without success and I leave it to move to 2.3/dev. Try it!!
Upvotes: 1