1

Requiring a Remote Zip File with Composer — Donat Studios

 2 years ago
source link: https://donatstudios.com/Require-a-Remote-Zip-File-with-Composer
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Require a Remote Zip File with Composer

I previously showed you how to Load a Github Gist with Composer, but sometimes you need to install code that isn't isn't even in a public facing VCS.

I for instance wanted to use a library only distributed by Zip.

It's actually fairly easy! In your composer.json file, you simply add a repositories section to the root. You will want to update the url section to point at the remote zip you intend to load, as well as updating the name and autoload sections. More information on configuring composers autoloader can be found here.

"repositories": [
    {
        "type": "package",
        "package": {
            "name": "dr-que/x-y",
            "version": "master",
            "dist": {
                "type": "zip",
                "url": "http://xyplot.drque.net/Downloads/XY_Plot-1.4.zip",
                "reference": "master"
            },
            "autoload": {
                "classmap": ["."]
            }
        }
    }
]

Then in your require section, add your selected name as follows.

"require": {
    "dr-que/x-y": "dev-master"
}

Then just run composer update and you should be ready to roll!


Comment by: Ed on Aug. 3, 2016

Ed's Gravatar Thanks!

P.S. I also tried to include dr-que, but other lib - http://polynomialregression.drque.net/ :)

Comment by: Jigarius Caesar on May. 8, 2019

Jigarius Caesar's Gravatar Hi. What if I want composer to only get a subfolder from the ZIP? Is that possible? Say, I want "http://xyplot.drque.net/Downloads/XY_Plot-1.4.zip:/dist"

Comment by: Jesse G Donat on May. 8, 2019

Jesse G Donat's Gravatar Not as far as I am aware, however you could simply point the autoloader at the subdirectory.

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK