简体   繁体   中英

Installing github package into Laravel project using composer

I need to install custom packages from github url using composer. My Laravel 5.2 based project is clean and fresh install.

The github project I need is: https://github.com/cmcdonaldca/ohShopify.php

I am still new to Laravel and composer and need help with clear steps as much as possible.

Any help?

I am going to use this repo to explain the steps. The reasons is because the repo you includes do not have composer.json which I don't think possible to install using composer in that case

  1. Add repositories in composer.json

    "repositories": [ { "url": "https://github.com/notmaintained/shopify.php", "type": "git" } ],
  2. Add the package name in require with the branch name after the dev :

     "sandeepshetty/shopify.php" : "dev-master"

EDIT:

Just tested this. There are some error since it was unmaintained package but you should get the idea of installing composer package using git.

An improvement to the answer above.

  1. Add repositories in composer.json

    "repositories": [ { "url": "https://github.com/notmaintained/shopify.php", "type": "git" } ],
  2. Add the package name in require with the branch name after the dev:

     "sandeepshetty/shopify.php" : "dev-master"

The package name is sometimes mistaken with the username/repo name. Always open the composer.json file to get the actual packcage name. I spent great deal of time looking around.

Composer uses packages from the repository https://packagist.org/ . You can't really just use github packages directly from github.

You have 2 options here.

  1. Use a package available on https://packagist.org/ to integrate with the shopify API. I've had a look on packagist and found rocket-code/shopify and phpish/shopify . To add them to your laravel project, in the folder that contains the composer.json file use the following command:

    composer require rocket-code/shopify

  2. You could create your own packagist package using the git repository. so you'll clone the repo and then create your own packagist account. So sign up, get a packagist account, upload the file and then require it in your laravel project.

I suggest that you use an existing composer package, as it takes away the responsibility of managing your own package.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM