0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

CakePHP4.*の環境構築

Posted at

スクリーンショット 2022-07-04 13.48.16.jpg

(出典:CakePHP公式サイト)
CakePHPのサーバー起動に手間取ったので成功までの道のりをメモしました。

※PHPのローカル開発環境としてXAMPPを使用しています。

CakePHP公式ドキュメント

インストール - 4.x

1.intl拡張モジュールを有効化
CakePHP4を使用するためには必須のためphp.iniを編集

/Applications/XAMPP/xamppfiles/etc内のphp.iniを開き、extension=php_intl.dll のコメントアウトを外して保存、もしXAMPPを起動していたら一度停止して再起動してください。
スクリーンショット 2022-07-04 13.24.59.jpg

2.PHPとcomposerのバージョン確認

php -v
PHP 8.1.7 (cli) (built: Jun  9 2022 14:08:46) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.7, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.7, Copyright (c), by Zend Technologies

最初7.4だったのでbrew install phpで最新のバージョン(8.1.*)に変更

composer -v
   ______
  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                    /_/
Composer version 2.3.8 2022-07-01 12:10:47

3.プロジェクト作成
今回はcakephpTestという名前で作成

composer self-update && composer create-project --prefer-dist cakephp/app:"4.*" cakephpTest
Set Folder Permissions ? (Default to Y) [Y,n]? 
Y
Updated Security.salt value in config/app_local.php

このメッセージが出ればプロジェクト作成は終了

フォルダの構成

XAMPPを使用しているため以下に保存

htdocs
	└─ cakephp
		   └─ cakephpTest

4.bin/cake ファイルを実行可能にする

chmod +x bin/cake

+x bin/cakebin/cake に実行権限(x)を付与という意味になります。

5.サーバーを起動

bin/cake server
Welcome to CakePHP v4.4.1 Console
-------------------------------------------------------------------------------
App : src
Path: /Applications/XAMPP/xamppfiles/htdocs/cakephpTest/cakephpTest/src/
DocumentRoot: /Applications/XAMPP/xamppfiles/htdocs/cakephpTest/cakephpTest/webroot
Ini Path: 
-------------------------------------------------------------------------------
built-in server is running in http://localhost:8765/
You can exit with `CTRL-C`
[Mon Jul  4 12:56:33 2022] PHP 8.1.7 Development Server (http://localhost:8765) started

スクリーンショット 2022-07-04 13.11.34.jpg

おまけ:CakePHPのコマンド一覧

App:
 - help

Bake:
 - bake
 - bake all
 - bake behavior
 - bake cell
 - bake command
 - bake command_helper
 - bake component
 - bake controller
 - bake controller all
 - bake fixture
 - bake fixture all
 - bake form
 - bake helper
 - bake mailer
 - bake middleware
 - bake model
 - bake model all
 - bake plugin
 - bake shell_helper
 - bake template
 - bake template all
 - bake test

Cake/TwigView:
 - twig-view compile

CakePHP:
 - cache clear
 - cache clear_all
 - cache list
 - completion
 - i18n
 - i18n extract
 - i18n init
 - plugin assets copy
 - plugin assets remove
 - plugin assets symlink
 - plugin load
 - plugin loaded
 - plugin unload
 - routes
 - routes check
 - routes generate
 - schema_cache build
 - schema_cache clear
 - server
 - version

DebugKit:
 - benchmark

Migrations:
 - bake migration
 - bake migration_diff
 - bake migration_snapshot
 - bake seed
 - bake simple_migration
 - migrations
 - migrations create
 - migrations dump
 - migrations mark_migrated
 - migrations migrate
 - migrations orm-cache-build
 - migrations orm-cache-clear
 - migrations rollback
 - migrations seed
 - migrations status
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?