CakePHP Intro and Migration
cake3 usage

public tutorial
https://book.cakephp.org/3.0/en/tutorials-and-examples/cms/articles-controller.html
install
Use Composer.
curl -s https://getcomposer.org/installer | php Composer (version 1.9.0) successfully installed to: /Users/kaede/code/cake3/composer.phar php composer.phar create-project --prefer-dist cakephp/app hoge - Installing cakephp/plugin-installer (1.1.1): Downloading (100%)
When completed, Directory will be like this:
▾ interns/
▸ bin/
▸ config/
▸ logs/
▸ plugins/
▸ src/
▸ tests/
▸ tmp/
▸ vendor/
▸ webroot/
composer.jsongg
composer.lock
index.php
phpunit.xml.dist
README.md
composer.phar
README.md
start server
bin/cake server
runs app in http://localhost:8765/
Defalt Page is this:


At first, your cakephp project is not connected to Database.
(img)
Writing setting file and making a database enables connection.
connect Database(DB)
Rewrite app.php
In Datasources: 'className' => 'Cake\Database\Connection', 'driver' => 'Cake\Database\Driver\Mysql', 'username' => 'root', 'password' => '', 'database' => 'yourDBname',
create DB
Download XAMPP or LAMPP and create your DB.

open XAMPP and start all.
mysql -u root create database hoge;
You see SQL is connected now.
(img)
Manage table
create table
CakePHP can make tables by simple commands
bin/cake bake migration CreateTableName columnName:string columnName:text created modified
You can make sure your table was made by MySQL console.

This makes 20190924_migration.php, but this did not made
the table yet.
execute
You have to execute this by:
bin/cake migrations migrate
This made tables of the migration definition.
delete table
bin/cake bake migration DropTableName
add a column to table
bin/cake bake migration AddColumnNameToTableName columnName:type bin/cake bake migration AddPriceToTableName price:decimal
undo the migration
bin/cake migrations rollback
can reset.
delete a column
bin/cake bake migration RemovePriceFromTableName price
Make Controller
bin/cake bake all tableNames
cmd can make proper files:
controller, model, ctps,
and the functions index, add, edit, view,
See the CRUD in the browser
Conclusion
This article introduced:
making DB by SQL,
creating table and columns by migration,
creating controllers by bake all.
This made minimum CRUD system.