이런저런 IT 이야기
article thumbnail
Published 2020. 6. 27. 23:53
Laravel 프로젝트 설정하기 PHP
반응형

Laravel 은 요즘 가장 인기있는 프레임웍이죠(PHP 필드에서요 ㅋㅋㅋ).  라라벨은 보안 및 데이터베이스 마이그레이션을 강화하면서, 대부분의 프로젝트의 많은 공통 작업을 용이하게 하는것을 목표로 합니다. 그래서 많은 개발자들이 웹사이트를 개발하기 위해 믿을만하고 효과적인 접근방법중 하나를 제공한다고 믿고있습니다. 여기에서는 라라벨을 어떻게 설치하고 Visual Studio Code에서 실행하는지 보여드리도록 하겠습니다.

1) Visual Studio Code 설치하기

Visual Studio Code (VS Code) 를 여기에서 download page. 다운로드 하세요. 자세한 설치 가이드는  here 여기를 참고하시구요. 만약 이미 설치 하셨다면, Skip 하시기 바랍니다.

2) Composer 설치하기

맥환경에서는 다음과 같이 진행하시면 됩니다. 현재 버전을 확인하시면 더욱 좋겠죠.

% brew install composer
% composer --version
Composer version 1.10.8

 

3) 프로젝트 생성하기

Now, you need to create a directory for your new Laravel project. This step might take some time, depending on the speed of your internet. You can create a directory anywhere in your system and then use the command prompt to go to that directory with the following command:

% composer create-project laravel/laravel LavavelTest
Creating a "laravel/laravel" project at "./LavavelTest"
Installing laravel/laravel (v7.12.0)
  - Installing laravel/laravel (v7.12.0): Loading from cache
