Laravel
Laravel 8
概要
テストすることで学習定着すると言ってたので
目的
きわめる
routing
ルーティングとは、URLと、コントローラーなどの対応を指す。
具体的な記述は routes/*.php に記述されている。
nginx設定
きれいなURL
を採用するためのnginx設定
└example.com/a で、aControllerを見に行くための設定
location / {
index index.php index.htm index.html;
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\/php)(/.+)$;
fastcgi_pass php-fpm:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
.env
環境設定ファイル。DB, memcache, redisなどの設定。
app自体、ログ、AWS、mail、session、pusher も // TODO
migrationファイル作成
artisanでファイルを作成する。 (Flightはサンプルクラス名)
./artisan make:migration Flight [-mfsc] # -mfsc means migration, factory, seeder, controller
ファイルを編集して、好きなテーブルレイアウトにする
Schema::create('テーブル', function (Blueprint $table) {
$table->id();
$table->string('name', 50); // 追加
$table->timestamps();
});
migration実行
./artisan migrate
migration全戻し
./artisan migrate:reset
model作成
./artisan make:model ${モデル名}