Readouble

Laravel 5.dev 設定

イントロダクションIntroduction

フレームワークの全設定ファイルはconfigディレクトリーの中に設置されています。全ファイル中の、それぞれのオプションにコメントが入っています。自由にご覧になり、用意されたオプションを理解してください。All of the configuration files for the Laravel framework are stored in the config directory. Each option is documented, so feel free to look through the files and get familiar with the options available to you.

インストール後After Installation

アプリケーションの命名Naming Your Application

Laravelをインストールしたら、アプリケーションに「名前」を付けたいことでしょう。appディレクトリーはデフォルトでApp名前空間下にあり、PSR-4オートローディング規約により、Composerがオートローディングしています。しかし、app:name Artisanコマンドにより、簡単にアプリケーション名にあった名前空間へ変更できます。After installing Laravel, you may wish to "name" your application. By default, the app directory is namespaced under App, and autoloaded by Composer using the PSR-4 autoloading standard[http://www.php-fig.org/psr/psr-4/]. However, you may change the namespace to match the name of your application, which you can easily do via the app:name Artisan command.

例えばアプリケーションを"Horsefly"と名付けたければ、インストールルートのディレクトリーで、次のコマンドを実行してください。For example, if your application is named "Horsefly", you could run the following command from the root of your installation:

php artisan app:name Horsefly

アプリケーションの名前付けは強制ではありません。そうしたければ、App名前空間のままでもかまいません。Renaming your application is entirely optional, and you are free to keep the App namespace if you wish.

他の設定Other Configuration

最初に必要なLaravelの設定は、多くありません。すぐに開発を開始することもできます!ですが、config/app.phpファイルと、そのドキュメントには目を通しておいたほうが良いでしょう。ロケーションに合わせて変えておきたくなるtimezonelocaleのような多くのオプションを含んでいます。Laravel needs very little configuration out of the box. You are free to get started developing! However, you may wish to review the config/app.php file and its documentation. It contains several options such as timezone and locale that you may wish to change according to your location.

Laravelをインストールし終えたら、ローカル環境の設定も行いましょう。Once Laravel is installed, you should also configure your local environment[/docs/master/configuration#environment-configuration].

注意: 実働のアプリケーションに対し、app.debug設定オプションをtrueに設定してはいけません。Note: You should never have the app.debug configuration option set to true for a production application.

パーミッションPermissions

Laravelでは一箇所だけパーミッション設定が必要です。storage下のフォルダーへWebサーバーによる書き込みアクセスを設定してください。Laravel may require one set of permissions to be configured: folders within storage require write access by the web server.

設定値にアクセスするAccessing Configuration Values

Configファサードを利用し、設定値へ簡単にアクセスできます。You may easily access your configuration values using the Config facade:

$value = Config::get('app.timezone');

Config::set('app.timezone', 'America/Chicago');

configヘルパ関数を使用することもできます。You may also use the config helper function:

$value = config('app.timezone');

環境設定Environment Configuration

アプリケーションを実行している環境に基づいて、異なった設定値を使用できれば、多くの場面で役立つでしょう。例えば、ローカル環境では実働環境とは異なったキャッシュドライバーを使いたい時です。環境ベースの設定で簡単にできます。It is often helpful to have different configuration values based on the environment the application is running in. For example, you may wish to use a different cache driver locally than you do on your production server. It's easy using environment based configuration.

.Laravelは、Vance Lucasさんにより作成された、DotEnvを活用しているので、朝飯前です。インストールしたてのLaravelでは、アプリケーションのルートディレクトリーに.env.exampleファイルが含まれています。Composerを利用してLaravelをインストールしたら、このファイルは自動的に.envへリネームされます。Composerを使用しない場合は、自分で名前を変更してください。To make this a cinch, Laravel utilizes the DotEnv[https://github.com/vlucas/phpdotenv] PHP library by Vance Lucas. In a fresh Laravel installation, the root directory of your application will contain a .env.example file. If you install Laravel via Composer, this file will automatically be renamed to .env. Otherwise, you should rename the file manually.

このファイルにリストされている全変数は、アプリケーションがリクエストを受け取ると、$_ENV PHPスーパーグローバルへロードされます。これらの変数から値を取得するには、envヘルパが使用できます。実際、Laravelの設定ファイルを調べてみれば、多くのオプションでこのヘルパが使用されていることに気がつくでしょう!All of the variables listed in this file will be loaded into the $_ENV PHP super-global when your application receives a request. You may use the env helper to retrieve values from these variables. In fact, if you review the Laravel configuration files, you will notice several of the options already using this helper!

ローカルサーバーの要求に合わせ、環境変数を変更してください。実働環境でも同様です。しかし、.envファイルをアプリケーションのソース管理下へ追加してはいけません。あなたのアプリケーションを利用する各開発者/サーバーは別々の環境値を設定できるからです。Feel free to modify your environment variables as needed for your own local server, as well as your production environment. However, your .env file should not be committed to your application's source control, since each developer / server using your application could require a different environment configuration.

チームにより開発を行っているならば、アプリケーションに.env.exampleファイルを含んでおきたいことでしょう。example設定ファイルへプレースフォルダー値を入れておけば、他の開発者はアプリケーションを実行するために、どの環境変数が必要なのか明確に理解できます。If you are developing with a team, you may wish to continue including a .env.example file with your application. By putting place-holder values in the example configuration file, other developers on your team can clearly see which environment variables are needed to run your application.

現在のアプリケーションの環境にアクセスするAccessing The Current Application Environment

現在のアプリケーションの環境へは、Applicationインスタンスのenvironmentメソッドによりアクセスできます。You may access the current application environment via the environment method on the Application instance:

$environment = $app->environment();

environmentメソッドに引数を渡すことで、指定した値の環境であるかを確認することができます。You may also pass arguments to the environment method to check if the environment matches a given value:

if ($app->environment('local'))
{
	// 環境はlocal
}

if ($app->environment('local', 'staging'))
{
	// 環境はlocalかstaging
}

アプリケーションのインスタンスを取得するには、サービスコンテナーにより、Illuminate\Contracts\Foundation\Application契約を依存解決してください。もちろん、サービスプロバイダーの中では、$this->appインスタンス変数により、アプリケーションインスタンスを利用できます。To obtain an instance of the application, resolve the Illuminate\Contracts\Foundation\Application contract via the service container[/docs/master/container]. Of course, if you are within a service provider[/docs/master/providers], the application instance is available via the $this->app instance variable.

アプリケーションのインスタンスにはappヘルパか、Appファサードでもアクセスできます。An application instance may also be accessed via the app helper of the App facade:

$environment = app()->environment();

$environment = App::environment();

キャッシュの設定Configuration Caching

アプリケーションを少しスピードアップするために、config:cache Artisanコマンドで全ての設定ファイルを一つにまとめることができます。このコマンドは、フレームワークが素早くロードできるように、全設定オプションを一つのファイルへ結合します。To give your application a little speed boost, you may cache all of your configuration files into a single file using the config:cache Artisan command. This will combine all of the configuration options for your application into a single file which can be loaded quickly by the framework.

通常はデプロイ手順の一部として、config:cacheコマンドを実行すべきでしょう。You should typically run the config:cache command as part of your deployment routine.

メンテナンスモードMaintenance Mode

アプリケーションがメンテナンスモードの場合、そのアプリケーションで指定した全リクエストでカスタムビューを表示する必要があります。これにより、アップデートやメンテナンスを実行する時、簡単にアプリケーションを「停止」させることができます。メンテナンスモードのチェックは、アプリケーションのデフォルトミドルウェア中で行われています。アプリケーションがメンテナンスモードの場合、503のステータスコードと共に、HttpException例外が投げられます。When your application is in maintenance mode, a custom view will be displayed for all requests into your application. This makes it easy to "disable" your application while it is updating or when you are performing maintenance. A maintenance mode check is included in the default middleware stack for your application. If the application is in maintenance mode, an HttpException will be thrown with a status code of 503.

メンテナンスモードへ切り換える場合は、シンプルにdown Artisanコマンドを実行してください。To enable maintenance mode, simply execute the down Artisan command:

php artisan down

メンテナンスモードを解除する場合は、upコマンドを使用します。To disable maintenance mode, use the up command:

php artisan up

メンテナンスモードのレスポンステンプレートMaintenance Mode Response Template

メンテナンスモードで使用されるデフォルトのテンプレートは、resources/views/errors/503.blade.phpに存在しています。The default template for maintenance mode responses is located in resources/views/errors/503.blade.php.

メンテナンスモードとキューMaintenance Mode & Queues

アプリケーションがメンテナンスモードの場合、キューのジョブは処理されません。メンテナンスモードが解除され、アプリケーションが通常モードになった時点で、処理が続けられます。While your application is in maintenance mode, no queued jobs[/docs/master/queues] will be handled. The jobs will continue to be handled as normal once the application is out of maintenance mode.

きれいなURLPretty URLs

ApacheApache

フレームワークに含まれているpublic/.htaccessファイルにより、index.phpがURLに含まれていなくてもアクセスできます。Laravelアプリケーションのサーバーとして、Apacheを使用している場合、mod_rewriteを確実に有効にしてください。The framework ships with a public/.htaccess file that is used to allow URLs without index.php. If you use Apache to serve your Laravel application, be sure to enable the mod_rewrite module.

もし、フレームワークに含まれている.htaccessファイルが動作しない場合は、以下の指定を試してください。If the .htaccess file that ships with Laravel does not work with your Apache installation, try this one:

Options  FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

NginxNginx

Nginxの場合、以下のディレクティブをサイトの設定で指定すれば、「きれいな」URLが利用できます。On Nginx, the following directive in your site configuration will allow "pretty" URLs:

location / {
    try_files $uri $uri/ /index.php?$query_string;
}

もちろん、Homesteadを使用すれば、きれいなURLの設定は自動的に行われます。Of course, when using Homestead[/docs/master/homestead], pretty URLs will be configured automatically.

章選択

Artisan CLI

設定

明暗テーマ
light_mode
dark_mode
brightness_auto システム設定に合わせる
テーマ選択
photo_size_select_actual デフォルト
photo_size_select_actual モノクローム(白黒)
photo_size_select_actual Solarized風
photo_size_select_actual GitHub風(青ベース)
photo_size_select_actual Viva(黄緑ベース)
photo_size_select_actual Happy(紫ベース)
photo_size_select_actual Mint(緑ベース)
コードハイライトテーマ選択

明暗テーマごとに、コードハイライトのテーマを指定できます。

テーマ配色確認
スクリーン表示幅
640px
80%
90%
100%

768px以上の幅があるときのドキュメント部分表示幅です。

インデント
無し
1rem
2rem
3rem
原文確認
原文を全行表示
原文を一行ずつ表示
使用しない

※ 段落末のEボタンへカーソルオンで原文をPopupします。

Diff表示形式
色分けのみで区別
行頭の±で区別
削除線と追記で区別

※ [tl!…]形式の挿入削除行の表示形式です。

テストコード表示
両コード表示
Pestのみ表示
PHPUnitのみ表示
和文変換

対象文字列と置換文字列を半角スペースで区切ってください。(最大5組各10文字まで)

本文フォント

総称名以外はCSSと同様に、"〜"でエスケープしてください。

コードフォント

総称名以外はCSSと同様に、"〜"でエスケープしてください。

保存内容リセット

localStrageに保存してある設定項目をすべて削除し、デフォルト状態へ戻します。

ヘッダー項目移動

キーボード操作