Created project in /Users/leedev/Desktop/LavavelTest
> @php -r "file_exists('.env') || copy('.env.example', '.env');"
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 97 installs, 0 updates, 0 removals
  - Installing voku/portable-ascii (1.5.2): Downloading (100%)         
  - Installing symfony/polyfill-ctype (v1.17.1): Downloading (100%)         
  - Installing phpoption/phpoption (1.7.4): Downloading (100%)         
  - Installing vlucas/phpdotenv (v4.1.7): Downloading (100%)         
  - Installing symfony/css-selector (v5.1.2): Downloading (100%)         
  - Installing tijsverkoyen/css-to-inline-styles (2.2.2): Downloading (100%)         
  - Installing symfony/polyfill-php80 (v1.17.1): Downloading (100%)         
  - Installing symfony/polyfill-mbstring (v1.17.1): Downloading (100%)         
  - Installing symfony/var-dumper (v5.1.2): Downloading (100%)         
  - Installing symfony/deprecation-contracts (v2.1.2): Downloading (100%)         
  - Installing symfony/routing (v5.1.2): Downloading (100%)         
  - Installing symfony/process (v5.1.2): Downloading (100%)         
  - Installing symfony/polyfill-php72 (v1.17.0): Downloading (100%)         
  - Installing symfony/polyfill-intl-idn (v1.17.1): Downloading (100%)         
  - Installing symfony/mime (v5.1.2): Downloading (100%)         
  - Installing psr/log (1.1.3): Downloading (100%)         
  - Installing symfony/polyfill-php73 (v1.17.1): Downloading (100%)         
  - Installing symfony/http-foundation (v5.1.2): Downloading (100%)         
  - Installing psr/event-dispatcher (1.0.0): Downloading (100%)         
  - Installing symfony/event-dispatcher-contracts (v2.1.2): Downloading (100%)         
  - Installing symfony/event-dispatcher (v5.1.2): Downloading (100%)         
  - Installing symfony/error-handler (v5.1.2): Downloading (100%)         
  - Installing symfony/http-kernel (v5.1.2): Downloading (100%)         
  - Installing symfony/finder (v5.1.2): Downloading (100%)         
  - Installing symfony/polyfill-intl-normalizer (v1.17.1): Downloading (100%)         
  - Installing symfony/polyfill-intl-grapheme (v1.17.1): Downloading (100%)         
  - Installing symfony/string (v5.1.2): Downloading (100%)         
  - Installing psr/container (1.0.0): Downloading (100%)         
  - Installing symfony/service-contracts (v2.1.2): Downloading (100%)         
  - Installing symfony/console (v5.1.2): Downloading (100%)         
  - Installing symfony/polyfill-iconv (v1.17.1): Downloading (100%)         
  - Installing doctrine/lexer (1.2.1): Downloading (100%)         
  - Installing egulias/email-validator (2.1.18): Downloading (100%)         
  - Installing swiftmailer/swiftmailer (v6.2.3): Downloading (100%)         
  - Installing ramsey/collection (1.0.1): Downloading (100%)         
  - Installing brick/math (0.8.15): Downloading (100%)         
  - Installing ramsey/uuid (4.0.1): Downloading (100%)         
  - Installing psr/simple-cache (1.0.1): Downloading (100%)         
  - Installing opis/closure (3.5.5): Downloading (100%)         
  - Installing symfony/translation-contracts (v2.1.2): Downloading (100%)         
  - Installing symfony/translation (v5.1.2): Downloading (100%)         
  - Installing nesbot/carbon (2.35.0): Downloading (100%)         
  - Installing monolog/monolog (2.1.0): Downloading (100%)         
  - Installing league/flysystem (1.0.69): Downloading (100%)         
  - Installing league/commonmark (1.5.1): Downloading (100%)         
  - Installing dragonmantank/cron-expression (v2.3.0): Downloading (100%)         
  - Installing doctrine/inflector (2.0.3): Downloading (100%)         
  - Installing laravel/framework (v7.17.2): Downloading (100%)         
  - Installing fideloper/proxy (4.4.0): Downloading (100%)         
  - Installing asm89/stack-cors (1.3.0): Downloading (100%)         
  - Installing fruitcake/laravel-cors (v1.0.6): Downloading (100%)         
  - Installing ralouphie/getallheaders (3.0.3): Downloading (100%)         
  - Installing psr/http-message (1.0.1): Downloading (100%)         
  - Installing guzzlehttp/psr7 (1.6.1): Downloading (100%)         
  - Installing guzzlehttp/promises (v1.3.1): Downloading (100%)         
  - Installing guzzlehttp/guzzle (6.5.5): Downloading (100%)         
  - Installing dnoegel/php-xdg-base-dir (v0.1.1): Downloading (100%)         
  - Installing nikic/php-parser (v4.5.0): Downloading (100%)         
  - Installing psy/psysh (v0.10.4): Downloading (100%)         
  - Installing laravel/tinker (v2.4.0): Downloading (100%)         
  - Installing scrivo/highlight.php (v9.18.1.1): Downloading (100%)         
  - Installing filp/whoops (2.7.3): Downloading (100%)         
  - Installing facade/ignition-contracts (1.0.0): Downloading (100%)         
  - Installing facade/flare-client-php (1.3.2): Downloading (100%)         
  - Installing facade/ignition (2.0.7): Downloading (100%)         
  - Installing fzaninotto/faker (v1.9.1): Downloading (100%)         
  - Installing hamcrest/hamcrest-php (v2.0.0): Downloading (100%)         
  - Installing mockery/mockery (1.4.0): Downloading (100%)         
  - Installing nunomaduro/collision (v4.2.0): Downloading (100%)         
  - Installing sebastian/version (2.0.1): Downloading (100%)         
  - Installing sebastian/type (1.1.3): Downloading (100%)         
  - Installing sebastian/resource-operations (2.0.1): Downloading (100%)         
  - Installing sebastian/recursion-context (3.0.0): Downloading (100%)         
  - Installing sebastian/object-reflector (1.1.1): Downloading (100%)         
  - Installing sebastian/object-enumerator (3.0.3): Downloading (100%)         
  - Installing sebastian/global-state (3.0.0): Downloading (100%)         
  - Installing sebastian/exporter (3.1.2): Downloading (100%)         
  - Installing sebastian/environment (4.2.3): Downloading (100%)         
  - Installing sebastian/diff (3.0.2): Downloading (100%)         
  - Installing sebastian/comparator (3.0.2): Downloading (100%)         
  - Installing phpunit/php-timer (2.1.2): Downloading (100%)         
  - Installing phpunit/php-text-template (1.2.1): Downloading (100%)         
  - Installing phpunit/php-file-iterator (2.0.2): Downloading (100%)         
  - Installing theseer/tokenizer (1.1.3): Downloading (100%)         
  - Installing sebastian/code-unit-reverse-lookup (1.0.1): Downloading (100%)         
  - Installing phpunit/php-token-stream (3.1.1): Downloading (100%)         
  - Installing phpunit/php-code-coverage (7.0.10): Downloading (100%)         
  - Installing doctrine/instantiator (1.3.1): Downloading (100%)         
  - Installing phpdocumentor/reflection-common (2.2.0): Downloading (100%)         
  - Installing webmozart/assert (1.9.0): Downloading (100%)         
  - Installing phpdocumentor/type-resolver (1.3.0): Downloading (100%)         
  - Installing phpdocumentor/reflection-docblock (5.1.0): Downloading (100%)         
  - Installing phpspec/prophecy (v1.10.3): Downloading (100%)         
  - Installing phar-io/version (2.0.1): Downloading (100%)         
  - Installing phar-io/manifest (1.0.3): Downloading (100%)         
  - Installing myclabs/deep-copy (1.9.5): Downloading (100%)         
  - Installing phpunit/phpunit (8.5.8): Downloading (100%)         
voku/portable-ascii suggests installing ext-intl (Use Intl for transliterator_transliterate() support)
symfony/var-dumper suggests installing ext-intl (To show region name in time zone dump)
symfony/routing suggests installing symfony/config (For using the all-in-one router or any loader)
symfony/routing suggests installing symfony/yaml (For using the YAML loader)
symfony/routing suggests installing symfony/expression-language (For using expression matching)
symfony/routing suggests installing doctrine/annotations (For using the annotation loader)
symfony/polyfill-intl-idn suggests installing ext-intl (For best performance)
symfony/event-dispatcher suggests installing symfony/dependency-injection
symfony/http-kernel suggests installing symfony/browser-kit
symfony/http-kernel suggests installing symfony/config
symfony/http-kernel suggests installing symfony/dependency-injection
symfony/polyfill-intl-normalizer suggests installing ext-intl (For best performance)
symfony/polyfill-intl-grapheme suggests installing ext-intl (For best performance)
symfony/service-contracts suggests installing symfony/service-implementation
symfony/console suggests installing symfony/lock
egulias/email-validator suggests installing ext-intl (PHP Internationalization Libraries are required to use the SpoofChecking validation)
swiftmailer/swiftmailer suggests installing ext-intl (Needed to support internationalized email addresses)
swiftmailer/swiftmailer suggests installing true/punycode (Needed to support internationalized email addresses, if ext-intl is not installed)
ramsey/uuid suggests installing ext-gmp (Enables faster math with arbitrary-precision integers using GMP.)
ramsey/uuid suggests installing ext-uuid (Enables the use of PeclUuidTimeGenerator and PeclUuidRandomGenerator.)
ramsey/uuid suggests installing ramsey/uuid-doctrine (Allows the use of Ramsey\Uuid\Uuid as Doctrine field type.)
ramsey/uuid suggests installing paragonie/random-lib (Provides RandomLib for use with the RandomLibAdapter)
symfony/translation suggests installing symfony/config
symfony/translation suggests installing symfony/yaml
monolog/monolog suggests installing graylog2/gelf-php (Allow sending log messages to a GrayLog2 server)
monolog/monolog suggests installing doctrine/couchdb (Allow sending log messages to a CouchDB server)
monolog/monolog suggests installing ruflin/elastica (Allow sending log messages to an Elastic Search server)
monolog/monolog suggests installing elasticsearch/elasticsearch (Allow sending log messages to an Elasticsearch server via official client)
monolog/monolog suggests installing php-amqplib/php-amqplib (Allow sending log messages to an AMQP server using php-amqplib)
monolog/monolog suggests installing ext-amqp (Allow sending log messages to an AMQP server (1.0+ required))
monolog/monolog suggests installing ext-mongodb (Allow sending log messages to a MongoDB server (via driver))
monolog/monolog suggests installing mongodb/mongodb (Allow sending log messages to a MongoDB server (via library))
monolog/monolog suggests installing aws/aws-sdk-php (Allow sending log messages to AWS services like DynamoDB)
monolog/monolog suggests installing rollbar/rollbar (Allow sending log messages to Rollbar)
monolog/monolog suggests installing php-console/php-console (Allow sending log messages to Google Chrome)
league/flysystem suggests installing league/flysystem-eventable-filesystem (Allows you to use EventableFilesystem)
league/flysystem suggests installing league/flysystem-rackspace (Allows you to use Rackspace Cloud Files)
league/flysystem suggests installing league/flysystem-azure (Allows you to use Windows Azure Blob storage)
league/flysystem suggests installing league/flysystem-webdav (Allows you to use WebDAV storage)
league/flysystem suggests installing league/flysystem-aws-s3-v2 (Allows you to use S3 storage with AWS SDK v2)
league/flysystem suggests installing league/flysystem-aws-s3-v3 (Allows you to use S3 storage with AWS SDK v3)
league/flysystem suggests installing spatie/flysystem-dropbox (Allows you to use Dropbox storage)
league/flysystem suggests installing srmklive/flysystem-dropbox-v2 (Allows you to use Dropbox storage for PHP 5 applications)
league/flysystem suggests installing league/flysystem-cached-adapter (Flysystem adapter decorator for metadata caching)
league/flysystem suggests installing league/flysystem-sftp (Allows you to use SFTP server storage via phpseclib)
league/flysystem suggests installing league/flysystem-ziparchive (Allows you to use ZipArchive adapter)
laravel/framework suggests installing ext-memcached (Required to use the memcache cache driver.)
laravel/framework suggests installing ext-pcntl (Required to use all features of the queue worker.)
laravel/framework suggests installing ext-redis (Required to use the Redis cache and queue drivers (^4.0|^5.0).)
laravel/framework suggests installing aws/aws-sdk-php (Required to use the SQS queue driver, DynamoDb failed job storage and SES mail driver (^3.0).)
laravel/framework suggests installing doctrine/dbal (Required to rename columns and drop SQLite columns (^2.6).)
laravel/framework suggests installing league/flysystem-aws-s3-v3 (Required to use the Flysystem S3 driver (^1.0).)
laravel/framework suggests installing league/flysystem-cached-adapter (Required to use the Flysystem cache (^1.0).)
laravel/framework suggests installing league/flysystem-sftp (Required to use the Flysystem SFTP driver (^1.0).)
laravel/framework suggests installing moontoast/math (Required to use ordered UUIDs (^1.1).)
laravel/framework suggests installing nyholm/psr7 (Required to use PSR-7 bridging features (^1.2).)
laravel/framework suggests installing pda/pheanstalk (Required to use the beanstalk queue driver (^4.0).)
laravel/framework suggests installing pusher/pusher-php-server (Required to use the Pusher broadcast driver (^4.0).)
laravel/framework suggests installing symfony/cache (Required to PSR-6 cache bridge (^5.0).)
laravel/framework suggests installing symfony/filesystem (Required to create relative storage directory symbolic links (^5.0).)
laravel/framework suggests installing symfony/psr-http-message-bridge (Required to use PSR-7 bridging features (^2.0).)
laravel/framework suggests installing wildbit/swiftmailer-postmark (Required to use Postmark mail driver (^3.0).)
guzzlehttp/psr7 suggests installing zendframework/zend-httphandlerrunner (Emit PSR-7 responses)
psy/psysh suggests installing ext-pcntl (Enabling the PCNTL extension makes PsySH a lot happier :))
psy/psysh suggests installing ext-pdo-sqlite (The doc command requires SQLite to work.)
psy/psysh suggests installing hoa/console (A pure PHP readline implementation. You'll want this if your PHP install doesn't already support readline or libedit.)
filp/whoops suggests installing whoops/soap (Formats errors as SOAP responses)
facade/ignition suggests installing laravel/telescope (^3.1)
sebastian/global-state suggests installing ext-uopz (*)
phpunit/php-code-coverage suggests installing ext-xdebug (^2.7.2)
phpunit/phpunit suggests installing phpunit/php-invoker (^2.0.0)
phpunit/phpunit suggests installing ext-xdebug (*)
Writing lock file
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: facade/ignition
Discovered Package: fideloper/proxy
Discovered Package: fruitcake/laravel-cors
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Package manifest generated successfully.
43 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
> @php artisan key:generate --ansi
Application key set successfully.

