CakePHP3 DB設定
DBの接続設定について書いていきます。
confing/app.php の Datasources の変更
'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' => 'user_name',
'password' => 'password',
'database' => 'db_name',
'encoding' => 'utf8',
'timezone' => 'Asia/Tokyo',
'flags' => [],
'cacheMetadata' => true,
'log' => false,
:
config/bootstrap.php にもtimezoneの記述があるので変更します
/*
* Set server timezone to UTC. You can change it to another timezone of your
* choice but using UTC makes time calculations / conversions easier.
*/
date_default_timezone_set('Asia/Tokyo');
localhostにアクセスしてDatabaseの部分を確認します。
ちゃんと接続できているようです!