プロジェクト作成時のバージョン指定
公式サイトに記載されている方法で、バージョンを指定してプロジェクトを作成します。
なお、Laravel10のプロジェクトを作成するには、PHP 8.1以上が必要です。
$composer create-project --prefer-dist laravel/laravel:^10.0 cms_lv
composerを実行すると、時のようなログが表示されます。
composer create-projectの実行ログ
Creating a "laravel/laravel:^10.0" project at "./cms_lv"
Info from https://repo.packagist.org: #StandWithUkraine
Installing laravel/laravel (v10.2.2)
- Downloading laravel/laravel (v10.2.2)
- Installing laravel/laravel (v10.2.2): Extracting archive
Created project in /home/chopin/cms_lv
> @php -r "file_exists('.env') || copy('.env.example', '.env');"
Loading composer repositories with package information
Updating dependencies
Lock file operations: 108 installs, 0 updates, 0 removals
- Locking brick/math (0.11.0)
- Locking dflydev/dot-access-data (v3.0.2)
- Locking doctrine/inflector (2.0.6)
- Locking doctrine/lexer (3.0.0)
- Locking dragonmantank/cron-expression (v3.3.2)
- Locking egulias/email-validator (4.0.1)
- Locking fakerphp/faker (v1.22.0)
- Locking filp/whoops (2.15.2)
- Locking fruitcake/php-cors (v1.2.0)
- Locking graham-campbell/result-type (v1.1.1)
- Locking guzzlehttp/guzzle (7.7.0)
- Locking guzzlehttp/promises (2.0.0)
- Locking guzzlehttp/psr7 (2.5.0)
- Locking guzzlehttp/uri-template (v1.0.1)
- Locking hamcrest/hamcrest-php (v2.0.1)
- Locking laravel/framework (v10.13.1)
- Locking laravel/pint (v1.10.0)
- Locking laravel/sail (v1.22.0)
- Locking laravel/sanctum (v3.2.5)
- Locking laravel/serializable-closure (v1.3.0)
- Locking laravel/tinker (v2.8.1)
- Locking league/commonmark (2.4.0)
- Locking league/config (v1.2.0)
- Locking league/flysystem (3.15.1)
- Locking league/flysystem-local (3.15.0)
- Locking league/mime-type-detection (1.11.0)
- Locking mockery/mockery (1.5.1)
- Locking monolog/monolog (3.3.1)
- Locking myclabs/deep-copy (1.11.1)
- Locking nesbot/carbon (2.67.0)
- Locking nette/schema (v1.2.3)
- Locking nette/utils (v4.0.0)
- Locking nikic/php-parser (v4.15.5)
- Locking nunomaduro/collision (v7.5.2)
- Locking nunomaduro/termwind (v1.15.1)
- Locking phar-io/manifest (2.0.3)
- Locking phar-io/version (3.2.1)
- Locking phpoption/phpoption (1.9.1)
- Locking phpunit/php-code-coverage (10.1.2)
- Locking phpunit/php-file-iterator (4.0.2)
- Locking phpunit/php-invoker (4.0.0)
- Locking phpunit/php-text-template (3.0.0)
- Locking phpunit/php-timer (6.0.0)
- Locking phpunit/phpunit (10.2.0)
- Locking psr/container (2.0.2)
- Locking psr/event-dispatcher (1.0.0)
- Locking psr/http-client (1.0.2)
- Locking psr/http-factory (1.0.2)
- Locking psr/http-message (2.0)
- Locking psr/log (3.0.0)
- Locking psr/simple-cache (3.0.0)
- Locking psy/psysh (v0.11.18)
- Locking ralouphie/getallheaders (3.0.3)
- Locking ramsey/collection (2.0.0)
- Locking ramsey/uuid (4.7.4)
- Locking sebastian/cli-parser (2.0.0)
- Locking sebastian/code-unit (2.0.0)
- Locking sebastian/code-unit-reverse-lookup (3.0.0)
- Locking sebastian/comparator (5.0.0)
- Locking sebastian/complexity (3.0.0)
- Locking sebastian/diff (5.0.3)
- Locking sebastian/environment (6.0.1)
- Locking sebastian/exporter (5.0.0)
- Locking sebastian/global-state (6.0.0)
- Locking sebastian/lines-of-code (2.0.0)
- Locking sebastian/object-enumerator (5.0.0)
- Locking sebastian/object-reflector (3.0.0)
- Locking sebastian/recursion-context (5.0.0)
- Locking sebastian/type (4.0.0)
- Locking sebastian/version (4.0.1)
- Locking spatie/backtrace (1.4.0)
- Locking spatie/flare-client-php (1.3.6)
- Locking spatie/ignition (1.8.0)
- Locking spatie/laravel-ignition (2.1.3)
- Locking symfony/console (v6.3.0)
- Locking symfony/css-selector (v6.3.0)
- Locking symfony/deprecation-contracts (v3.3.0)
- Locking symfony/error-handler (v6.3.0)
- Locking symfony/event-dispatcher (v6.3.0)
- Locking symfony/event-dispatcher-contracts (v3.3.0)
- Locking symfony/finder (v6.3.0)
- Locking symfony/http-foundation (v6.3.0)
- Locking symfony/http-kernel (v6.3.0)
- Locking symfony/mailer (v6.3.0)
- Locking symfony/mime (v6.3.0)
- Locking symfony/polyfill-ctype (v1.27.0)
- Locking symfony/polyfill-intl-grapheme (v1.27.0)
- Locking symfony/polyfill-intl-idn (v1.27.0)
- Locking symfony/polyfill-intl-normalizer (v1.27.0)
- Locking symfony/polyfill-mbstring (v1.27.0)
- Locking symfony/polyfill-php72 (v1.27.0)
- Locking symfony/polyfill-php80 (v1.27.0)
- Locking symfony/polyfill-php83 (v1.27.0)
- Locking symfony/polyfill-uuid (v1.27.0)
- Locking symfony/process (v6.3.0)
- Locking symfony/routing (v6.3.0)
- Locking symfony/service-contracts (v3.3.0)
- Locking symfony/string (v6.3.0)
- Locking symfony/translation (v6.3.0)
- Locking symfony/translation-contracts (v3.3.0)
- Locking symfony/uid (v6.3.0)
- Locking symfony/var-dumper (v6.3.0)
- Locking symfony/yaml (v6.3.0)
- Locking theseer/tokenizer (1.2.1)
- Locking tijsverkoyen/css-to-inline-styles (2.2.6)
- Locking vlucas/phpdotenv (v5.5.0)
- Locking voku/portable-ascii (2.0.1)
- Locking webmozart/assert (1.11.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 108 installs, 0 updates, 0 removals
- Downloading doctrine/lexer (3.0.0)
- Downloading symfony/deprecation-contracts (v3.3.0)
- Downloading symfony/polyfill-php83 (v1.27.0)
- Downloading symfony/http-foundation (v6.3.0)
- Downloading laravel/pint (v1.10.0)
- Downloading symfony/yaml (v6.3.0)
- Downloading symfony/css-selector (v6.3.0)
- Downloading symfony/var-dumper (v6.3.0)
- Downloading symfony/uid (v6.3.0)
- Downloading symfony/routing (v6.3.0)
- Downloading symfony/process (v6.3.0)
- Downloading symfony/mime (v6.3.0)
- Downloading symfony/service-contracts (v3.3.0)
- Downloading symfony/event-dispatcher-contracts (v3.3.0)
- Downloading symfony/event-dispatcher (v6.3.0)
- Downloading egulias/email-validator (4.0.1)
- Downloading symfony/mailer (v6.3.0)
- Downloading symfony/error-handler (v6.3.0)
- Downloading symfony/http-kernel (v6.3.0)
- Downloading symfony/finder (v6.3.0)
- Downloading symfony/string (v6.3.0)
- Downloading symfony/console (v6.3.0)
- Downloading ramsey/collection (2.0.0)
- Downloading symfony/translation-contracts (v3.3.0)
- Downloading symfony/translation (v6.3.0)
- Downloading monolog/monolog (3.3.1)
- Downloading laravel/framework (v10.13.1)
- Downloading nunomaduro/collision (v7.5.2)
- Downloading sebastian/version (4.0.1)
- Downloading sebastian/type (4.0.0)
- Downloading sebastian/recursion-context (5.0.0)
- Downloading sebastian/object-reflector (3.0.0)
- Downloading sebastian/object-enumerator (5.0.0)
- Downloading sebastian/global-state (6.0.0)
- Downloading sebastian/exporter (5.0.0)
- Downloading sebastian/environment (6.0.1)
- Downloading sebastian/diff (5.0.3)
- Downloading sebastian/comparator (5.0.0)
- Downloading sebastian/code-unit (2.0.0)
- Downloading sebastian/cli-parser (2.0.0)
- Downloading phpunit/php-timer (6.0.0)
- Downloading phpunit/php-text-template (3.0.0)
- Downloading phpunit/php-invoker (4.0.0)
- Downloading phpunit/php-file-iterator (4.0.2)
- Downloading sebastian/lines-of-code (2.0.0)
- Downloading sebastian/complexity (3.0.0)
- Downloading sebastian/code-unit-reverse-lookup (3.0.0)
- Downloading phpunit/php-code-coverage (10.1.2)
- Downloading phpunit/phpunit (10.2.0)
- Downloading spatie/laravel-ignition (2.1.3)
- Installing doctrine/inflector (2.0.6): Extracting archive
- Installing doctrine/lexer (3.0.0): Extracting archive
- Installing symfony/polyfill-ctype (v1.27.0): Extracting archive
- Installing webmozart/assert (1.11.0): Extracting archive
- Installing dragonmantank/cron-expression (v3.3.2): Extracting archive
- Installing symfony/deprecation-contracts (v3.3.0): Extracting archive
- Installing psr/container (2.0.2): Extracting archive
- Installing fakerphp/faker (v1.22.0): Extracting archive
- Installing symfony/polyfill-php80 (v1.27.0): Extracting archive
- Installing symfony/polyfill-php83 (v1.27.0): Extracting archive
- Installing symfony/polyfill-mbstring (v1.27.0): Extracting archive
- Installing symfony/http-foundation (v6.3.0): Extracting archive
- Installing fruitcake/php-cors (v1.2.0): Extracting archive
- Installing psr/http-message (2.0): Extracting archive
- Installing psr/http-client (1.0.2): Extracting archive
- Installing ralouphie/getallheaders (3.0.3): Extracting archive
- Installing psr/http-factory (1.0.2): Extracting archive
- Installing guzzlehttp/psr7 (2.5.0): Extracting archive
- Installing guzzlehttp/promises (2.0.0): Extracting archive
- Installing guzzlehttp/guzzle (7.7.0): Extracting archive
- Installing guzzlehttp/uri-template (v1.0.1): Extracting archive
- Installing laravel/pint (v1.10.0): Extracting archive
- Installing symfony/yaml (v6.3.0): Extracting archive
- Installing voku/portable-ascii (2.0.1): Extracting archive
- Installing phpoption/phpoption (1.9.1): Extracting archive
- Installing graham-campbell/result-type (v1.1.1): Extracting archive
- Installing vlucas/phpdotenv (v5.5.0): Extracting archive
- Installing symfony/css-selector (v6.3.0): Extracting archive
- Installing tijsverkoyen/css-to-inline-styles (2.2.6): Extracting archive
- Installing symfony/var-dumper (v6.3.0): Extracting archive
- Installing symfony/polyfill-uuid (v1.27.0): Extracting archive
- Installing symfony/uid (v6.3.0): Extracting archive
- Installing symfony/routing (v6.3.0): Extracting archive
- Installing symfony/process (v6.3.0): Extracting archive
- Installing symfony/polyfill-php72 (v1.27.0): Extracting archive
- Installing symfony/polyfill-intl-normalizer (v1.27.0): Extracting archive
- Installing symfony/polyfill-intl-idn (v1.27.0): Extracting archive
- Installing symfony/mime (v6.3.0): Extracting archive
- Installing symfony/service-contracts (v3.3.0): Extracting archive
- Installing psr/event-dispatcher (1.0.0): Extracting archive
- Installing symfony/event-dispatcher-contracts (v3.3.0): Extracting archive
- Installing symfony/event-dispatcher (v6.3.0): Extracting archive
- Installing psr/log (3.0.0): Extracting archive
- Installing egulias/email-validator (4.0.1): Extracting archive
- Installing symfony/mailer (v6.3.0): Extracting archive
- Installing symfony/error-handler (v6.3.0): Extracting archive
- Installing symfony/http-kernel (v6.3.0): Extracting archive
- Installing symfony/finder (v6.3.0): Extracting archive
- Installing symfony/polyfill-intl-grapheme (v1.27.0): Extracting archive
- Installing symfony/string (v6.3.0): Extracting archive
- Installing symfony/console (v6.3.0): Extracting archive
- Installing ramsey/collection (2.0.0): Extracting archive
- Installing brick/math (0.11.0): Extracting archive
- Installing ramsey/uuid (4.7.4): Extracting archive
- Installing psr/simple-cache (3.0.0): Extracting archive
- Installing nunomaduro/termwind (v1.15.1): Extracting archive
- Installing symfony/translation-contracts (v3.3.0): Extracting archive
- Installing symfony/translation (v6.3.0): Extracting archive
- Installing nesbot/carbon (2.67.0): Extracting archive
- Installing monolog/monolog (3.3.1): Extracting archive
- Installing league/mime-type-detection (1.11.0): Extracting archive
- Installing league/flysystem (3.15.1): Extracting archive
- Installing league/flysystem-local (3.15.0): Extracting archive
- Installing nette/utils (v4.0.0): Extracting archive
- Installing nette/schema (v1.2.3): Extracting archive
- Installing dflydev/dot-access-data (v3.0.2): Extracting archive
- Installing league/config (v1.2.0): Extracting archive
- Installing league/commonmark (2.4.0): Extracting archive
- Installing laravel/serializable-closure (v1.3.0): Extracting archive
- Installing laravel/framework (v10.13.1): Extracting archive
- Installing laravel/sail (v1.22.0): Extracting archive
- Installing laravel/sanctum (v3.2.5): Extracting archive
- Installing nikic/php-parser (v4.15.5): Extracting archive
- Installing psy/psysh (v0.11.18): Extracting archive
- Installing laravel/tinker (v2.8.1): Extracting archive
- Installing hamcrest/hamcrest-php (v2.0.1): Extracting archive
- Installing mockery/mockery (1.5.1): Extracting archive
- Installing filp/whoops (2.15.2): Extracting archive
- Installing nunomaduro/collision (v7.5.2): Extracting archive
- Installing sebastian/version (4.0.1): Extracting archive
- Installing sebastian/type (4.0.0): Extracting archive
- Installing sebastian/recursion-context (5.0.0): Extracting archive
- Installing sebastian/object-reflector (3.0.0): Extracting archive
- Installing sebastian/object-enumerator (5.0.0): Extracting archive
- Installing sebastian/global-state (6.0.0): Extracting archive
- Installing sebastian/exporter (5.0.0): Extracting archive
- Installing sebastian/environment (6.0.1): Extracting archive
- Installing sebastian/diff (5.0.3): Extracting archive
- Installing sebastian/comparator (5.0.0): Extracting archive
- Installing sebastian/code-unit (2.0.0): Extracting archive
- Installing sebastian/cli-parser (2.0.0): Extracting archive
- Installing phpunit/php-timer (6.0.0): Extracting archive
- Installing phpunit/php-text-template (3.0.0): Extracting archive
- Installing phpunit/php-invoker (4.0.0): Extracting archive
- Installing phpunit/php-file-iterator (4.0.2): Extracting archive
- Installing theseer/tokenizer (1.2.1): Extracting archive
- Installing sebastian/lines-of-code (2.0.0): Extracting archive
- Installing sebastian/complexity (3.0.0): Extracting archive
- Installing sebastian/code-unit-reverse-lookup (3.0.0): Extracting archive
- Installing phpunit/php-code-coverage (10.1.2): Extracting archive
- Installing phar-io/version (3.2.1): Extracting archive
- Installing phar-io/manifest (2.0.3): Extracting archive
- Installing myclabs/deep-copy (1.11.1): Extracting archive
- Installing phpunit/phpunit (10.2.0): Extracting archive
- Installing spatie/backtrace (1.4.0): Extracting archive
- Installing spatie/flare-client-php (1.3.6): Extracting archive
- Installing spatie/ignition (1.8.0): Extracting archive
- Installing spatie/laravel-ignition (2.1.3): Extracting archive
51 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
INFO Discovering packages.
laravel/sail .......................................................... DONE
laravel/sanctum ....................................................... DONE
laravel/tinker ........................................................ DONE
nesbot/carbon ......................................................... DONE
nunomaduro/collision .................................................. DONE
nunomaduro/termwind ................................................... DONE
spatie/laravel-ignition ............................................... DONE
82 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
> @php artisan vendor:publish --tag=laravel-assets --ansi --force
INFO No publishable resources for tag [laravel-assets].
No security vulnerability advisories found
> @php artisan key:generate --ansi
INFO Application key set successfully.
Databaseの設定
MySQL/MariaDBの場合
mysqlを起動して、次の内容を実行します。
- Laravelのプロジェクトで使用するデータベースの作成
- データベースをアクセスするユーザーとパスワードの作成
- ユーザーへのアクセス権限の付与
$sudo mysql -u root
>create database cms_lv;
>create user 'cms_db_user'@'localhost' identified by 'cmsPassword';
>grant all privileges on cms_lv.* to 'cms_db_user'@'localhost';
>quit
INFO Application key set successfully.
.envにmysqlで作成したデータベース関連の設定を追加します。
$vi .env
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=cms_lv
DB_USERNAME=cms_db_user
DB_PASSWORD=cmsPassword
SQLite 3の場合
データベース用の空ファイルを作成します。
$cd cms_lv
$touch database/cms_lv.sqlite
.envにデータベース関連の設定を追加します。DB_CONNECTIONとDB_DATABASE以外は不要です。
$vi .env
#DB_HOST=127.0.0.1
#DB_PORT=3306
#DB_DATABASE=
#DB_USERNAME=
#DB_PASSWORD=
DB_CONNECTION=sqlite
DB_DATABASE=database/cms_lv.sqlite
動作確認
次のコマンドでビルドインサーバを起動してからWebブラウザでhttp://localhost:8000にアクセスします。
$php artisan serve
INFO Server running on [http://127.0.0.1:8000].
Press Ctrl+C to stop the server