위와 같이 나와야 정상적으로 설치된것입니다.

만약 아래와 같은 에러가 나왔다면.

아래와 같이 config를 바꾸고 다시 생성하시면 정상적으로 생성 될 것입니다.

% composer config -g repo.packagist composer https://packagist.org
% composer config -g github-protocols https ssh

 

4) Laravel 시작

라라벨은 Artisan가 항상 따라오는 데요. Artisan는  command-line interface (CLI) 입니다. 라라벨의 가장 중요한 요소중에 하나죠.  아까 프로젝트를 생성할때 서버에서 설치가 되었거든요. 그때 Artisan가 자동으로 설치됩니다. 설치를 하실필요가 없어요.

Artisan는 매우 유용한 툴입니다. 앱을 개발하는데 유용한 명령어들을 제공하구요. 기본적으로  명령어를 한번 실행하면 controller와 model, database migration files, providers, events, jobs, form requests, session commands 그리고 custom command도 손쉽게 만들수 있습니다. 라라벨을 실행하기 위해 아래 명령어를 실행하세요.

% php artisan serve
Laravel development server started: http://127.0.0.1:8000

위와 같이 실행되면, 바로 브라우저에서 http://localhost:8000 url을 입력후 들어가보세요.

위와같이 사이트가 나옵니다.

