Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Packages using Composer
  • Hi,

    I would like to create two packages: a PDF and a Barcode package.

    The default library would be TCPDF for each, because TCPDF can generate barcodes as well.

    It would use Composer, so there will be a composer.json in each package folder. The only problem is that TCPDF is about 20 MB and I don't want to force people to download it twice.

    How can I solve this problem. How can I share the same vendor dir for them?
  • All Composer libraries are installed in the same vendor folder.

    I'm pretty sure Composer is smart enough to detect it already has the library and will not download it again.
  • The main point is to have the package fully portable, so I created a composer.json in the package's folder, and not edited the "main" composer.json. This means I have to run composer update on package install.

    But this way I have to have a different folder for all composer.jsons, because composer would simply delet all the packages from the vendor folder which aren't in the actual composer.json

    So the problem is that I need a different vendor folder if I want to use different composer.json, and that is required if I want to make it fully portable.


  • Maybe I don't fully understand the Composer yet.

    I've checked the composer-installer. Actually I don't want to install (yet) these packages, but I want to install their dependencies.
  • In the current Fuel design you can not have a composer.json file in a Fuel Package, since the package is not composer compatible.

    If the package was installed through composer, it would pick up the json file in the package and install any dependencies listed in there, but currently it doesn't.

    You can't have different vendor folders as well, the composer autoloader doesn't work that way.

    So currently the only option is to add the dependencies to the global json file.
  • Actually firstly I tried to have different a vendor folder inside the package and it worked.

    I did not find composer documentation quite understandable, so it was hard to see this whole thing.

    But now I understand it more. Actually adding a repository and using the composer-installers partly solved the problem, however, I had to add the package to the global json.
  • HarroHarro
    Accepted Answer
    Processing the composer.json is recursive.

    First, it will process the main json file in the project root, and install every dependency listed in there. For every dependency installed, it will check after installation if it contains a json file too. If so, it will process the dependencies in that file. And so on.

    All installed packages will end up in the same vendor folder.

    You can only use different installation targets if you run Composer against multiple/unrelated individual json files, or if you use a custom installer (which we're going to use for packages in v2.0).

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion