CakePHP4を試す


環境構築 - Vagrant で LAMP 環境を構築 (6) -

CakePHP4のインストールに再チャレンジ

以前CakePHP 4のインストールにチャレンジして、Composerという伏兵にあって断念していました。
しかし各種プラグイン等がComposerを使ってインストールすることを前提に提供されていることもあり、再度チャレンジしてみることにしました。
Google先生にお伺いをたてても、筆者の現象について解決されている方は見当たりません。もしかしたら筆者の環境特有のことなのかもしれません。
怪しそうなところから、ひとつづつ条件を変えて確認してみます。

PHP 7.2にしてみる

Composer自体がPHPのアプリケーションですので、PHPのバージョンに影響を受ける可能性があるかもしれません。標準のパッケージであるバージョン7.2で確認してみることにしました。
しかし、現象は変わりませんでした。

共有フォルダをやめてみる

以前のチャレンジでは、ホストマシンからファイルを編集したいとの思いから共有フォルダにCakePHPをインストールしようとしていました。ファイルシステムによっては何か影響があるかもしれません。
すると、インストールが正常に終了しました。
関連するパッケージとして次のパッケージをインストールしています。

$ sudo apt update && sudo apt -y upgrade
$ sudo apt -y install software-properties-common
$ sudo add-apt-repository -y ppa:ondrej/php
$ sudo apt update
$ sudo apt -y install php7.4 php7.4-cli php7.4-mbstring php7.4-intl php7.4-sqlite3 composer
$ sudo apt -y install unzip zip

実行時のログも併せて置きます。

$ sudo mkdir /var/www/CakePHP ↵
$ sudo chown vagrant:vagrant /var/www/CakePHP/ ↵
$ composer create-project --prefer-dist cakephp/app:4.* /var/www/CakePHP/application_directory ↵
Installing cakephp/app (4.0.3)
  - Installing cakephp/app (4.0.3): Downloading (100%)         
Created project in /var/www/CakePHP/application_directory
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 80 installs, 0 updates, 0 removals
  - Installing cakephp/plugin-installer (1.2.0): Downloading (100%)         
  - Installing m1/env (2.2.0): Downloading (100%)         
  - Installing josegonzalez/dotenv (3.2.0): Downloading (100%)         
  - Installing psr/simple-cache (1.0.1): Downloading (100%)         
  - Installing psr/log (1.1.3): Downloading (100%)         
  - Installing psr/http-message (1.0.1): Downloading (100%)         
  - Installing psr/http-server-handler (1.0.1): Downloading (100%)         
  - Installing psr/http-server-middleware (1.0.1): Downloading (100%)         
  - Installing psr/http-client (1.0.0): Downloading (100%)         
  - Installing psr/http-factory (1.0.1): Downloading (100%)         
  - Installing laminas/laminas-zendframework-bridge (1.0.3): Downloading (100%)         
  - Installing laminas/laminas-diactoros (2.3.0): Downloading (100%)         
  - Installing laminas/laminas-httphandlerrunner (1.1.0): Downloading (100%)         
  - Installing composer/ca-bundle (1.2.7): Downloading (100%)         
  - Installing cakephp/chronos (2.0.4): Downloading (100%)         
  - Installing aura/intl (3.0.0): Downloading (100%)         
  - Installing cakephp/cakephp (4.0.7): Downloading (100%)         
  - Installing symfony/polyfill-ctype (v1.15.0): Downloading (100%)         
  - Installing symfony/filesystem (v5.0.8): Downloading (100%)         
  - Installing symfony/config (v5.0.8): Downloading (100%)         
  - Installing psr/container (1.0.0): Downloading (100%)         
  - Installing symfony/service-contracts (v2.0.1): Downloading (100%)         
  - Installing symfony/polyfill-php73 (v1.15.0): Downloading (100%)         
  - Installing symfony/polyfill-mbstring (v1.15.0): Downloading (100%)         
  - Installing symfony/console (v5.0.8): Downloading (100%)         
  - Installing robmorgan/phinx (0.12.1): Downloading (100%)         
  - Installing cakephp/migrations (3.0.0-RC): Downloading (100%)         
  - Installing mobiledetect/mobiledetectlib (2.8.34): Downloading (100%)         
  - Installing twig/twig (v3.0.3): Downloading (100%)         
  - Installing twig/markdown-extra (v3.0.3): Downloading (100%)         
  - Installing jasny/twig-extensions (v1.3.0): Downloading (100%)         
  - Installing cakephp/twig-view (1.0.2): Downloading (100%)         
  - Installing cakephp/bake (2.1.0): Downloading (100%)         
  - Installing squizlabs/php_codesniffer (3.5.5): Downloading (100%)         
  - Installing phpstan/phpdoc-parser (0.4.4): Downloading (100%)         
  - Installing slevomat/coding-standard (6.3.3): Downloading (100%)         
  - Installing cakephp/cakephp-codesniffer (4.0.1): Downloading (100%)         
  - Installing jdorn/sql-formatter (v1.2.17): Downloading (100%)         
  - Installing seld/phar-utils (1.1.0): Downloading (100%)         
  - Installing seld/jsonlint (1.8.0): Downloading (100%)         
  - Installing justinrainbow/json-schema (5.2.9): Downloading (100%)         
  - Installing composer/xdebug-handler (1.4.1): Downloading (100%)         
  - Installing composer/spdx-licenses (1.5.3): Downloading (100%)         
  - Installing composer/semver (1.5.1): Downloading (100%)         
  - Installing symfony/process (v5.0.8): Downloading (100%)         
  - Installing symfony/finder (v5.0.8): Downloading (100%)         
  - Installing composer/composer (1.10.5): Downloading (100%)         
  - Installing cakephp/debug_kit (4.1.2): 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.0): Downloading (100%)         
  - Installing phpdocumentor/reflection-common (2.1.0): Downloading (100%)         
  - Installing phpdocumentor/type-resolver (1.1.0): Downloading (100%)         
  - Installing webmozart/assert (1.8.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.4): Downloading (100%)         
  - Installing dnoegel/php-xdg-base-dir (v0.1.1): Downloading (100%)         
  - Installing nikic/php-parser (v4.4.0): Downloading (100%)         
  - Installing symfony/var-dumper (v5.0.8): Downloading (100%)         
  - Installing psy/psysh (v0.10.4): Downloading (100%)         
