1
0

More than 5 years have passed since last update.

環境構築後に設定する箇所

Last updated at Posted at 2019-05-13

はじめに

ここの続きです
後から足りない場所などがあれば追記します

.envファイルの変更

修正箇所のみ記載

devproject/.env
APP_NAME=DevProjectApp          #アプリ名
APP_URL=https://homestead.test  #URL
DB_DATABASE=devhomestead        #DB名
DB_USERNAME=homestead           #ユーザー
DB_PASSWORD=secret              #パスワード

config/app.phpファイルの変更

タイムゾーンの設定

devproject\config\app.php
    /*
    |--------------------------------------------------------------------------
    | Application Timezone
    |--------------------------------------------------------------------------
    |
    | Here you may specify the default timezone for your application, which
    | will be used by the PHP date and date-time functions. We have gone
    | ahead and set this to a sensible default for you out of the box.
    |
    */

    'timezone' => 'Asia/Tokyo',

ロケールの設定

devproject\config\app.php
    /*
    |--------------------------------------------------------------------------
    | Application Locale Configuration
    |--------------------------------------------------------------------------
    |
    | The application locale determines the default locale that will be used
    | by the translation service provider. You are free to set this value
    | to any of the locales which will be supported by the application.
    |
    */

    'locale' => 'ja',

Faker言語の設定

devproject\config\app.php
    /*
    |--------------------------------------------------------------------------
    | Faker Locale
    |--------------------------------------------------------------------------
    |
    | This locale will be used by the Faker PHP library when generating fake
    | data for your database seeds. For example, this will be used to get
    | localized telephone numbers, street address information and more.
    |
    */

    'faker_locale' => 'ja_JP',

日本語化

php -r "copy('https://readouble.com/laravel/5.8/ja/install-ja-lang-files.php', 'install-ja-lang.php');"
php -f install-ja-lang.php
php -r "unlink('install-ja-lang.php');"

ディレクトリ
devproject\resources\lang\ja

ファイル名 用途
auth.php ログイン認証用
pagination.php ページネーション用
passwords.php パスワード用
validation.php バリデーション用

https対応

  • nginxでの対応

    • nginxでリダイレクトするようにするとhomesteadをprovisionする度に修正が必要になるため保留
      • homestead.yamlで設定できるかどうか調べる
  • Laravelでの対応

ミドルウェアを追加し、httpsではない場合にhttpsとしてリダイレクトする

php artisan make:middleware RedirectToHttps
devproject\app\Http\Middleware\RedirectToHttps.php
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        if (empty($_SERVER['HTTPS'])) {
            return redirect()->secure($request->fullUrl());
        }

        return $next($request);
    }
devproject\app\Http\Kernel.php
    /**
     * The application's global HTTP middleware stack.
     *
     * These middleware are run during every request to your application.
     *
     * @var array
     */
    protected $middleware = [
        // 省略...
        \App\Http\Middleware\RedirectToHttps::class,     //追加
    ];

注意

IISなどでは$_SERVER['HTTPS']ではないらしい。
今回のケースではnginxなので問題ない

1
0
0

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
1
0