Search code examples
laravelcomposer-phplaravel-artisan

Differences between install via artisan and composer


I found that web.config is included when I install Laravel with:

composer create-project --prefer-dist laravel/laravel blog

but not when I install Laravel using the Laravel installer, with:

laravel new blog

(as per https://laravel.com/docs/5.8/installation)

I've subsequently found a few other differences e.g. devDependencies versions in package.json, some config settings in broadcasting.php, cache.php, database.php.

Can anyone explain to me what is responsible for this difference? Is one install method 'better' than the other?

Thanks Chris


Solution

  • The difference between both commands is that the composer command uses packagist to get the latest package from GitHub the first time or a cached version, while laravel new blog downloads a zip file from the Laravel server which has the latest version and uses that. Both commands run the so called 'after install' scripts, creating an environment file and setting the application key.

    When you don't want a cached version but a new one using composer, run composer clear-cache first, to delete the local cache composer creates.

    If you want to see the difference for yourself, compare the composer.json of the base Laravel project (https://www.github.com/laravel/laravel) and the NewCommand.php file in the src directory of the Laravel installer (https://www.github.com/laravel/installer)

    Edit

    After running both commands, the only difference I could really find was the order in which some things are done, but both generate a working system. Fun thing I noticed is that laravel new project comes with a yarn.lock file, but without a readme.md and composer composer create-project vice versa.