Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Composer create-project. Point at specific branch

I have created a fork of the Laravel repo, made some changes to it and renamed the name in the composer file to votemike/laravel. I would now like to create a new project based on this repo and so I'm calling:

composer create-project --prefer-dist votemike/laravel --repository='{"type":"vcs","url":"https://github.com/votemike/laravel"}' testing

However, my terminal then pops up saying Reading composer.json of votemike/laravel (v5.2.23) which gradually decrements. The resulting project then seems to be a normal Laravel project without my changes. I then tried:

composer create-project --prefer-dist votemike/laravel:master --repository='{"type":"vcs","url":"https://github.com/votemike/laravel"}' testing

But that doesn't seem to work either.

Could anyone help me out with the command I need to run? I assume my computer shouldn't be reading every version of the composer file. And can the command be simplified at all?

Thanks,

Michael

like image 216
Votemike Avatar asked Mar 28 '16 17:03

Votemike


1 Answers

Update:

Since this is a custom Composer project, I wonder if you could use the custom create project script that I wrote a blog post about : Composer create project script

You simply drop it at the root of your project, edit it to match, and run it - and it will create a project for you.

I've used it to test my own Composer projects, and I think it could allow you to simply create your custom Laravel projects without having to fight with Composer over versions.

https://gist.github.com/jacmoe/e9e8ed5fd45affb893a8

Edit:

What you need to do is edit this:

BRANCH_NAME=${1:-master}
DEST_DIR=${2:-~/Desktop/newapp}
PACKAGE_NAME=vendor/package

You can probably leave the first ( BRANCH_NAME ) as-is, but do change DEST_DIR and PACKAGE_NAME !

PACKAGE_NAME must match the package name of the composer.json for your modified Laravel source directory.

Notice :

You use this from your locally cloned copy of your fork of Laravel - it works locally - it does not try to find anything on Github or Packagist. It is using the directory you are in (working directory) and will use that to create a project - you can choose where the script will create it.


Original answer:

Off the top of my head:

composer create-project --prefer-dist --stability=dev votemike/laravel

Or, if that doesn't work, try this:

composer create-project --prefer-dist --stability=dev votemike/laravel:dev-master

Alternatively, instead of dev-master , use @dev - or dev-branch ...

The first command should do it, though.

Does your cloned project have any tags? If it doesn't, that would explain why Composer is acting up. Telling it to use dev-master will fix that, because Composer will by default only pull releases (tags following the major.minor.revision scheme).

Edit:

In one of my projects I am using the master branch of a package, using the following entry in my composer.json :

"jacmoe/yii2-tale-jade": "dev-master",

How you get your package into your composer.json is up to you - either manually, or by requiring it using the right version ( like dev-master )

This requires that the composer.json for the project you are trying to require is not using a version field - if it does have one, remove it.

like image 114
jacmoe Avatar answered Sep 30 '22 08:09

jacmoe