13
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

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

Last updated at Posted at 2022-12-31

0. はじめに

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

0-1. 目次

1.環境構築
2.初期設定
Reference

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

13
10
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?