What does the different flags of Composer when creating a Laravel project? - laravel

Anyone can tell me the difference between this commands
composer create-project laravel/laravel your-project-name --prefer-dist
composer create-project laravel/laravel your-project-name
composer create-project laravel/laravel your-project-name -dev

From the documentation for composer:
--prefer-dist: Reverse of --prefer-source, composer will install from dist if possible. This can speed up installs substantially on build servers and other use cases where you typically do not run updates of the vendors. It is also a way to circumvent problems with git if you do not have a proper setup.
That means Composer will install the dependencies from the distribution build, instead of the sources.
And for the --dev flag:
--dev: Install packages listed in require-dev.
That means Composer will also install all package dependencies list in require-dev key from your composer.json. The require-dev key are dependences only required for development.
Please, for more information, read the docs regarding Composer CLI: https://getcomposer.org/doc/03-cli.md#create-project

Related

Composer install VS composer install --dev

Is there any differences between "composer install" and "composer install --dev"?
I ran these two commands and get the same packages installed.
As you can read in the documentation, leaving it out and using --dev performs the same action:
--dev: Install packages listed in require-dev (this is the default behavior).

How to install a laravel package from github

I am sorry if this is a newbie question.
Basically,I want to install a laravel package(https://github.com/yovanoc/codetube/).
There is no documentation on how to install it.So i used this command:
composer create-project yavanoc/codetube --prefer-dist myproject
But get this error:
[InvalidArgumentException]
Could not find pacakage yavanoc/codetube with stability stable
I can't use git clone because after that,I will not know how to go on further to complete the installation.It is only composer create-project yavanoc/codetube --prefer-dist myproject command that I know can completely install a a laravel package and since that didn't work,I do not know what to do now.
Thanks.
You're not far off with using the create-project command. It would have worked if the package was on Packagist, the default Composer repository.
Since it's not on Packagist you need to do what the create-project command does yourself. Looking at the documenation it says: "This is the equivalent of doing a git clone/svn checkout followed by a composer install of the vendors." In your case you can do:
git clone https://github.com/yovanoc/codetube.git myproject
cd myproject
composer install

How to install Laravel 4 using composer

When laravel 5 is not yet released, I install Laravel 4 using this command composer create-project laravel/laravel your-project-name --prefer-dist. But now when I use it, It installs laravel 5. I just want to use laravel 4, not yet ready for 5.
I've tried the other answers but doesn't work for me. So here's the command I use.
composer create-project laravel/laravel=4.1.27 your-project-name --prefer-dist
Source :
Installing specific laravel version with composer create-project
UPDATE
Laravel updated the installation docs of 4.* after releasing 5.
composer create-project laravel/laravel {directory} 4.2 --prefer-dist
Source: http://laravel.com/docs/4.2#install-laravel
If nothing specified composer create-project will get the latest stable version. You can change that by just specifying the version you want:
composer create-project laravel/laravel project-name ~4.2.0 --prefer-dist
This will install the latest 4.2.* version of laravel
You should download latest laravel 4.2 release from github - https://github.com/laravel/laravel/releases/tag/v4.2.11
then use composer update to download all relevant packages including latest laravel version
I use Alternate Method.
Docs says Alternate Method
Once Composer is installed, download the 4.2 version https://github.com/laravel/laravel/archive/v4.2.11.zip of the Laravel framework and extract its contents into a directory on your server. Next, in the root of your Laravel application, run the php composer.phar install (or composer install) command to install all of the framework's dependencies. This process requires Git to be installed on the server to successfully complete the installation.
If you want to update the Laravel framework, you may issue the php composer.phar update command.
U can use this
composer create-project laravel/laravel {directory} 4.2 --prefer-dist
replacing {directory} with the actual directory of your project

What does --prefer-dist mean when using create-project to install laravel4?

What does --prefer-dist mean when using create-project to install laravel4?
--prefer-dist: Reverse of --prefer-source; composer will install from dist if possible. This can speed up installs substantially on build servers and other use cases where you typically do not run updates of the vendors. It is also a way to circumvent problems with Git if you do not have a proper setup.

Laravel 4 - Require packages on Laravel install

I looked around for an answer to this question, but couldn't find anything.
Just wondering, is there a way to tell Composer to require additional packages during a laravel 4 installation?
For example:
If I want to always use the Entrust package in all my laravel projects, instead of having to require it every time I create a new laravel project, can I tell my Composer to also require the Entrust package when I run composer create-project laravel/laravel --prefer-dist
Thanks
I'm not aware of such thing in Composer, but you can add require statement to the same command:
composer create-project laravel/laravel --prefer-dist ./ && composer require zizaco/entrust

Resources