CakePHP4でブログサイトを作ってみよう

CakePHP4で簡易ブログサイトを作ってみるコーナーです。

271 views

CakePHP4の準備

composer create-project --prefer-dist cakephp/app:4.* cakeblog

DBの設定

mysqlでcakeblogdbというデータベースを作成する。

create database cakeblogdb;

config/app_local.phpを編集する。11,12,14行目。

    'Datasources' => [
        'default' => [
            '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' => 'root',
            'password' => '',

            'database' => 'cakeblogdb',
            /*
             * If not using the default 'public' schema with the PostgreSQL driver
             * set it here.
             */
            //'schema' => 'myapp',

            /*
             * You can use a DSN string to set the entire configuration
             */
            'url' => env('DATABASE_URL', null),
        ],

http://localhost/cakeblog/にアクセスして以下の画面が表示されることを確認する。

Page 11 of 15.

前のページ 次のページ



[添付ファイル]


お問い合わせ

プロフィール

すぺぺぺ

自己紹介

本サイトの作成者。
プログラムは趣味と勉強を兼ねて、のんびり本サイトを作っています。
フレームワークはdjango。
ChatGPTで自動プログラム作成に取り組み中。

サイト/ブログ

https://www.osumoi-stdio.com/novel/

ツイッター

@darkimpact0626