Adding composer.json to package
PermalinkAlso wondering what else do we have to do? Does composer.json get found and read automatically by C5 or do we have to register it somehow? And where will the files actually get put? Do we need to make a /vendor folder or is it automatically created?
Would love to see a How To on this subject is anybody is up for that.
This is for C5.7 btw.
Anything you can add around that part would help. Thanks again and I'll take a shot at this and then add anything I find.
Regarding step 4 and downloading, my only experience is with Windows. I have the Composer system path set for a global install. This allows me to run Composer from any command prompt. I open the folder with the composer.json file, open a command prompt from that folder, and run "composer install".
This looks like a good walk-through for Mac (which I believe is the same for Linux and Unix).
http://blog.teamtreehouse.com/dependency-management-in-php-using-co...
It can be a one time process, where you download it once and are done. The site developer doesn't have to do anything with it.
Optionally, Composer can be used again in the future to update the dependencies to the current version.
I wanted to follow up and see if you were able to get Composer and your library working.
First cd/navigate ( use CMD/Terminal ) to the directory where your composer.json file located, then apply the following commands.
$ curl -shttp://getcomposer.org/installer... | php
$ php composer.phar update
Once you have done, you will get a new directory(vendor) with all dependancies downloaded in it, you can then use the same directory for another project without running composer.
Cheers
First cd/navigate ( use CMD/Terminal ) to the directory where your composer.json file located, then apply the following commands.
$ curl -shttp://getcomposer.org/installer... | php
$ php composer.phar update
Once you have done, you will get a new directory(vendor) with all dependancies downloaded in it, you can then use the same directory for another project without running composer.
Cheers
I've been dealing with the same issue and just got it working.
This is the approach I used successfully.
https://www.concrete5.org/community/forums/5-7-discussion/add-3rdpar...
Here is an example using Stripe PHP -https://github.com/stripe/stripe-php...
1. Install Composer.
https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx...
https://getcomposer.org/doc/00-intro.md#installation-windows...
2. Create a composer.json file in your package root.
3. Open composer.json and paste this code into it to declare your dependencies. The dependencies are available on the project GitHub, Packagist, or project website.
4. Run Composer to download the dependencies.
https://getcomposer.org/doc/00-intro.md#using-composer...
5. Once Composer finishes downloading, you will see a new folder called vendor and a new file called composer.lock.
composer.lock - This file locks the dependencies of your project to a known state. It is a list of the exact versions of the dependencies it installed in the vendor file.
vendor - The vendor folder contains all your dependencies, an autoload.php file, and a composer folder that contains additional autoload files.
6. In your package controller, above the class declaration, require the autoload.php file once.
Now you should be able to create a new Stripe object in local scope and \Stripe object in global scope.
For anyone more experienced with this, If you see an error in my explanation, please reply and correct me.