2017 © Pedro Peláez
 

library framework

Chai is a framework of useful tools

image

chai/framework

Chai is a framework of useful tools

  • Wednesday, July 10, 2013
  • by mloberg
  • Repository
  • 1 Watchers
  • 0 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Chai

Chai is a collection of tools to aid in the development of PHP applications. It aims to be easy to use and completely framework agnostic. It utilizes components from other frameworks and libraries, so as not to re-invent the wheel., (*1)

Requirements

  • PHP 5.3 or greater
  • Composer

Components

Migrations

Migrations allow you to "version control" your database. You can create tables, update tables, or perform other actions. Most migration systems have an up and down method. The up method does the desired action such as creating or updating a table. The down method does the opposite allowing you to run migrations multiple times without any issues. In addition, Chai has an update method that is ran if the migration has already been applied., (*2)

Getting Started

To get started using migrations, you will need to create a console script (bin/console)., (*3)

<?php

//use Symfony\Component\Console\Application;
use Chai\Console\Application;
use Chai\Migrations\Migrations;

$migrations = new Migrations();
$migrations->setMigrationsDirectory(__DIR__.'/../app/database/migrations');
$migrations->setDatabaseParameters(array(
    'host' => '',
    'port' => '',
    'username' => '',
    'password' => '',
    'database' => '',
));

$app = new Application('Description', '0.1.0');
$app->register($migrations);
$app->run();

Then run bin/console migration:init, which will create the migrations table., (*4)

Creating Migrations

You cna create a migration using the console application., (*5)

bin/console migration:create <name>, (*6)

Migration names must be all lowercase, using underscores (_) as seperators, and not begin with a number., (*7)

Valid Migration Names, (*8)

  • create_user_table
  • update_post_table
  • add_index_to_metadata_table
  • test_migration_2

Invalid Migration Names, (*9)

  • CreateTable
  • Add Post Table
  • 1test_migration

All migrations are prefixed with a timestamp. This is to keep migrations unique and to know which order they are to be ran in., (*10)

A basic migration looks like:, (*11)

<?php

use Chai\Migrations\BaseMigration;

class TestMigration extends BaseMigration
{

    public function up()
    {
        // Do something here
    }

    public function down()
    {
        // Do the opposite here
    }

    public function update()
    {
        // Do something only if the
        // migration has already been ran
    }

}

Running Migrations

bin/console migration:up [name], (*12)

bin/console migration:down [name], (*13)

Status

bin/console migration:status, (*14)

The Versions

10/07 2013

dev-master

9999999-dev

Chai is a framework of useful tools

  Sources   Download

The Requires

 

The Development Requires

10/07 2013

v0.0.1

0.0.1.0

Chai is a framework of useful tools

  Sources   Download

The Requires

 

The Development Requires