【Laravel】git cloneして開発環境構築

# 0. はじめに
大阪の受託開発エンジニアの、kazumakishimoto([@kazuma_dev](https://twitter.com/kazuma_dev))です！
Laravelプロジェクトを`git clone`して、`vendor`や`.env`ファイルを作って`php artisan serve`するまでのメモです！
(※初期設定は必要に応じて実施してください。)

## 0-1. 目次
> [1.環境構築](#1-環境構築)
> [2.初期設定](#2-初期設定)
> [Reference](#reference)

## 0-2. 前提条件
- Gitインストール済み
- GitHub登録済み

## 0-3. 開発環境
|key|value|
|:--:|:--:|
|OS|macOS|
|FW|Laravel|
|バーション管理|Git/GitHub|
|パッケージ管理|Composer|

# 1. 環境構築
## 1-1. git clone
```terminal:local
$ mkdir laravel
$ cd laravel
$ git clone https://github.com/xxxxxxxxxxxxxxx/xxxx.git
```
## 1-2. vendor
```terminal:local
$ composer install
```

## 1-3. .env
```terminal:local
$ cp .env.example .env
$ php artisan key:generate
$ php artisan config:clear
```

## 1-4. 動作確認
```terminal:local
$ php artisan serve
```

# 2. 初期設定
## 2-1. アプリ名
```.env:.env
APP_NAME=アプリケーション名
```
```php:config/app.php
'name' => env('APP_NAME', 'アプリケーション名'),
```

## 2-2. timezone
```diff:config/app.php
- 'timezone' => 'UTC',
+ 'timezone' => 'Asia/Tokyo',
```

## 2-3. locale
```diff:config/app.php
- 'locale' => 'en',
+ 'locale' => 'ja',
- 'faker_locale' => 'en_US',
+ 'faker_locale' => 'ja_JP',
```

## 2-4. charset
```diff:config/database.php
'mysql' => [
- 'charset' => 'utf8mb4',
+ 'charset' => 'utf8',
- 'collation' => 'utf8mb4_unicode_ci',
+ 'collation' => 'utf8_unicode_ci',
],
```

## 2-5. models
```terminal:local
$ mkdir app/Models
```
```diff:app/Models/User.php
- namespace App;
+ namespace App\Models;
```
```diff:/app/Http/Controllers/Auth/RegisterController.php
use App\Http\Controllers\Controller;
- use App\User;
+ use App\Models\User;
```
```diff:config/auth.php
     'providers' => [ 
         'users' => [ 
             'driver' => 'eloquent', 
-             'model' => App\User::class, 
+             'model' => App\Models\User::class, 
         ], 
```
```diff:/config/services.php
    'stripe' => [
-        'model' => App\User::class,
+        'model' => App\Models\User::class,
        ],
    ],
```
```diff:database/factories/UserFactory.php
- $factory->define(App\User::class, function (Faker $faker) {
+ $factory->define(App\Models\User::class, function (Faker $faker) {
```
```diff:composer.json
    "autoload": {
        "psr-4": {
            "App\\": "app/",
-           "Models\\": "app/"
+           "Models\\": "app/Models/"
        },
```

## 2-6. lang
```terminal:local
$ cd resources/lang
$ mkdir ja
$ cd resources/lang/ja
```
```terminal: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
```terminal:local
$ php artisan migrate:refresh --seed
```

# Reference
https://qiita.com/hinako_n/items/6c45413daef3a206c02d

https://qiita.com/webprofado/items/32694685f2afdae176fd

https://qiita.com/10mi8o/items/6329d3d4e2f5b6dd26d5

https://qiita.com/vrvr/items/4755e758f5d4b2e07579

https://qiita.com/samuraibrass/items/d71c08e144dbbf98e348