Sunday, December 30, 2012

FuelPHP 2. Start after Installation

Start

I followd this tutorial http://ucf.github.com/fuelphp-crash-course/

1. Create a database


    uncomment the orm package in the app/config/config.php




return array(

'default_timezone'   => 'Asia/Seoul',

'always_load'  => array(
'packages'  => array(
'orm',
),
),
);



    create a database with any name, say fuel_dev

        mysql> create database fuel_dev;

    update the app/config/development/db.php

        return array(
            'default' => array(
                'connection'  => array(
                    'dsn'        => 'mysql:host=localhost;dbname=fuel_dev',
                    'username'   => 'xyz',
                    'password'   => '12345',
                ),
            ),
        );

2. Scaffolding

    Use oil to generate a scaffolding which fills the database with a table and creates some fuel runnable codes

        J:/vhosts/words> php oil generate scaffold messages name:string message:text

    Here, string is varchar(255)
    Some fields are automatically added
    Those added fields are id(int, 11, auto_increment), created_at(int, 11), and updated_at(int, 11)

    It does not create a real table in the database, but just a schema as a file

3. Migration


    To create a real database table, do migration

        J:/vhosts/words> php oil refine migrate

    That will create a real table named messages
    And another table is created named migration


No comments:

Post a Comment