Readouble

Laravel 5.8 インストール

インストールInstallation

videocam Laracastsはフレームワーク初心者のために、無料でLaravelの全体に渡るイントロダクションを提供しています。学習を始めるには最適の場所です。{video} Laracasts provides a free, thorough introduction to Laravel[http://laravelfromscratch.com] for newcomers to the framework. It's a great place to start your journey.

サーバ要件Server Requirements

Laravelフレームワークを動作させるには多少のシステム要件があります。Laravel Homestead仮想マシンでは、要求が全て満たされています。そのため、Laravelのローカル開発環境としてHomesteadを活用されることを強くおすすめします。The Laravel framework has a few system requirements. All of these requirements are satisfied by the Laravel Homestead[/docs/{{version}}/homestead] virtual machine, so it's highly recommended that you use Homestead as your local Laravel development environment.

しかし、Homesteadを使用しない場合は、以下の要件を満たす必要があります。However, if you are not using Homestead, you will need to make sure your server meets the following requirements:

- PHP >= 7.1.3 - BCMath PHP拡張 - Ctype PHP拡張 - JSON PHP拡張 - Mbstring PHP拡張 - OpenSSL PHP拡張 - PDO PHP拡張 - Tokenizer PHP拡張 - XML PHP拡張

LaravelのインストールInstalling Laravel

LaravelはComposerを依存パッケージの管理に使用しています。ですから、Laravelを始める前に、自分の開発機にComposerを確実にインストールしておいてください。Laravel utilizes Composer[https://getcomposer.org] to manage its dependencies. So, before using Laravel, make sure you have Composer installed on your machine.

LaravelインストーラVia Laravel Installer

最初にComposerを使用し、Laravelインストーラをダウンロードします。First, download the Laravel installer using Composer:

composer global require laravel/installer

皆さんのシステムの、どこへlaravel実行ファイルが設置されても動作するように、グローバルなComposerのbinディレクトリを$PATHへ登録してください。このディレクトリはオペレーティングシステムにより場所が異なります。通常は、以下の場所です。Make sure to place composer's system-wide vendor bin directory in your $PATH so the laravel executable can be located by your system. This directory exists in different locations based on your operating system; however, some common locations include:

- macOS/GNU/Linuxディストリビューション: `$HOME/.composer/vendor/bin` - Windows: `%USERPROFILE%\AppData\Roaming\Composer\vendor\bin`

インストールし終えたら、laravel newコマンドにより、指定したディレクトリに真新しいLaravelプロジェクトを作成できます。例えば、laravel new blogを実行すると、blogという名前のディレクトリへ、必要とするパッケージが全部揃った、真新しいLaravelがインストールされます。Once installed, the laravel new command will create a fresh Laravel installation in the directory you specify. For instance, laravel new blog will create a directory named blog containing a fresh Laravel installation with all of Laravel's dependencies already installed:

laravel new blog

Composer Create-ProjectVia Composer Create-Project

ターミナルでComposerのcreate-projectコマンドを実行し、Laravelをインストールする方法もあります。Alternatively, you may also install Laravel by issuing the Composer create-project command in your terminal:

composer create-project --prefer-dist laravel/laravel blog "5.8.*"

ローカル開発サーバLocal Development Server

PHPがローカルにインストール済みで、PHPの組込み開発サーバをアプリケーションサーバとして使いたい場合は、serve Artisanコマンドを使用します。このコマンドは、開発サーバをhttp://localhost:8000として起動します。If you have PHP installed locally and you would like to use PHP's built-in development server to serve your application, you may use the serve Artisan command. This command will start a development server at http://localhost:8000:

php artisan serve

より堅牢なローカル開発の選択肢として、HomesteadValetも利用できます。More robust local development options are available via Homestead[/docs/{{version}}/homestead] and Valet[/docs/{{version}}/valet].

設定Configuration

PublicディレクトリPublic Directory

Laravelをインストールできたら、Webサーバのドキュメント/Webルートがpublicディレクトリになるように設定してください。このディレクトリのindex.phpは、アプリケーションへ送信された、全HTTPリクエストを始めに処理するフロントコントローラとして動作します。After installing Laravel, you should configure your web server's document / web root to be the public directory. The index.php in this directory serves as the front controller for all HTTP requests entering your application.

設定ファイルConfiguration Files

フレームワークで使用する設定ファイルは全て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.

ディレクトリパーミッションDirectory Permissions

Laravelをインストールした後に、多少のパーミッションの設定が必要です。storage下とbootstrap/cacheディレクトリをWebサーバから書き込み可能にしてください。設定しないとLaravelは正しく実行されません。Homestead仮想マシンを使用する場合は、あらかじめ設定されています。After installing Laravel, you may need to configure some permissions. Directories within the storage and the bootstrap/cache directories should be writable by your web server or Laravel will not run. If you are using the Homestead[/docs/{{version}}/homestead] virtual machine, these permissions should already be set.

アプリケーションキーApplication Key

次にインストール後に行うべきなのは、アプリケーションキーにランダムな文字列を設定することです。ComposerかLaravelインストーラを使ってインストールしていれば、php artisan key:generateコマンドにより、既に設定されています。The next thing you should do after installing Laravel is set your application key to a random string. If you installed Laravel via Composer or the Laravel installer, this key has already been set for you by the php artisan key:generate command.

通常、この文字列は32文字にすべきです。キーは.env環境ファイルに設定されます。もし、.env.exampleファイルをまだ.envにリネームしていなければ、今すぐ行ってください。アプリケーションキーが設定されていなければ、ユーザーセッションや他の暗号化済みデーターは安全ではありません!Typically, this string should be 32 characters long. The key can be set in the .env environment file. If you have not renamed the .env.example file to .env, you should do that now. If the application key is not set, your user sessions and other encrypted data will not be secure!

その他の設定Additional Configuration

Laravelのその他の設定は、最初に指定する必要がありません。すぐに開発を開始しても大丈夫です! しかし、config/app.phpファイルと、その中の記述を確認しておいたほうが良いでしょう。アプリケーションに合わせ変更したい、timezonelocalのような多くのオプションが含まれています。Laravel needs almost no other 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 application.

以下のようなLaravelのコンポーネントについても、設定しておいたほうが良いでしょう。You may also want to configure a few additional components of Laravel, such as:

- [キャッシュ](/docs/{{version}}/cache#configuration) - [データベース](/docs/{{version}}/database#configuration) - [セッション](/docs/{{version}}/session#configuration)

Webサーバ設定Web Server Configuration

きれいなURLPretty URLs

ApacheApache

URLパスにフロントコントローラのindex.phpを付けなくても良いように、Laravelはpublic/.htaccessファイルを用意しています。LaravelをApache上で動作させるときは、確実にmod_rewriteモジュールを有効に設定し、そのサーバで.htaccessファイルを動作させます。Laravel includes a public/.htaccess file that is used to provide URLs without the index.php front controller in the path. Before serving Laravel with Apache, be sure to enable the mod_rewrite module so the .htaccess file will be honored by the server.

Laravelに用意されている.htaccessファイルが、インストールしたApacheで動作しない場合は、以下の代替設定を試してください。If the .htaccess file that ships with Laravel does not work with your Apache installation, try this alternative:

Options  FollowSymLinks -Indexes
RewriteEngine On

RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

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

NginxNginx

Nginxを使用する場合は、全てのリクエストがindex.phpフロントコントローラへ集まるように、サイト設定に以下のディレクティブを使用します。If you are using Nginx, the following directive in your site configuration will direct all requests to the index.php front controller:

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

HomesteadValetを使用する場合は、きれいなURLの設定は自動的に行われます。When using Homestead[/docs/{{version}}/homestead] or Valet[/docs/{{version}}/valet], pretty URLs will be automatically configured.

章選択

設定

明暗テーマ
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!…]形式の挿入削除行の表示形式です。

Pagination和文
ペジネーション
ペギネーション
ページネーション
ページ付け
Scaffold和文
スカフォールド
スキャフォールド
型枠生成
本文フォント

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

コードフォント

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

保存内容リセット

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

ヘッダー項目移動

キーボード操作