1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Laravel PHP を触る

Last updated at Posted at 2015-07-14

環境

  • Mac
  • Laravel 5.0.0

http://readouble.com/laravel/5/0/0/ja/installation.html を参考にインストールしていきます。

Composer のインストール

$ curl -sS https://getcomposer.org/installer | php
# !/usr/bin/env php
All settings correct for using Composer
Downloading...

Composer successfully installed to: /Users/yoshiyuki_sakamoto/php/composer.phar
Use it: php composer.phar

$ mv composer.phar /usr/local/bin
$ sudo ln -s /usr/local/bin/composer.phar /usr/local/bin/composer

動かしてみる

$ composer                                                                                                              [master]
   ______
  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                    /_/

...

Laravelのインストール

composer global require "laravel/installer=~1.1"

~/.composer/ というディレクトリができたと思います。 ~/.composer/vendor/bin/laravel を実行できるようにするため、 /usr/local/bin/laravel にシンボリックリンクを貼ります。

$ sudo ln -s ~/.composer/vendor/bin/laravel /usr/local/bin/laravel
$ laravel
Laravel Installer version 1.2.1

...

使ってみる

$ laravel new laravel-test
Crafting application...

...

Application ready! Build something amazing.

これで laravel-test ディレクトリが出来上がる。 public/index.php がルーティングのphpなので、(index.pxpはpublicの中に置かれるのが一般的なようだ)以下のようにシンボリックリンク張った。

$ sudo ln -s /Users/.../laravel-test/public /Library/WebServer/Documents/laravel

私のPCにはApacheがインストール済みで、mod_rewrite も有効になっている。これらが有効になっていない場合は有効にして欲しい。
そして、 localhost/laravel にアクセスしてみると、真っ白だ…

storage ディレクトリ(おそらくログなどのディレクトリ)にApacheの書き込み権限を与えてやる必要があるようだ。Macの場合は、デフォルトのApacheのユーザー名は _www だ。ubuntuとかの場合は違ったはず。

$ sudo chown -R _www storage

これで localhost/laravel/ にアクセスすると Laravel 5 とだけ書かれたページが表示される。

感想とか

まず、 app の中身を見てみたが、よくあるような models, controllers のようなディレクトリはなく、見慣れないディレクトリが存在していた。どうやらviewとかはあるようだ。

resources/assets の中には sass というディレクトリがある。 css ではなくいきなりsassのディレクトリが用意されているのは珍しい...プリコンパイルとかしてくれるのだろうか。

Laravel のベースは Symfony になっているらしく、Symfony を今風にしたような感じらしい。ディレクトリ構造からも、いろいろ便利そうな機能がありそうで好感触である。

1
2
2

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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?