CakePHP4 クイックスタート
プロジェクト作成
php composer.phar create-project --prefer-dist cakephp/app:4.1 cms
バージョンを指定せずに app:4.*
とするとエラーになる
エラー1
Exception: Argument 1 passed to Cake\Utility\Security::setSalt() must be of the type string, null given, called in /Users/xxxx/cms/config/bootstrap.php on line 164
config/app.php
のSecurityのenvの第二引数に32文字以上のランダムな文字を入れておけばよい。
'Security' => [ 'salt' => env('SECURITY_SALT', 'dfc123c6c22d84f4bc12273f3df67c6ae55009696e4126b36ac2f755778faccc'), ],
XAMPP環境にCakePHP4インストール時に起きたエラーと解決方法 | 417.Run()
エラー2
PHP Warning: require(/Users/xxxx/cms/vendor/autoload.php): failed to open stream: No such file or directory in /Users/xxxx/cms/bin/cake.php on line 5
CakePHP プロジェクト内にある vender フォルダに必要なファイルがインストールされていないことが原因です。 composerのアップデートをしましょう。
[~/cms]$ composer update
CakePHP3インストール時によく起こるエラーの解決法まとめ
サーバー起動
[~/cms]$ bin/cake server Welcome to CakePHP v4.3.4 Console ------------------------------------------------------------------------------- App : src Path: /Users/xxxx/cms/src/ DocumentRoot: /Users/xxxx/cms/webroot Ini Path: ------------------------------------------------------------------------------- built-in server is running in http://localhost:8765/ You can exit with `CTRL-C`
一番最初の画面で表示されるエラー
Please replace templates/Pages/home.php with your own version or re-enable debug mode.
以下のようなコードがテンプレートファイルに入っていると404エラーになります。
if (!Configure::read('debug')): throw new NotFoundException('Please replace src/Template/Pages/home.ctp with your own version.'); endif;
コメントアウトすると