简体   繁体   中英

Tying composer.json to a specific Laravel 5 SHA

I'm working on an experimental project using the as-yet unreleased Laravel 5. It seems that a recent commit effectively broke things, but rather than wait for the matter to be fixed I'd rather just continue using the development version I know to be working while monitoring the commit log . My current composer.json file looks like this (the relevant snippet):

  "name": "laravel/laravel",   
  "description": "The Laravel Framework.",
  "keywords": ["framework", "laravel"],
  "license": "MIT",
  "type": "project",
  "require": {
    "laravel/framework": "~5.0",    
    "illuminate/html": "~5.0"
  },

I'm trying to do this:

  "name": "laravel/laravel",   
  "description": "The Laravel Framework.",
  "keywords": ["framework", "laravel"],
  "license": "MIT",
  "type": "project",
  "require": {
    "laravel/framework": "~5.0#cd37f40bba5dced6b1c30d313df2e46c5c33a62c",    
    "illuminate/html": "~5.0"
  },

Per the docs Composer supports the ability to bind to a specific SHA however when I run composer update I receive the message:

[UnexpectedValueException]                                 

Could not parse version constraint ~5.0#cd37f40bba5dced6b1c30d313df2e46c5c33a62c: 
Invalid version string "~5.0#cd37f40bba5dced6b1c30d313df2e46c5c33a62c"

Of course, I've tried various variants ( 5.0#... , 5#... , etc) however all yield the same error message. Input appreciated!

You have to use the branch alias instead. You should use 5.0-dev#cd37f40bba5dced6b1c30d313df2e46c5c33a62c as version:

"name": "laravel/laravel",   
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
  "laravel/framework": "5.0-dev#cd37f40bba5dced6b1c30d313df2e46c5c33a62c",    
  "illuminate/html": "~5.0"
},

You can try with:

"laravel/framework": "5.0.x-dev#cd37f40bba5dced6b1c30d313df2e46c5c33a62c",

instead of:

"laravel/framework": "~5.0#cd37f40bba5dced6b1c30d313df2e46c5c33a62c",

and install it using:

composer install --prefer-source

My exact composer.json file was:

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",    
    "require": {
      "laravel/framework": "5.0.x-dev#cd37f40bba5dced6b1c30d313df2e46c5c33a62c",
      "illuminate/html": "~5.0"
    },
    "config": {
        "preferred-install": "dist"
    },
    "minimum-stability": "dev"
}

However you need to notice that during installation the following message is being displayed:

Installing laravel/framework (dev-master cd37f40)
    Cloning cd37f40bba5dced6b1c30d313df2e46c5c33a62c
    cd37f40bba5dced6b1c30d313df2e46c5c33a62c is gone (history was rewritten?), recovered by checking out 5300b9eb19b5aeac8746835558419d274ee21621

so it seems this commit is not available but I'm not composer expert so I may be wrong.

EDIT

I've tried dozens of other settings but each time either it fails or it gets another commit and not the one you want.

Here's the similar question with an answer which helped me:

composer | laravel 5 - Updating dependencies but the framework itself

"require": {
"laravel/framework": "dev-master#49e3c77b518547bb661b1de4fda64a3ae0c5c505",
...
}

Sigh the answer hit me like a bolt of lightning. https://github.com/laravel/laravel/commits/develop are obviously laravel/laravel commits, and not laravel/framework commits.

Even with my ridiculous oversight resolved, it remains unclear to me how one might go about locking to a particular version of laravel/laravel for the time being. There are workarounds to be certain, but I'm looking for the right way, if such a solution exists.

Sorry for the wheel spinning @Wouter and @Marcin, and thanks for your help.

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