LoginSignup
9
9

More than 5 years have passed since last update.

laravelを使ってみる。インストールから簡単なアプリまで。【2】

Last updated at Posted at 2013-07-13

http://qiita.com/ms2sato/items/3fe8db44be76647ed7a9
の続き

# マイグレーション
app/config/database.php
を修正して自分の環境に合わせた。

下記をやってみる。

$ php artisan migrate:make create_users_table
Laravel requires the Mcrypt PHP extension.

Mcryptというのを入れれば良いらしいがちょっと調べたら下記が引っかかった。MAMP入れていれば入っているようだからパスを設定すれば大丈夫とのこと。
http://stackoverflow.com/questions/16830405/laravel-requires-the-mcrypt-php-extension

自分の所は5.4.3が入っていたので合わせて修正。

.bash_profile
export PATH=/Applications/MAMP/bin/php/php5.4.3/bin:$PATH

コンソール再起動。

$ php artisan migrate:make create_users_table
Created Migration: 2013_07_13_095102_create_users_table
Generating optimized class loader
Compiling common classes

無事に作成できた。

マイグレーションのファイルを修正する。
どんな型が使えるかは下記を参照
http://laravel.com/docs/schema

2013_07_13_095102_create_users_table.php
<?php

use Illuminate\Database\Migrations\Migration;

class CreateUsersTable extends Migration {

    public function up() {
        Schema::create('users', function($table) {
                    $table->increments('id');
                    $table->string('serial')->unique();
                    $table->integer('status');
                    $table->timestamps();
                });
    }

    public function down() {
        Schema::drop('users');
    }

}

準備ができたのでマイグレーション実行。

$ php artisan migrate
Migration table created successfully.
Migrated: 2013_07_13_095102_create_users_table

続くかも?

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