27
26

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を使ってみる。インストールから簡単なアプリまで。【1】

Last updated at Posted at 2013-07-13

http://laravel.com/docs/quick
で5分でできるって言っているのでやってみよう。
MacOSX上、アプリ名はgateという名前にしている。何でも良いけど。

インストール

$ composer create-project laravel/laravel gate --prefer-dist
-bash: composer: command not found

早速躓いた。composerって何だろう。

http://www.ryuzee.com/contents/blog/5681
によると、コンポーネントのインストールの仕組みの様子。

どうやら下記の方法でインストールするようだが…?

 $ curl -s http://getcomposer.org/installer | php
# !/usr/bin/env php
Some settings on your machine make Composer unable to work properly.
Make sure that you fix the issues listed below and run this script again:

The detect_unicode setting must be disabled.
Add the following to the end of your `php.ini`:
    detect_unicode = Off

The php.ini used by your command-line PHP is: /private/etc/php.ini
If you can not modify the ini file, you can also run `php -d option=value` to modify ini values on the fly. You can use -d multiple times.

「detect_unicodeはdisabledですよ!」と怒っている。

sudo vi /private/etc/php.ini

して、php.iniの最終行に
detect_unicode = Off

再度実行。

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

Composer successfully installed to: /Users/xxx/xxx/projects/larabel/composer.phar
Use it: php composer.phar

Good!。
php composer.phar
で利用できるらしい。

 $ composer create-project laravel/laravel gate --prefer-dist
-bash: composer: command not found
 $ php composer.phar create-project laravel/laravel gate --prefer-dist

composerを直接叩けるようにはなっていないので、php composer.pharとした。Install完了までは結構待たされる。symfonyとか入ってる。そういうものなのですか。使った事無いけど。

この時点でgate/publicのディレクトリをhtdocsに割り当てると「You have arrived.」との表示。これでインストールは終了な様子。12分経過。調べながらやったんだから5分じゃ無いけど勘弁して欲しい。

カスタマイズ

ドキュメントの真似をする。

app/controllers/UserController.php
<?php

class UserController extends BaseController {

	public function getIndex()
	{
		return View::make('user');
	}

}

app/routes.php
<?php
Route::get('/', function()
{
	return View::make('hello');
});

Route::get('users', 'UserController@getIndex');
app/views/user.php
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>User</title>
</head>
<body>
    User
</body>
</html>

してみたら、/usersで無事に画面に「User」と表示された。
http://qiita.com/ms2sato/items/5e597763cb034cad8c08
へ続く。

27
26
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
27
26

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?