Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 540
IoC Avatar asked Jul 12 '16 08:07

IoC


3 Answers

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.

like image 94
geckob Avatar answered Nov 14 '22 23:11

geckob


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.

like image 44
OLASEYO OLUMIDE Avatar answered Nov 14 '22 23:11

OLASEYO OLUMIDE


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.

like image 38
vsharper Avatar answered Oct 08 '22 10:10

vsharper