0. はじめに
大阪の受託開発エンジニアの、kazumakishimoto(@kazuma_dev)です!
Laravelプロジェクトをgit clone
して、vendor
や.env
ファイルを作ってphp artisan serve
するまでのメモです!
(※初期設定は必要に応じて実施してください。)
0-1. 目次
0-2. 前提条件
- Gitインストール済み
- GitHub登録済み
0-3. 開発環境
key | value |
---|---|
OS | macOS |
FW | Laravel |
バーション管理 | Git/GitHub |
パッケージ管理 | Composer |
1. 環境構築
1-1. git clone
local
$ mkdir laravel
$ cd laravel
$ git clone https://github.com/xxxxxxxxxxxxxxx/xxxx.git
1-2. vendor
local
$ composer install
1-3. .env
local
$ cp .env.example .env
$ php artisan key:generate
$ php artisan config:clear
1-4. 動作確認
local
$ php artisan serve
2. 初期設定
2-1. アプリ名
.env
APP_NAME=アプリケーション名
config/app.php
'name' => env('APP_NAME', 'アプリケーション名'),
2-2. timezone
config/app.php
- 'timezone' => 'UTC',
+ 'timezone' => 'Asia/Tokyo',
2-3. locale
config/app.php
- 'locale' => 'en',
+ 'locale' => 'ja',
- 'faker_locale' => 'en_US',
+ 'faker_locale' => 'ja_JP',
2-4. charset
config/database.php
'mysql' => [
- 'charset' => 'utf8mb4',
+ 'charset' => 'utf8',
- 'collation' => 'utf8mb4_unicode_ci',
+ 'collation' => 'utf8_unicode_ci',
],
2-5. models
local
$ mkdir app/Models
app/Models/User.php
- namespace App;
+ namespace App\Models;
/app/Http/Controllers/Auth/RegisterController.php
use App\Http\Controllers\Controller;
- use App\User;
+ use App\Models\User;
config/auth.php
'providers' => [
'users' => [
'driver' => 'eloquent',
- 'model' => App\User::class,
+ 'model' => App\Models\User::class,
],
/config/services.php
'stripe' => [
- 'model' => App\User::class,
+ 'model' => App\Models\User::class,
],
],
database/factories/UserFactory.php
- $factory->define(App\User::class, function (Faker $faker) {
+ $factory->define(App\Models\User::class, function (Faker $faker) {
composer.json
"autoload": {
"psr-4": {
"App\\": "app/",
- "Models\\": "app/"
+ "Models\\": "app/Models/"
},
2-6. lang
local
$ cd resources/lang
$ mkdir ja
$ cd resources/lang/ja
local
$ curl -OL https://raw.githubusercontent.com/rito-nishino/Laravel-Japanese-Language-fileset/master/auth.php
$ curl -OL https://raw.githubusercontent.com/rito-nishino/Laravel-Japanese-Language-fileset/master/pagination.php
$ curl -OL https://raw.githubusercontent.com/rito-nishino/Laravel-Japanese-Language-fileset/master/passwords.php
$ curl -OL https://raw.githubusercontent.com/rito-nishino/Laravel-Japanese-Language-fileset/master/validation.php
2-7. migration
local
$ php artisan migrate:refresh --seed
Reference