LoginSignup
3
7

More than 5 years have passed since last update.

MacにLaravel+Homesteadの環境を整える2018年2月時点

Last updated at Posted at 2018-02-25

この記事について

LaravelHomesteadも知らないので環境構築にあたり忘れないように手銃をメモ。Homesteadのインストールと、quickstartのTODOアプリ起動まで。2018年2月時点の最新と思われる情報を元にしている。

手順

前提

  • Laravelは5.6
  • Homesteadは7.1.2
  • VirtualBoxとVagrantはインストール済み

コマンド等

注:ほぼ https://readouble.com/laravel/5.6/ja/homestead.html の内容

Homestead Vagrant Box のインストール

これはかなり時間がかかるのでどこかに出かけてても良いのでは :wink:

$ vagrant box add laravel/homestead

Homestead のインストール

↑で入れたHomestead Vagrant Boxとは異なるものなのでこれも入れる

$ git clone https://github.com/laravel/homestead.git ~/Homestead
$ cd Homestead/
$ git checkout v7.1.2
$ bash init.sh

最後の bash init.shHomestead.yaml ファイルが作成される。

quickstartのアプリを起動させる

github.com で公開されている https://github.com/laravel/quickstart-basic のTODOリストを作成するアプリを試しに起動させるまで

ソースのダウンロードとEclipseの設定

git clone https://github.com/laravel/quickstart-basic.git quickstart-basic

この後、Eclipseに綺麗に取り込む方法がわからなかったので :cry: .project ファイルを手で作成。プロジェクト名は laravel-quickstart-basic にし、Eclipse上の既存プロジェクトのインポート機能でインポート。

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>laravel-quickstart-basic</name>
    <comment></comment>
    <projects>
    </projects>
    <buildSpec>
        <buildCommand>
            <name>org.eclipse.php.composer.core.builder.buildPathManagementBuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>org.eclipse.wst.common.project.facet.core.builder</name>
            <arguments>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>org.eclipse.wst.validation.validationbuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>org.eclipse.dltk.core.scriptbuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>org.eclipse.php.core.PHPNature</nature>
        <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
    </natures>
</projectDescription>

Homestead の設定

Homestead.yaml ファイルを編集してTODOアプリを反映させる。http://quickstart.test でブラウザからアクセスできるように設定。当然 hosts ファイルにもエントリを追加

folders:
    - map: ~/workspace/quickstart-basic
      to: /home/vagrant/quickstart-basic
sites:
    - map: quickstart.test
      to: /home/vagrant/quickstart-basic/public

/etc/hosts ファイルに以下エントリーを追加

192.168.10.10  quickstart.test

Vagrantの起動とデータベースmigrate

$ vagrant up

仮想マシンが起動したらSSHでログインしてmigrateを実行

$ vagrant ssh
vagrant@homestead$ cd quickstart-basic/
vagrant@homestead$ php artisan migrate

ブラウザからアクセス http://quickstart.test して、TODOアプリ画面が表示されればOK

3
7
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
3
7