라라벨을 처음 접하는 분들은 공식문서에 나오는 두가지 방법에 대해서 혼란이 생길 수도 있습니다. 두가지 방법이 어떻게 다른지 알아보도록 하죠.
Update 2020-11-19
라라벨 인스톨러의 최신버전(v4.x)에서는 laravel new와 composer create-project로 만들어지는 프로젝트의 차이가 없어졌습니다.
laravel new로 생성할 경우 composer create-project로 우선 생성 후 퍼미션과 .env파일 그리고 제트스트림 처리까지 해 주기 때문에 신규 프로젝트 생성에는 laravel new를 사용하는 것을 강하게 추천합니다.
아래의 내용은 라라벨 인스톨러 v3.x에 해당되는 내용입니다.
방법 1. laravel new blog
우선 라라벨 공식문서에 나오는 내용을 확인해 보죠:
laravelnewblog
라라벨 인스톨러를 컴포져로 설치한 후 laravel 커맨드를 이용해서 프로젝트를 생성합니다.
어떤 일이 벌어질까요?
라라벨 인스톨러는 매우 단순합니다. 심포니의 커맨드 프레임워크를 베이스로 단 하나의 커맨드만 생성하고 있습니다.
<?php/*** Configure the command options.** @returnvoid*/protectedfunctionconfigure(){$this->setName('new')->setDescription('Create a new Laravel application')->addArgument('name',InputArgument::OPTIONAL)->addOption('dev',null,InputOption::VALUE_NONE,'Installs the latest "development" release')->addOption('auth',null,InputOption::VALUE_NONE,'Installs the Laravel authentication scaffolding')->addOption('force','f',InputOption::VALUE_NONE,'Forces install even if the directory already exists');}
위의 코드로 추론해 볼 수 있는건 커맨드 이름은 new이며, 옵션으로 dev, auth, force를 사용할 수 있습니다.
커맨드에서 laravel help new를 하면 더 많은 옵션이 있으나, 심포니 콘솔 프레임워크에서 제공하는 것으로 라라벨 인스톨러와는 직접적인 연관은 되지 않습니다.
코드에서 묘사된 설명과 같이 dev는 마지막 개발 릴리즈를, auth는 인증 스케폴딩을, force는 이미 설치된 라라벨 프로젝트가 있다고 해서 강제 설치합니다.
<?php
/**
* Download the temporary Zip to the given file.
*
* @param string $zipFile
* @param string $version
* @return $this
*/
protected function download($zipFile, $version = 'master')
{
switch ($version) {
case 'develop':
$filename = 'latest-develop.zip';
break;
case 'auth':
$filename = 'latest-auth.zip';
break;
case 'master':
$filename = 'latest.zip';
break;
}
$response = (new Client)->get('http://cabinet.laravel.com/'.$filename);
file_put_contents($zipFile, $response->getBody());
return $this;
}
composer create-project --prefer-dist laravel/laravel blog
--stability (-s): Minimum stability of package. Defaults to stable.
--prefer-source: Install packages from source when available.
--prefer-dist: Install packages from dist when available.
--repository: Provide a custom repository to search for the package, which will be used instead of packagist. Can be either an HTTP URL pointing to a composer repository, a path to a local packages.json file, or a JSON string which similar to what the repositories key accepts.
--add-repository: Add the repository option to the composer.json.
--dev: Install packages listed in require-dev.
--no-dev: Disables installation of require-dev packages.
--no-scripts: Disables the execution of the scripts defined in the root package.
--no-progress: Removes the progress display that can mess with some terminals or scripts which don't handle backspace characters.
--no-secure-http: Disable the secure-http config option temporarily while installing the root package. Use at your own risk. Using this flag is a bad idea.
--keep-vcs: Skip the deletion of the VCS metadata for the created project. This is mostly useful if you run the command in non-interactive mode.
--remove-vcs: Force-remove the VCS metadata without prompting.
--no-install: Disables installation of the vendors.
--ignore-platform-reqs: ignore php, hhvm, lib-* and ext-* requirements and force the installation even if the local machine does not fulfill these.