Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i use Composer to install a package without a version (only master)

Tags:

composer-php

I am new to composer and i am trying to install this following lib via the composer update

https://github.com/neitanod/forceutf8

so as i understand my composer.json looks like this

{
    "config": {
        "vendor-dir": "libs/vendor"
    },
    "require": {
        "raven/raven": "0.7.1",
        "monolog/monolog": "1.7.*",
        "smarty/smarty": "3.1.16",
        "forceutf8/forceutf8": "master"
    }
}

Bt for some reason (as i think forceutf8 has no version) its halts with error, all the rest installed correctly, error i get is

Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - The requested package forceutf8/forceutf8 could not be found in any version, there may be a typo in the package na
me.

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.

Read <http://getcomposer.org/doc/articles/troubleshooting.md> for further common problems. 

i tried following version also but no luck still

{
    "config": {
        "vendor-dir": "libs/vendor"
    },
    "name": "career/skillquest",
    "repositories": [
      {
        "type": "vcs",
        "url": "https://github.com/neitanod/forceutf8"
      }
    ],
    "require": 
      {
        "forceutf8/forceutf8": "dev-master",
        "raven/raven": "0.7.1",
        "monolog/monolog": "1.7.*",
        "smarty/smarty": "3.1.16"
      }
}

Issue was it needs to be

"neitanod/forceutf8": "dev-master"

NOT

"forceutf8/forceutf8": "master"
like image 838
mahen3d Avatar asked Feb 11 '14 06:02

mahen3d


People also ask

Does composer install update packages?

composer update will update our dependencies as they are specified in composer. json . Supposing we have actually installed the 2.0. 1 version of the package, running composer update will cause an upgrade of this package (for example to 2.0.

What is composer install -- no Dev?

You can pass the --no-dev flag to the install/update commands to tell Composer that you do not want to install the development dependencies (this will also not do dev-autoload autoloading, as we will see).


Video Answer


1 Answers

First of all, you have the wrong name: forceutf8/forceutf8 Correct name is: neitanod/forceutf8

Composer adds a prefix of "dev-" to every branch name that is not looking like a version number, and a suffix "-dev" to branch names that look like version numbers.

Example: Branch "master" is called "dev-master", branch "feature" is called "dev-feature". Branch "1.0.x" is called "1.0.x-dev".

So this part is wrong:

"require": {
    "raven/raven": "0.7.1",
    "monolog/monolog": "1.7.*",
    "smarty/smarty": "3.1.16",
    "forceutf8/forceutf8": "master"
}

Correct version would be:

"require": {
    "raven/raven": "0.7.1",
    "monolog/monolog": "1.7.*",
    "smarty/smarty": "3.1.16",
    "neitanod/forceutf8": "dev-master"
}

Now requiring branches without tagged versions is not the best thing because these info is quite unstable - any new commit can break things, and it is not that easy to point exactly at the commit you wanted to use. To protect you agains this, Composer by default does not load these development branch, but will only load stable versions. You have to enable loading development versions:

"require": {
    "raven/raven": "0.7.1",
    "monolog/monolog": "1.7.*",
    "smarty/smarty": "3.1.16",
    "neitanod/forceutf8": "dev-master@dev"
}

The "@dev" flag allows to load development versions of the version mentioned (which in this case is a branch, but "1.0.0@dev" would work the same way, allowing all (including dev) versions of 1.0.0, like "1.0.0-alpha", but also the stable "1.0.0").

Note that you could also allow development version for ALL your dependencies by using "minimum-stability", but this is not recommended, because it will load development versions for EVERYTHING according to the version requirement. In your case, you would grab the latest dev version of monolog's 1.7 branch only, but this might be enough to bring a once stable software into a broken state.

like image 61
Sven Avatar answered Oct 17 '22 03:10

Sven