cakephp/app suggests installing markstory/asset_compress (An asset compression plugin which provides file concatenation and a flexible filter system for preprocessing and minification.)
cakephp/app suggests installing dereuromark/cakephp-ide-helper (After baking your code, this keeps your annotations in sync with the code evolving from there on for maximum IDE and PHPStan/Psalm compatibility.)
cakephp/app suggests installing phpstan/phpstan (PHPStan focuses on finding errors in your code without actually running it. It catches whole classes of bugs even before you write tests for the code.)
m1/env suggests installing m1/vars (For loading of configs)
cakephp/cakephp suggests installing ext-curl (To enable more efficient network calls in Http\Client.)
cakephp/cakephp suggests installing lib-ICU (The intl PHP library, to use Text::transliterate() or Text::slug())
cakephp/cakephp suggests installing paragonie/csp-builder (CSP builder, to use the CSP Middleware)
symfony/config suggests installing symfony/yaml (To use the yaml reference dumper)
symfony/service-contracts suggests installing symfony/service-implementation ()
symfony/console suggests installing symfony/event-dispatcher ()
symfony/console suggests installing symfony/lock ()
robmorgan/phinx suggests installing symfony/yaml (Install if using YAML configuration format)
cakephp/migrations suggests installing dereuromark/cakephp-ide-helper (If you want to have IDE suggest/autocomplete when creating migrations.)
composer/composer suggests installing ext-zip (Enabling the zip extension allows you to unzip archives)
sebastian/global-state suggests installing ext-uopz (*)
phpunit/phpunit suggests installing phpunit/php-invoker (^2.0.0)
phpunit/phpunit suggests installing ext-soap (*)
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.)
Writing lock file
Generating autoload files
> Cake\Composer\Installer\PluginInstaller::postAutoloadDump
> App\Console\Installer::postInstall
Created `config/app_local.php` file
Created `/var/www/CakePHP/application_directory/logs` directory
Created `/var/www/CakePHP/application_directory/tmp/cache/views` directory
Set Folder Permissions ? (Default to Y) [Y,n]? ↵
Permissions set on /var/www/CakePHP/application_directory/tmp/cache
Permissions set on /var/www/CakePHP/application_directory/tmp/cache/models
Permissions set on /var/www/CakePHP/application_directory/tmp/cache/persistent
Permissions set on /var/www/CakePHP/application_directory/tmp/cache/views
Permissions set on /var/www/CakePHP/application_directory/tmp/sessions
Permissions set on /var/www/CakePHP/application_directory/tmp/tests
Permissions set on /var/www/CakePHP/application_directory/tmp
Permissions set on /var/www/CakePHP/application_directory/logs
Updated Security.salt value in config/app_local.php

CakePHPのインストールがComposerによって行うことができました。
これにより、今後の作業でComposerを使用することが可能になりました。
プログラムソースの編集作業などはWindows環境の下で行うほうが便利です。今後Linuxの/var/www/CakePHP/application_directoryに配置したファイルにホストマシンからアクセスする方法を検討していきたいと思います。