LoginSignup
8

More than 5 years have passed since last update.

[備忘録] MacにLaravelをインストールする

Last updated at Posted at 2018-09-22

概要

PHPで簡単なウェブサイトを開発中にやりたいことができずに詰まっていたので友人のススメでLaravelをインストールすることにした。

環境について

PHP Mac OS
7.1.16 Mac OS High Sierra (10.13.6)

composerインストール

$ brew install homebrew/core/composer

Laravelのinstall

$ composer global require "laravel/installer"

インストール中のログ (操作は不要)

Using version ^2.0 for laravel/installer
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 10 installs, 0 updates, 0 removals
  - Installing symfony/process (v4.1.4): Downloading (100%)         
  - Installing symfony/polyfill-ctype (v1.9.0): Downloading (100%)         
  - Installing symfony/filesystem (v4.1.4): Downloading (100%)         
  - Installing symfony/polyfill-mbstring (v1.9.0): Downloading (100%)         
  - Installing symfony/console (v4.1.4): Downloading (100%)         
  - Installing guzzlehttp/promises (v1.3.1): Downloading (100%)         
  - Installing psr/http-message (1.0.1): Downloading (100%)         
  - Installing guzzlehttp/psr7 (1.4.2): Downloading (100%)         
  - Installing guzzlehttp/guzzle (6.3.3): Downloading (100%)         
  - Installing laravel/installer (v2.0.1): Downloading (100%)         
symfony/console suggests installing psr/log-implementation (For using the console logger)
symfony/console suggests installing symfony/event-dispatcher
symfony/console suggests installing symfony/lock
guzzlehttp/guzzle suggests installing psr/log (Required for using the Log middleware)
Writing lock file
Generating autoload files

パスを通す

$ export PATH="$PATH:$HOME/.composer/vendor/bin"

一度読み込む

$ source ~/.bashrc

プロジェクト作成

laravel newコマンドで、プロジェクト。

$ laravel new {プロジェクト名}

{プロジェクト名}の部分を作成したプロジェクト名に書き換える

今回はSampleとする

具体例

$ laravel new Sample

インストール中

[追記]

2回目以降のプロジェクト作成では作成できなかったので、下記のコマンドでプロジェクトファイルを作成できる。

$ composer create-project --prefer-dist laravel/laravel SampleProject

or

$ composer create-project laravel/laravel SampleProject --prefer-dist

これでSampleProjectを作成できる

laravelのバージョンを指定してプロジェクトを作成する

laravel 5.5 系のプロジェクトファイルを作成する

$ composer create-project "laravel/laravel=5.5.*" sampleproject
  • sampleprojectプロジェクト名で任意の名前でOK。

すると 5.5.X のバージョンのプロジェクトファイルを作成できる。

$ php artisan -V
Laravel Framework 5.5.43

これがしたかった。

ローカル開発サーバ起動

インストールが終了後

$ cd Sample

にて、Sampleフォルダに移動してから、

$ php artisan serve

を叩くと

Laravel development server started: <http://127.0.0.1:8000>

とログが表示される。

http://127.0.0.1:8000にアクセスするとページが表示される

スクリーンショット 2018-09-22 21.35.14.png

インストール完成である。

バージョンの確認

$ php artisan -V

もしくは

$ php artisan --version

で確認できる

Laravel Framework 5.7.5

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
8