6) Visual Studio Code상에서 생성한 폴더를 열어볼까요?

console에서 해당 폴더경로를 찾아가신후

% code .

치시면 위와 같이 Visual Studio Code가 실행 됩니다.

 

7) 설정

위와 같이 Visual Studio Code상에서 수정이 가능한 상태가 되었다면, 이젠 개발 할 수 있는 환경은 갖춰졌습니다. 이젠 만들어진 App에 Unique App Key를 설정해야하는 부분이 남았습니다. Unique App Key를 만들려면, 아래와 같이 명령어를 실행해야 합니다.

% php artisan key:generate
Application key set successfully.
% cat .env
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:WUWt9s*******************************+irwY=
APP_DEBUG=true
APP_URL=http://localhost

 

자 설정이 모두 마무리 되었습니다.  자세한 설명이 필요하시면 클릭 하세요 here.

여기우 우린 라라벨 설치방법 및 Visual Studio Code 연동 방법을 배웠으며, 웹사이트를 실행하는 법도 배웠습니다. 자 이제 좀더 깊게 들어가 보도록 하겠습니다.

아래는 샘플 프로젝트입니다.

읽어주셔서 감사합니다. 

 

https://github.com/leeyonghe/LaravelTest

 

leeyonghe/LaravelTest

Contribute to leeyonghe/LaravelTest development by creating an account on GitHub.

github.com

 

반응형
profile

이런저런 IT 이야기

@이런저런 IT 이야기

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!

profile on loading

Loading...

검색 태그