Paver
A PHP package mainly developed for Laravel to generate PHP codes using column names of specified table., (*1)
Example
$item->id = '';
$item->title = '';
$item->created_at = '';
$item->updated_at = '';
Installation&setting for Laravel
After installation using composer, add the followings to the array in app/config/app.php, (*2)
'providers' => array(
...Others...,
'Sukohi\Paver\PaverServiceProvider',
)
Also, (*3)
'aliases' => array(
...Others...,
'Paver' =>'Sukohi\Paver\Facades\Paver',
)
Usage
Basic setting, (*4)
$paver = Paver::table('table_name');
// Example
$paver = Paver::table('items');
Minimal way, (*5)
echo $paver->format();
// Example
$item->id = '';
$item->title = '';
$item->created_at = '';
$item->updated_at = '';
with Argument(s), (*6)
echo $paver->format('argument');
// Example
$item->id = $id;
$item->title = $title;
$item->created_at = $created_at;
$item->updated_at = $updated_at;
with Input::get('***'), (*7)
echo $paver->format('input');
// Example
$item->id = Input::get('id');
$item->title = Input::get('title');
$item->created_at = Input::get('created_at');
$item->updated_at = Input::get('updated_at');
with foreach(), (*8)
echo $paver->format('foreach');
// Example
$id = $item->id;
$title = $item->title;
$created_at = $item->created_at;
$updated_at = $item->updated_at;
Json, (*9)
echo $paver->format('json');
// Example
["id","title","position","created_at","updated_at"]
Array, (*10)
echo $paver->format('array');
// Example
$columns = ['id', 'title', 'position', 'created_at', 'updated_at'];
Custom format, (*11)
You can also use custom formats like this., (*12)
echo $paver->format(':table and :column.');
// Example
item and id.
item and title.
item and created_at.
item and updated_at.
- :table will be replaced with singular table name.
- :column will be replaced with a column name of the specified table.
License
This package is licensed under the MIT License., (*13)
Copyright 2014 Sukohi Kuhoh, (*14)