Laravelで簡単 初めてのプロジェクト作成
何事もはじめてが一番腰が重いもので、一度もやったことがなかったけど、やってみるとこんなに簡単だったのかよ!なんてことが幾らでもある。Laravelにまだ触れてみたことがないよという人も一度プロジェクト作成だけでもしてみると、また世界が変わって見える(かもしれない)。
環境
今回の環境はこちら。
- macOS
- Laravel6 (PHP >= 7.2.0が必要)
- PHP 7.3.11
Laravel6を使用するのは、投稿時点での最新のLTSだった為。(LTSとは「Long Term Support」の略で、長期間アップデートをサポートする安定版ですよということ)参照 : 公式ドキュメント
事前に必要なこと
- PHPがインストール済みである
- composerがインストール済みである
これらの手順が不明な場合は、各自検索を。
プロジェクト作成
バージョンを指定してプロジェクト作成
最新バージョンではないので、バージョンを指定してのプロジェクト作成を行った。「supilog」のところは、プロジェクト名が入る。
※composerがとてもとても古い場合は、差し支えなければ最新にしてから作業するのが吉かも。
composer create-project "laravel/laravel=6.*" supilog
実行結果
% composer create-project "laravel/laravel=6.*" supilog
Creating a "laravel/laravel=6.*" project at "./supilog"
Installing laravel/laravel (v6.20.0)
- Downloading laravel/laravel (v6.20.0)
- Installing laravel/laravel (v6.20.0): Extracting archive
Created project in /private/tmp/supilog
> @php -r "file_exists('.env') || copy('.env.example', '.env');"
Loading composer repositories with package information
Updating dependencies
Lock file operations: 94 installs, 0 updates, 0 removals
- Locking dnoegel/php-xdg-base-dir (v0.1.1)
- Locking doctrine/inflector (2.0.3)
- Locking doctrine/instantiator (1.4.0)
- Locking doctrine/lexer (1.2.1)
- Locking dragonmantank/cron-expression (v2.3.1)
- Locking egulias/email-validator (2.1.25)
- Locking facade/flare-client-php (1.4.0)
- Locking facade/ignition (1.16.16)
- Locking facade/ignition-contracts (1.0.2)
- Locking fakerphp/faker (v1.13.0)
- Locking fideloper/proxy (4.4.1)
- Locking filp/whoops (2.9.2)
- Locking hamcrest/hamcrest-php (v2.0.1)
- Locking laravel/framework (v6.20.16)
- Locking laravel/tinker (v2.6.0)
- Locking league/commonmark (1.5.7)
- Locking league/flysystem (1.1.3)
- Locking league/mime-type-detection (1.7.0)
- Locking mockery/mockery (1.4.3)
- Locking monolog/monolog (2.2.0)
- Locking myclabs/deep-copy (1.10.2)
- Locking nesbot/carbon (2.45.1)
- Locking nikic/php-parser (v4.10.4)
- Locking nunomaduro/collision (v3.2.0)
- Locking opis/closure (3.6.1)
- Locking paragonie/random_compat (v9.99.99)
- Locking phar-io/manifest (2.0.1)
- Locking phar-io/version (3.1.0)
- Locking php-parallel-lint/php-console-color (v0.3)
- Locking php-parallel-lint/php-console-highlighter (v0.5)
- Locking phpdocumentor/reflection-common (2.2.0)
- Locking phpdocumentor/reflection-docblock (5.2.2)
- Locking phpdocumentor/type-resolver (1.4.0)
- Locking phpoption/phpoption (1.7.5)
- Locking phpspec/prophecy (1.12.2)
- Locking phpunit/php-code-coverage (9.2.5)
- Locking phpunit/php-file-iterator (3.0.5)
- Locking phpunit/php-invoker (3.1.1)
- Locking phpunit/php-text-template (2.0.4)
- Locking phpunit/php-timer (5.0.3)
- Locking phpunit/phpunit (9.5.2)
- Locking psr/container (1.0.0)
- Locking psr/log (1.1.3)
- Locking psr/simple-cache (1.0.1)
- Locking psy/psysh (v0.10.6)
- Locking ramsey/uuid (3.9.3)
- Locking scrivo/highlight.php (v9.18.1.6)
- Locking sebastian/cli-parser (1.0.1)
- Locking sebastian/code-unit (1.0.8)
- Locking sebastian/code-unit-reverse-lookup (2.0.3)
- Locking sebastian/comparator (4.0.6)
- Locking sebastian/complexity (2.0.2)
- Locking sebastian/diff (4.0.4)
- Locking sebastian/environment (5.1.3)
- Locking sebastian/exporter (4.0.3)
- Locking sebastian/global-state (5.0.2)
- Locking sebastian/lines-of-code (1.0.3)
- Locking sebastian/object-enumerator (4.0.4)
- Locking sebastian/object-reflector (2.0.4)
- Locking sebastian/recursion-context (4.0.4)
- Locking sebastian/resource-operations (3.0.3)
- Locking sebastian/type (2.3.1)
- Locking sebastian/version (3.0.2)
- Locking swiftmailer/swiftmailer (v6.2.5)
- Locking symfony/console (v4.4.19)
- Locking symfony/css-selector (v5.2.3)
- Locking symfony/debug (v4.4.19)
- Locking symfony/deprecation-contracts (v2.2.0)
- Locking symfony/error-handler (v4.4.19)
- Locking symfony/event-dispatcher (v4.4.19)
- Locking symfony/event-dispatcher-contracts (v1.1.9)
- Locking symfony/finder (v4.4.19)
- Locking symfony/http-client-contracts (v2.3.1)
- Locking symfony/http-foundation (v4.4.19)
- Locking symfony/http-kernel (v4.4.19)
- Locking symfony/mime (v5.2.3)
- Locking symfony/polyfill-ctype (v1.22.1)
- Locking symfony/polyfill-iconv (v1.22.1)
- Locking symfony/polyfill-intl-idn (v1.22.1)
- Locking symfony/polyfill-intl-normalizer (v1.22.1)
- Locking symfony/polyfill-mbstring (v1.22.1)
- Locking symfony/polyfill-php72 (v1.22.1)
- Locking symfony/polyfill-php73 (v1.22.1)
- Locking symfony/polyfill-php80 (v1.22.1)
- Locking symfony/process (v4.4.19)
- Locking symfony/routing (v4.4.19)
- Locking symfony/service-contracts (v2.2.0)
- Locking symfony/translation (v4.4.19)
- Locking symfony/translation-contracts (v2.3.0)
- Locking symfony/var-dumper (v4.4.19)
- Locking theseer/tokenizer (1.2.0)
- Locking tijsverkoyen/css-to-inline-styles (2.2.3)
- Locking vlucas/phpdotenv (v3.6.8)
- Locking webmozart/assert (1.9.1)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 94 installs, 0 updates, 0 removals
- Downloading symfony/polyfill-mbstring (v1.22.1)
- Downloading symfony/var-dumper (v4.4.19)
- Downloading symfony/console (v4.4.19)
- Downloading scrivo/highlight.php (v9.18.1.6)
- Downloading vlucas/phpdotenv (v3.6.8)
- Downloading symfony/routing (v4.4.19)
- Downloading symfony/process (v4.4.19)
- Downloading symfony/polyfill-intl-normalizer (v1.22.1)
- Downloading symfony/polyfill-intl-idn (v1.22.1)
- Downloading symfony/mime (v5.2.3)
- Downloading symfony/http-foundation (v4.4.19)
- Downloading symfony/event-dispatcher-contracts (v1.1.9)
- Downloading symfony/event-dispatcher (v4.4.19)
- Downloading symfony/error-handler (v4.4.19)
- Downloading symfony/http-kernel (v4.4.19)
- Downloading symfony/finder (v4.4.19)
- Downloading symfony/polyfill-iconv (v1.22.1)
- Downloading paragonie/random_compat (v9.99.99)
- Downloading ramsey/uuid (3.9.3)
- Downloading symfony/translation (v4.4.19)
- Downloading nesbot/carbon (2.45.1)
- Downloading laravel/framework (v6.20.16)
- Downloading facade/flare-client-php (1.4.0)
- Downloading facade/ignition (1.16.16)
- Downloading mockery/mockery (1.4.3)
- Downloading php-parallel-lint/php-console-color (v0.3)
- Downloading php-parallel-lint/php-console-highlighter (v0.5)
- Downloading nunomaduro/collision (v3.2.0)
- Downloading phar-io/version (3.1.0)
- Downloading phpunit/phpunit (9.5.2)
- Installing doctrine/inflector (2.0.3): Extracting archive
- Installing doctrine/lexer (1.2.1): Extracting archive
- Installing dragonmantank/cron-expression (v2.3.1): Extracting archive
- Installing symfony/polyfill-php80 (v1.22.1): Extracting archive
- Installing symfony/polyfill-php72 (v1.22.1): Extracting archive
- Installing symfony/polyfill-mbstring (v1.22.1): Extracting archive
- Installing symfony/var-dumper (v4.4.19): Extracting archive
- Installing psr/container (1.0.0): Extracting archive
- Installing symfony/service-contracts (v2.2.0): Extracting archive
- Installing symfony/polyfill-php73 (v1.22.1): Extracting archive
- Installing symfony/console (v4.4.19): Extracting archive
- Installing scrivo/highlight.php (v9.18.1.6): Extracting archive
- Installing psr/log (1.1.3): Extracting archive
- Installing monolog/monolog (2.2.0): Extracting archive
- Installing symfony/polyfill-ctype (v1.22.1): Extracting archive
- Installing phpoption/phpoption (1.7.5): Extracting archive
- Installing vlucas/phpdotenv (v3.6.8): Extracting archive
- Installing symfony/css-selector (v5.2.3): Extracting archive
- Installing tijsverkoyen/css-to-inline-styles (2.2.3): Extracting archive
- Installing symfony/routing (v4.4.19): Extracting archive
- Installing symfony/process (v4.4.19): Extracting archive
- Installing symfony/polyfill-intl-normalizer (v1.22.1): Extracting archive
- Installing symfony/polyfill-intl-idn (v1.22.1): Extracting archive
- Installing symfony/deprecation-contracts (v2.2.0): Extracting archive
- Installing symfony/mime (v5.2.3): Extracting archive
- Installing symfony/http-foundation (v4.4.19): Extracting archive
- Installing symfony/http-client-contracts (v2.3.1): Extracting archive
- Installing symfony/event-dispatcher-contracts (v1.1.9): Extracting archive
- Installing symfony/event-dispatcher (v4.4.19): Extracting archive
- Installing symfony/debug (v4.4.19): Extracting archive
- Installing symfony/error-handler (v4.4.19): Extracting archive
- Installing symfony/http-kernel (v4.4.19): Extracting archive
- Installing symfony/finder (v4.4.19): Extracting archive
- Installing symfony/polyfill-iconv (v1.22.1): Extracting archive
- Installing egulias/email-validator (2.1.25): Extracting archive
- Installing swiftmailer/swiftmailer (v6.2.5): Extracting archive
- Installing paragonie/random_compat (v9.99.99): Extracting archive
- Installing ramsey/uuid (3.9.3): Extracting archive
- Installing psr/simple-cache (1.0.1): Extracting archive
- Installing opis/closure (3.6.1): Extracting archive
- Installing symfony/translation-contracts (v2.3.0): Extracting archive
- Installing symfony/translation (v4.4.19): Extracting archive
- Installing nesbot/carbon (2.45.1): Extracting archive
- Installing league/mime-type-detection (1.7.0): Extracting archive
- Installing league/flysystem (1.1.3): Extracting archive
- Installing league/commonmark (1.5.7): Extracting archive
- Installing laravel/framework (v6.20.16): Extracting archive
- Installing filp/whoops (2.9.2): Extracting archive
- Installing facade/ignition-contracts (1.0.2): Extracting archive
- Installing facade/flare-client-php (1.4.0): Extracting archive
- Installing facade/ignition (1.16.16): Extracting archive
- Installing fakerphp/faker (v1.13.0): Extracting archive
- Installing fideloper/proxy (4.4.1): Extracting archive
- Installing nikic/php-parser (v4.10.4): Extracting archive
- Installing dnoegel/php-xdg-base-dir (v0.1.1): Extracting archive
- Installing psy/psysh (v0.10.6): Extracting archive
- Installing laravel/tinker (v2.6.0): Extracting archive
- Installing hamcrest/hamcrest-php (v2.0.1): Extracting archive
- Installing mockery/mockery (1.4.3): Extracting archive
- Installing php-parallel-lint/php-console-color (v0.3): Extracting archive
- Installing php-parallel-lint/php-console-highlighter (v0.5): Extracting archive
- Installing nunomaduro/collision (v3.2.0): Extracting archive
- Installing webmozart/assert (1.9.1): Extracting archive
- Installing phpdocumentor/reflection-common (2.2.0): Extracting archive
- Installing phpdocumentor/type-resolver (1.4.0): Extracting archive
- Installing phpdocumentor/reflection-docblock (5.2.2): Extracting archive
- Installing sebastian/version (3.0.2): Extracting archive
- Installing sebastian/type (2.3.1): Extracting archive
- Installing sebastian/resource-operations (3.0.3): Extracting archive
- Installing sebastian/recursion-context (4.0.4): Extracting archive
- Installing sebastian/object-reflector (2.0.4): Extracting archive
- Installing sebastian/object-enumerator (4.0.4): Extracting archive
- Installing sebastian/global-state (5.0.2): Extracting archive
- Installing sebastian/exporter (4.0.3): Extracting archive
- Installing sebastian/environment (5.1.3): Extracting archive
- Installing sebastian/diff (4.0.4): Extracting archive
- Installing sebastian/comparator (4.0.6): Extracting archive
- Installing sebastian/code-unit (1.0.8): Extracting archive
- Installing sebastian/cli-parser (1.0.1): Extracting archive
- Installing phpunit/php-timer (5.0.3): Extracting archive
- Installing phpunit/php-text-template (2.0.4): Extracting archive
- Installing phpunit/php-invoker (3.1.1): Extracting archive
- Installing phpunit/php-file-iterator (3.0.5): Extracting archive
- Installing theseer/tokenizer (1.2.0): Extracting archive
- Installing sebastian/lines-of-code (1.0.3): Extracting archive
- Installing sebastian/complexity (2.0.2): Extracting archive
- Installing sebastian/code-unit-reverse-lookup (2.0.3): Extracting archive
- Installing phpunit/php-code-coverage (9.2.5): Extracting archive
- Installing doctrine/instantiator (1.4.0): Extracting archive
- Installing phpspec/prophecy (1.12.2): Extracting archive
- Installing phar-io/version (3.1.0): Extracting archive
- Installing phar-io/manifest (2.0.1): Extracting archive
- Installing myclabs/deep-copy (1.10.2): Extracting archive
- Installing phpunit/phpunit (9.5.2): Extracting archive
76 package suggestions were added by new dependencies, use `composer suggest` to see details.
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: facade/ignition
Discovered Package: fideloper/proxy
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Package manifest generated successfully.
67 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.
表示してみる
# 自分の作成したプロジェクトに移動
cd supilog
# バージョン確認
php artisan -V
# 起動
php artisan serve
ブラウザでアクセス
にアクセスします。
さいごに
プロジェクト作成は想像以上に簡単。というかコマンド打ってただ待っていただけΣ welcomeページもおしゃれで、なかなかテンションあげてくる。Laravel先生、お世話になります。