Windows への CakePHP インストール on XAMPP

Windows環境でXAMPPをインストールし、その上でCakePHPを動作させる手順です。
XAMPPとかCakePHPの記事書いているのにそもそもそのインストール手順ないやん!ってことで。
実際、自分が再構築するのにやり方忘れてた部分もあったので(´・ω・`)

XAMPPのインストール

ダウンロード

XAMPP 日本語からWindows 向け XAMPPをダウンロード

XAMPP ダウンロード

インストール

  1. ダウンロードしたファイルをダブルクリックしてインストールを開始 XAMPP インストール
  2. 64bit OSへインストールする場合にWarningが出ます
    please avoid to install XAMPP toに続くパス以外にインストールしましょう
    OKボタン XAMPP インストール
  3. Nextボタン XAMPP インストール
  4. Select Components
    インストールコンポーネントを選択しNextボタン
    よく分からない場合はそのままで問題ありません
    XAMPP インストール 私は必須以外に以下を選択
    • MySQL
    • phpMyAdmin
  5. Installation folder
    インストール先を指定してNextボタン XAMPP インストール
  6. Bitnami for XAMPP
    チェックを外してNextボタン XAMPP インストール
  7. Nextボタン XAMPP インストール
  8. インストール中にファイアウォールの警告が表示された場合は、チェックをそのままにしてアクセスを許可するボタン XAMPP インストール
  9. Finishボタン XAMPP インストール
  10. 完了画面でチェックを入れていた場合、下記の画面が表示されるので、言語を選択してSaveボタン XAMPP インストール
  11. コントロールパネルが起動します XAMPP インストール
  12. MySQLStart時にファイアウォールの警告が表示された場合は、チェックをそのままにしてアクセスを許可するボタン XAMPP インストール

Composerのインストール

ダウンロード

  1. CakePHP 日本語にアクセス
  2. クイックスタートガイドをクリック Composer ダウンロード
  3. 画面をスクロールしてCakePHP の取得にあるComposer のウェブサイトをクリック Composer ダウンロード
  4. Composer-Setup.exeをダウンロード Composer ダウンロード

インストール

  1. ダウンロードしたファイルをダブルクリックしてインストールを開始 Composer インストール
  2. Installation Options
    チェックせずにNextボタン Composer インストール
  3. Settings Check
    PHPのインストールフォルダを指定してNextボタン Composer インストール
  4. Proxy Settings
    プロキシサーバー経由でインターネットに接続する場合はプロキシサーバーを設定します
    Nextボタン Composer インストール
  5. Installボタン Composer インストール
  6. Nextボタン Composer インストール
  7. Finishボタン Composer インストール

CakePHP3のインストール

  1. コマンドプロンプトを起動します
  2. CakePHP3をインストールしたいフォルダに移動します
  3. 以下のコマンドを実行します

Composerのインストールディレクトリがデフォルト(C:\ProgramData\ComposerSetup\bin)の場合

C:\ProgramData\ComposerSetup\bin\composer self-update && C:\ProgramData\ComposerSetup\bin\composer create-project --prefer-dist cakephp/app cake-prj

または

コマンドプロンプトでComposerのインストールディレクトリから以下のコマンドを実行します。
C:\xampp\htdocs\cake-prjにインストールする場合

composer self-update && composer create-project --prefer-dist cakephp/app C:\xampp\htdocs\cake-prj

インストールできたらブラウザでアクセスできるか確認します。

  1. XAMPPでApacthを起動します
  2. ブラウザでhttp://localhost/cake-prj/にアクセスします
    正常にインストール出来ていれば、以下のようなCakePHP3の画面が表示されます CakePHP3

以下のようなエラーが出た場合、php.iniを後述のように編集します。
その後、インストールフォルダを削除して、再度コマンドを実行してください。

- cakephp/cakephp 3.6.9 requires ext-intl * -> the requested PHP extension intl is missing from your system.
Fatal error: You must enable the intl extension to use CakePHP. in C:\xampp\htdocs\cake-prj\config\requirements.php on line 31

php.iniの編集

extension=intlを有効にします。

;extension=intl

の行を以下のように変更します。

extension=intl

Databaseへの接続を設定する

/{CakePHPプロジェクト}/config/app.phpDatasourcesを編集します。

  • 'username'
  • 'password'
  • 'database'

をXAMPPで設定した値に変更します。

    'Datasources' => [
        'default' => [
            'className' => 'Cake\Database\Connection',
            'driver' => 'Cake\Database\Driver\Mysql',
            'persistent' => false,
            'host' => 'localhost',
            /*
             * CakePHP will use the default DB port based on the driver selected
             * MySQL on MAMP uses port 8889, MAMP users will want to uncomment
             * the following line and set the port accordingly
             */
            //'port' => 'non_standard_port_number',
            'username' => 'my_app', // * 変更する
            'password' => 'secret', // * 変更する
            'database' => 'my_app', // * 変更する
            /*
             * You do not need to set this flag to use full utf-8 encoding (internal default since CakePHP 3.6).
             */
            //'encoding' => 'utf8mb4',
            'timezone' => 'UTC',
            'flags' => [],
            'cacheMetadata' => true,
            'log' => false,

            /**
             * Set identifier quoting to true if you are using reserved words or
             * special characters in your table or column names. Enabling this
             * setting will result in queries built using the Query Builder having
             * identifiers quoted when creating SQL. It should be noted that this
             * decreases performance because each query needs to be traversed and
             * manipulated before being executed.
             */
            'quoteIdentifiers' => false,

            /**
             * During development, if using MySQL < 5.6, uncommenting the
             * following line could boost the speed at which schema metadata is
             * fetched from the database. It can also be set directly with the
             * mysql configuration directive 'innodb_stats_on_metadata = 0'
             * which is the recommended value in production environments
             */
            //'init' => ['SET GLOBAL innodb_stats_on_metadata = 0'],

            'url' => env('DATABASE_URL', null),
        ],
このエントリーをはてなブックマークに追加
にほんブログ村 IT技術ブログへ

スポンサードリンク

関連コンテンツ

コメント

メールアドレスが公開されることはありません。 が付いている欄は必須項目です