Readouble

Laravel 5.dev Laravel Homestead

イントロダクションIntroduction

Laravelはローカルでの開発環境を含め、PHP開発全体の経験を愉快なものにしようと努めています。Vagrantは、仮想マシーンの管理と事前設定を行う、簡単でエレガントな方法を提供しています。Laravel strives to make the entire PHP development experience delightful, including your local development environment. Vagrant[http://vagrantup.com] provides a simple, elegant way to manage and provision Virtual Machines.

Laravel Homestead(入植農地、「ホームステード」)は、事前にパッケージされた公式の"box"で、PHPやHHVM、Webサーバー、その他のサーバーソフトウェアをローカルマシンにインストールする必要なく、素晴らしい開発環境を準備します。オペレーティングシステムに関して、ごちゃごちゃになる心配は、もうありません! Vagrantのboxは、完全に使い捨て可能です。何かの調子が悪くなれば壊して、数分のうちにそのboxを再生成できます!Laravel Homestead is an official, pre-packaged Vagrant "box" that provides you a wonderful development environment without requiring you to install PHP, HHVM, a web server, and any other server software on your local machine. No more worrying about messing up your operating system! Vagrant boxes are completely disposable. If something goes wrong, you can destroy and re-create the box in minutes!

Homesteadは、Windows、Mac、Linuxシステムで実行でき、Nginx Webサーバー、PHP5.6、MySQL、Postgres、Redis、Memcachedやその他、素晴らしいLaravelアプリケーションを開発するために必要な全てのクールなツールを含んでいます。Homestead runs on any Windows, Mac, or Linux system, and includes the Nginx web server, PHP 5.6, MySQL, Postgres, Redis, Memcached, and all of the other goodies you need to develop amazing Laravel applications.

注意: Windowsを使用している場合は、ハードウェア仮想化(VT-x)を有効にする必要があります。通常、BIOSにより有効にできます。Note: If you are using Windows, you may need to enable hardware virtualization (VT-x). It can usually be enabled via your BIOS.

Homesteadは現在、Vagrant1.6上で構築・テストされています。Homestead is currently built and tested using Vagrant 1.6.

パッケージされているソフトウェアIncluded Software

  • Ubuntu 14.04Ubuntu 14.04
  • PHP 5.6PHP 5.6
  • HHVMHHVM
  • NginxNginx
  • MySQLMySQL
  • PostgresPostgres
  • Node(BowerとGrunt、Gulpも含む)Node (With Bower, Grunt, and Gulp)
  • RedisRedis
  • MemcachedMemcached
  • BeanstalkdBeanstalkd
  • Laravel EnvoyLaravel Envoy[/docs/ssh#envoy-task-runner]
  • Fabric HipChat拡張Fabric HipChat Extension

インストールと準備Installation & Setup

VirtualBoxとVagrantのインストールInstalling VirtualBox & Vagrant

Homestead環境を起動する前に、VirtualBoxVagrantをインストールする必要があります。両ソフトウェア共に、簡単に使用できるビジュアルなインストーラーが、人気のあるオペレーティングシステム全部に用意されています。Before launching your Homestead environment, you must install VirtualBox[https://www.virtualbox.org/wiki/Downloads] and Vagrant[http://www.vagrantup.com/downloads.html]. Both of these software packages provide easy-to-use visual installers for all popular operating systems.

Vagrant Boxの追加Adding The Vagrant Box

VirtualBoxとVagrantをインストールし終えたら、laravel/homestead boxをVagrantへ追加するために、以下のコマンドを端末で実行する必要があります。boxをダウンロードし終えるまで、接続速度にもよりますが、数分かかるでしょう。Once VirtualBox and Vagrant have been installed, you should add the laravel/homestead box to your Vagrant installation using the following command in your terminal. It will take a few minutes to download the box, depending on your Internet connection speed:

vagrant box add laravel/homestead

HomesteadのインストールInstalling Homestead

Gitから入手(ローカルにPHP無し)Manually Via Git (No Local PHP)

ローカルマシーンにPHPをインストールしたくなければ、シンプルにリポジトリーをクローンし、Homesteadを自分でインストールする方法が取れます。自分の「ホーム」ディレクトリーの中のHomesteadフォルダーへリポジトリーをクローンするのは、自分のLaravel(とPHP)の全プロジェクトをホストしておくための、Homestead Boxを用意するのだと考えてください。Alternatively, if you do not want to install PHP on your local machine, you may install Homestead manually by simply cloning the repository. Consider cloning the repository into a Homestead folder within your "home" directory, as the Homestead box will serve as the host to all of your Laravel (and PHP) projects:

git clone https://github.com/laravel/homestead.git Homestead

Homesteadコマンドラインツールがインストール済みであれば、bash init.shコマンドでHomestead.yaml設定ファイルを生成できます。Once you have installed the Homestead CLI tool, run the bash init.sh command to create the Homestead.yaml configuration file:

bash init.sh

Homestead.yamlファイルは、皆さんの~/.homesteadディレクトリーへ設置されます。The Homestead.yaml file will be placed in your ~/.homestead directory.

ComposerとPHPツールの利用With Composer PHP Tool

Vagrantへboxを追加し終えたら、ComposerのglobalコマンドでHomestead CLIツールをインストールする準備が整いました。Once the box has been added to your Vagrant installation, you are ready to install the Homestead CLI tool using the Composer global command:

composer global require "laravel/homestead=~2.0"

端末からhomesteadコマンドを実行するときに、実行形式ファイルが見つかるように、~/.composer/vendor/binディレクトリーへ実行パスを確実に通してください。Make sure to place the ~/.composer/vendor/bin directory in your PATH so the homestead executable is found when you run the homestead command in your terminal.

Homestead CLIツールをインストールし終えたら、initコマンドを実行し、Homestead.yaml設定ファイルを生成します。Once you have installed the Homestead CLI tool, run the init command to create the Homestead.yaml configuration file:

homestead init

Homestead.yamlファイルは~/.homesteadディレクトリーに設置されています。MacかLinuxシステムを使用している場合、homestead editコマンドを端末で実行すれば、編集が行えます。The Homestead.yaml file will be placed in the ~/.homestead directory. If you're using a Mac or Linux system, you may edit Homestead.yaml file by running the homestead edit command in your terminal:

homestead edit

SSHキーの設定Set Your SSH Key

次に、Homestead.yamlファイルを編集します。このファイルで、publicのSSHキーへのパスを設定でき、またメインマシーンと、Homestead仮想マシーンとの間で共有するフォルダーも指定できます。Next, you should edit the Homestead.yaml file. In this file, you can configure the path to your public SSH key, as well as the folders you wish to be shared between your main machine and the Homestead virtual machine.

SSHキーを持っていない? 一般的にMacとLinuxでは、以下のコマンドを使用し、SSHキーペアを生成できます。Don't have an SSH key? On Mac and Linux, you can generally create an SSH key pair using the following command:

ssh-keygen -t rsa -C "you@homestead"

Windowsでは、Gitをインストールし、Gitコマンドを実行するためのGit Bashシェルを使用します。別の方法として、PuTTYPuTTYgenを使うこともできます。On Windows, you may install Git[http://git-scm.com/] and use the Git Bash shell included with Git to issue the command above. Alternatively, you may use PuTTY[http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html] and PuTTYgen[http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html].

SSHキーを作成したら、Homestead.yamlファイルの、authorizeプロパティーへ、キーのパスを指定してください。Once you have created a SSH key, specify the key's path in the authorize property of your Homestead.yaml file.

共有フォルダーの設定Configure Your Shared Folders

Homestead.yamlファイルのfoldersプロパティーには、Homestead環境と共有したい全フォルダーがリストされています。これらのフォルダーの中のファイルが変更されると、ローカルマシーンとHomestead環境との間で同期されます。必要なだけ共有フォルダーを設定してください!The folders property of the Homestead.yaml file lists all of the folders you wish to share with your Homestead environment. As files within these folders are changed, they will be kept in sync between your local machine and the Homestead environment. You may configure as many shared folders as necessary!

Nginxサイトの設定Configure Your Nginx Sites

Nginxには詳しくない? 問題ありません。sitesプロパティーで、Homestead環境上のフォルダーと「ドメイン」を簡単にマップできます。サイト設定のサンプルは、Homestead.yamlファイルに含まれています。ここでも必要に応じ、Homestead環境中のサイトを好きなだけ追加してください。便利なように、Homesteadは皆さんが作業を行う、全てのLaravelプロジェクトの仮想環境を提供します!Not familiar with Nginx? No problem. The sites property allows you to easily map a "domain" to a folder on your Homestead environment. A sample site configuration is included in the Homestead.yaml file. Again, you may add as many sites to your Homestead environment as necessary. Homestead can serve as a convenient, virtualized environment for every Laravel project you are working on!

hhvmオプションをtrueに設定すれば、簡単にHomesteadサイトでHHVMが使えるようになります。You can make any Homestead site use HHVM[http://hhvm.com] by setting the hhvm option to true:

sites:
    - map: homestead.app
      to: /home/vagrant/Code/Laravel/public
      hhvm: true

BashエイリアスBash Aliases

BashエイリアスをHomestead boxに追加するには、~/.homesteadディレクトリーのルートに、aliasesファイルを追加するだけです。To add Bash aliases to your Homestead box, simply add to the aliases file in the root of the ~/.homestead directory.

Vagrant boxを起動するLaunch The Vagrant Box

Homestead.yamlのリンクを編集終えたら、Homesteadディレクトリーでvagrant upコマンドを実行してください。Once you have edited the Homestead.yaml to your liking, run the vagrant up command from your Homestead directory.

Vagrantは仮想マシーンを起動し、共有フォルダーとNginxサイトを自動的に設定します!仮想マシーンを破壊するには、vagrant destroy --forceコマンドを使用します。Vagrant will boot the virtual machine, and configure your shared folders and Nginx sites automatically! To destroy the machine, you may use the vagrant destroy --force command.

Nginxサイトの「ドメイン」をメインマシーンのhostsファイルに追加するのを忘れないでください! hostsファイルは、ローカルドメインへのリクエストをHomestead環境へリダイレクトしてくれます。MacとLinuxでは、このファイルは/etc/hostsにあります。Windowsでは、C:\Windows\System32\drivers\etc\hostsにあります。以下のような行をファイルへ追加してください。Don't forget to add the "domains" for your Nginx sites to the hosts file on your machine! The hosts file will redirect your requests for the local domains into your Homestead environment. On Mac and Linux, this file is located at /etc/hosts. On Windows, it is located at C:\Windows\System32\drivers\etc\hosts. The lines you add to this file will look like the following:

192.168.10.10  homestead.app

このIPアドレスを確実にHomestead.yamlファイルで指定してください。hostsファイルへドメインを追加したら、Webサーバーからサイトへアクセスできます!Make sure the IP address listed is the one you set in your Homestead.yaml file. Once you have added the domain to your hosts file, you can access the site via your web browser!

http://homestead.app

データベースに接続する方法を学ぶには、続けて読んでください!To learn how to connect to your databases, read on!

使用方法Daily Usage

SSHによる接続Connecting Via SSH

Homestead環境にSSHで接続するには、Homesteadディレクトリーでvagrant sshコマンドを実行してください。To connect to your Homestead environment via SSH, issue the vagrant ssh command from your Homestead directory.

Homesteadマシンへ頻繁に接続するでしょうから、ホストマシンの「エイリアス」を作成することを考えてください。Since you will probably need to SSH into your Homestead machine frequently, consider creating an "alias" on your host machine:

alias vm="ssh vagrant@127.0.0.1 -p 2222"

このエイリアスを設定すると、システムのどこにいようと、"vm"コマンドを使ってHomesteadマシンへSSH接続できます。Once you create this alias, you can simply use the "vm" command to SSH into your Homestead machine from anywhere on your system.

データベースへの接続Connecting To Your Databases

homesteadのデータベースは、最初からMySQLとPostgresのために設定されています。より便利にするために、Laravelのlocalデータベース設定がデフォルトで使用できるように設定されています。A homestead database is configured for both MySQL and Postgres out of the box. For even more convenience, Laravel's local database configuration is set to use this database by default.

MySQLかPostgresデータベースに接続するには、メインマシーンからNavicatかSequel Proを使い、127.0.0.1の33060(MySQL)番ポートか、54320(Postgres)番ポートへ接続してください。ユーザー名とパスワードは、両方共にhomestead/secretです。To connect to your MySQL or Postgres database from your main machine via Navicat or Sequel Pro, you should connect to 127.0.0.1 and port 33060 (MySQL) or 54320 (Postgres). The username and password for both databases is homestead / secret.

**注意:**メインマシーンから、データベースへ接続するには、標準的ではないポートだけを使用してください。Laravelのデータベース設定ファイル中では、デフォルトの3306と5432ポートを使用することができます。Laravelは仮想マシーンの内部で動作しているからです。Note: You should only use these non-standard ports when connecting to the databases from your main machine. You will use the default 3306 and 5432 ports in your Laravel database configuration file since Laravel is running within the Virtual Machine.

サイトを追加するAdding Additional Sites

Homestead環境が準備され、実働した後に、LaravelアプリケーションをNginxサイトへ追加したいこともあるでしょう。希望するだけの数のNginxサイトをLaravelアプリケーションに追加し、一つのHomestead環境上で実行することができます。これには2つの方法があります。最初の方法は、シンプルにHomestead.yamlファイルへサイトを追加し、それからvagrant provisionを実行してください。Once your Homestead environment is provisioned and running, you may want to add additional Nginx sites for your Laravel applications. You can run as many Laravel installations as you wish on a single Homestead environment. There are two ways to do this: First, you may simply add the sites to your Homestead.yaml file and then run vagrant provision.

別の方法は、Homestead環境で使用できる、serveスクリプトを使用します。serveスクリプトを使用するには、Homestead環境へSSHで接続し、以下のコマンドを実行してください。Alternatively, you may use the serve script that is available on your Homestead environment. To use the serve script, SSH into your Homestead environment and run the following command:

serve domain.app /home/vagrant/Code/path/to/public/directory

注目: serveコマンドを実行した後は、新しいサイトをメインマシーンのhostsファイルへ追加するのを忘れずに!Note: After running the serve command, do not forget to add the new site to the hosts file on your main machine!

ポートPorts

以下のポートが、Homestead環境へポートフォワードされています。The following ports are forwarded to your Homestead environment:

  • SSH: 2222 → フォワード先 22SSH: 2222 → Forwards To 22
  • HTTP: 8000 → フォワード先 80HTTP: 8000 → Forwards To 80
  • MySQL: 33060 → フォワード先 3306MySQL: 33060 → Forwards To 3306
  • Postgres: 54320 → フォワード先 5432Postgres: 54320 → Forwards To 5432

章選択

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に保存してある設定項目をすべて削除し、デフォルト状態へ戻します。

ヘッダー項目移動

キーボード操作