Rapyd ユーザーガイド
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
[[Rapyd]]
#contents
* ダウンロード [#c3518d56]
以下のURLから「Rapyd」をダウンロードして、解凍すると中に...
- http://code.google.com/p/rapyd-framework/
- http://code.google.com/p/rapyd-framework/downloads/deta...
* rapyd 0.8 guide [#b1489429]
Minimalistic PHP Framework for Backends
User Guide v. 0.8
* Overview [#b47bc511]
Rapyd is minimalistic php framework made to build applica...
Its based on a widespread pattern: MVC (Model, View, Cont...
Since 0.8 It support also HMVC (Hierarchical MVC)
It's inspired by CodeIgniter and KohanaPHP.
Rapyd is probably less mature, but give it a chance.
* Features [#dd623a15]
- No compiling, no command line needed, just unzip, it sh...
- Widget oriented architecture (grids, forms, tables, etc...
- Simple syntax, oriented to build simple (or complex) da...
- Modules support (each module is just “reply” of the app...
- you can integrate rapyd with any other php script (like...
- Nice URLs / SEO oriented (since 0.8 the framework does ...
- Really open source (MIT licensed)
* Installation [#tc97ae97]
** System Requirements [#tc108637]
1. PHP 5.1 or higher (required)
2. pdo-sqlite3 to run samples (it support also mySQL, pos...
3. apache webserver with mod_rewrite enabled (for really ...
** Configuration & Deployment [#cbcdabed]
You must configure the application in /application/config...
Rapyd comes with a Demo module (with several examples of ...
but remember, you should remove the demo folder on produc...
* URLs and Flow [#zf3d67b8]
** Rapyd URLs [#b3bd06d1]
Rapyd uses URI (uniform resource identifiers) to determin...
So instead classic “php application” urls:
http://site.com/welcome.php
http://site.com/register.php?step=1
It use:
http://site.com/index.php/welcome/index
http://site.com/index.php/registration/step/1
'''(and with a simple .htaccess and mod_rewrite enabled “...
In an mvc framework there is a system gateway: the only s...
In the above examples rapyd will work as follows:
- instancing a class*: the controller “welcome”, then cal...
- instancing a class*: the controller “registration”, the...
'''(* must extend “rpd” class, and must be placed on the:...
So, in a site driven by rapyd framework, to build a “page...
This is enough but a bit poor, so in each MVC framework (...
Models are classes where you should do db-stuffs, and Vie...
A controller can instance and use models, then can pass d...
** Application Flow [#c7d7c91b]
In Rapyd, and other MVC frameworks:
- All non static resources are served by a sistem gateway...
- The gateway detect by uri the needed resource and insta...
- A Controller is a simple class where each Method is a c...
- A Controller Method can send output by echo or print.. ...
- A Controller should be placed in /application/controllers
- A Model should be placed in /application/models
- A View should be placed in /application/views
And the “flow” is:
request > gateway > controller [ > model ] [ > view ] > ...
Note:
Rapyd also support “modules” which are like “sub-applicat...
Note:
In Rapyd, there are also, “Libraries” and “Helpers” (basi...
* Filesystem [#u61d8e8b]
Rapyd Filesystem is clean, “system” is separated from “ap...
Furthermore, you can isolate application pieces in “modul...
If you need to customize “rapyd/libraries” you can build ...
Note:
Rapyd use class autoload, you do not have to worry about ...
* Controller [#pc9b545b]
A controller is a simple php class it must extend rpd sup...
Conventions/rules:
- Class name must end with _controller
- Filename must be minuscase, with the same class name (w...
- File must be deployed in /application/controllers/ (or ...
** Sample [#ta224522]
#code(php){{
<?php
class welcome_controller extends rpd {
function index()
{
$vars = array('varname' => 'value');
echo $this->view('welcome', $vars);
}
function test()
{
echo 'test';
}
}
}}
This request:
''http://site.com/welcome/inex''
will parse the View 'welcome' then the result will be pri...
This other request:
''http://site.com/welcome/test''
will output 'test'
* View [#d5a2510d]
A view is a simple php file with html, php loops, echos e...
Conventions/rules:
- Filename must be minuscase
- File must be deployed in /application/views/ (or in /mo...
** Sample [#zb0d5db9]
#code(php){{
<html>
<head>
<title>Welcome !</title>
</head>
<body>
<h1>Welcome</h1>
<p>This is a simple html file with some php var <?=$v...
</body>
</html>
}}
Note:
If you are thinking “where is smarty?.. I need a template...
my answer is .. No, there isn't a template engine, and yo...
** Sample using view in view... and HMVC! [#h41f2941]
#code(php){{
<?=rpd::view('header', $input_data)?>
<h1>Welcome</h1>
<p>This is a simple html file with some php var <?=$varna...
<h2>user info<h2>
<?=rpd::run('userbox','info', array('short_style'));?>
<?=rpd::view('footer', $input_data)?>
}}
TA-DA!..
''rpd::view'' let you call another view, “$input_data” is...
''rpd::run'' let you call $controller->method($params);
so you can gain a great level of isolation. You can isola...
* Models / DB / Active Record [#n7e60deb]
A Model is a class where you should do db stuffs. In exam...
Using active record way is great to tokenize queries (for...
#code(php){{
<?php
class articles_model extends rpd
{
function __construct()
{
$this->db = rpd::$db;
}
//using simple query
function get_categories()
{
$sql = "SELECT c.category_id as id, COUNT(a.article_id) a...
FROM articles_categories c LEFT JOIN articles a USING(cat...
WHERE c.public = 'y'
GROUP BY c.category_id
ORDER BY c.priority ASC ";
$this->db->query($sql);
if ($this->db->num_rows() > 0)
{
return $this->db->result_array();
} else {
return array();
}
}
//using active record
function get_articles($limit=10, $category="", $rand=false)
{
$this->db->select("a.*");
$this->db->from("articles a");
$this->db->where("a.public","y");
if (is_numeric($category))
{
$this->db->where("a.category_id", $category);
}
if ($rand)
$this->db->orderby("RANDOM()");
else
$this->db->orderby("article_date", "desc");
$this->db->get(null, $limit);
if ($this->db->num_rows() > 0)
{
return $this->db->result_array();
} else {
return array();
}
}
}
}}
* Widgets [#e1b5255e]
Ok, we now know how mvc works, and how to execute queries...
Rapyd is focused to build in few lines of code “CRUD” int...
Each widget extend a basic “component”, and is designed t...
** Widgets semantic [#he4abbd4]
A widget has a behavior driven by “uri segments” (this is...
''http://site.com/index.php/grid/index/pag/2''
''http://site.com/index.php/grid/index/orderby/article_id...
''http://site.com/index.php/grid/index/orderby/article_id...
'''(this show how a datagrid work with offset and order)'''
''http://site.com/index.php/edit/index/show/1''
''http://site.com/index.php/edit/index/modify/1''
''http://site.com/index.php/edit/index/create/1''
'''(this show how a dataedit change editing status)'''
''http://site.com/index.php/filtered_grid/index/search/1/...
'''(this show how datafilter and datagrid work together: ...
*DataGrid widget [#o63bd219]
**Sample [#b0e18b97]
#code(php){{
$grid = new datagrid_library();
$grid->label = 'Article List';
$grid->per_page = 5;
$grid->source('articles');
$grid->column('article_id','ID',true)->url('edit/show/{ar...
$grid->column('title','Title');
$grid->column('body','Body')->callback('escape',$this);
$grid->build();
$data['head'] = $this->head();
$data['content']= $grid->output;
}}
**Properties [#h90e99b1]
| Property | Default Value | Options | Description |
| label | '' | string | label to display for the grid |
| per_page | | integer | the number of records to display...
**Methods [#gff6cdfe]
$grid->source($source)
| $source | - | mixed may be a db-table name, a sql-query...
an associative array matrix |
$grid->column($pattern, $label, $is_orderby)
| $pattern | - | string | field pattern, field name, or c...
| $label | - | string | column label |
| $orderby | - | boolean | if column is sortable |
$grid->build()
build grid, fill $grid->output
* DataFilter widget [#ffc1aecc]
** Sample [#m3e100c1]
#code(php){{
$filter = new datafilter_library();
$filter->label = 'Article Filter';
$filter->db->select("articles.*, authors.*");
$filter->db->from("articles");
$filter->db->join("authors","authors.author_id=articles.a...
$filter->field('input','title','Title')
->attributes(array('style' => 'width:170px'));
$filter->field('radiogroup','public','Public')
->options(array("y"=>"Yes", "n"=>"No"));
$filter->buttons('reset','search');
$filter->build();
$data['head'] = $this->head();
$data['content']= $grid->output;
}}
** Properties [#u57710d1]
| Property | Default Value | Options | Description |
| label | '' | string | label to display for the filter |
** Methods [#t53135f2]
$filter->source($source)
| $source | - | mixed | may be a db-table name, or a sql-...
$filter->field($type, $name, $label)
| $type | - | string | field type (input, password, check...
radiogroup, radio, dropdown, date, editor) |
| $name | - | string | field name, usually the db table f...
where clause |
| $label | - | string | label to display for the field |
$filter->field($type, $name, $label)->attributes($attrib...
| $attributes | - | assoc.array | array of extra attribut...
$filter->field($type, $name, $label)->options($options)
| $options | - | array | array of options (for field type...
$filter->buttons($button1[,$button2...])
| $button n | - | mixed | name of buttons to build ('rese...
$filter->build()
build filter, fill $filter->output
* DataEdit widget [#wa4ef363]
** Sample [#yff2c7b1]
#code(php){{
$edit = new dataedit_library();
$edit->label = 'Manage Article';
$edit->back_url = $this->url('filtered_grid/index');
$edit->source('articles');
$edit->field('input','title','Title')->rule('trim','requi...
$edit->field('radiogroup','public','Public')
->options(array("y"=>"Yes", "n"=>"No"));
$edit->field('dropdown','author_id','Author')
->options('SELECT author_id, firstname FROM authors')
->rule('required');
$edit->field('date','datefield','Date')
->attributes(array('style'=>'width: 80px'));
$edit->field('editor','body','Description')->rule('requir...
$edit->buttons('modify','save','undo','back');
$edit->build();
$data['head'] = $this->head();
$data['content']= $edit->output;
}}
** Properties [#ecf22368]
| Property | Default Value | Options | Description |
| label | '' | string | label to display for the filter |
| back_url | '' | string | url of page where to go back (...
** Methods [#xe182d72]
$edit->source($source)
| $source | - | mixed
may be a "datamodel" object (or extended one), or the
name of a db table (in this case dataedit will instance a
new datamodel for us)
$edit->field($type, $name, $label)
$type - string field type (input, password, checkboxgroup...
radiogroup, radio, dropdown, date, editor)
$name - string field name, usually the db table field to ...
where clause
$label - string label to display for the field
$edit->field($type, $name, $label)->attributes($attributes)
$attributes - assoc.
array array of extra attributes to build for column
$edit->field($type, $name, $label)->rule($rule)
$rule - mixed
$rule can be 'required' or can be the name of a custom
or native php function (like trim), it's possible to pass...
array instead a single rule, or use a serialized sintax l...
'required|trim' using a pipe as separator
$edit->field($type, $name, $label)->options($options)
$options - array array of options (for field types like d...
radiogroup etc..)
$edit->buttons($button1[,$button2...])
$button n - mixed name of buttons to build ('modify','sav...
'back' are the standard buttons available for dataedit)
$edit->build()
build dataedit, fill $edit->output
終了行:
[[Rapyd]]
#contents
* ダウンロード [#c3518d56]
以下のURLから「Rapyd」をダウンロードして、解凍すると中に...
- http://code.google.com/p/rapyd-framework/
- http://code.google.com/p/rapyd-framework/downloads/deta...
* rapyd 0.8 guide [#b1489429]
Minimalistic PHP Framework for Backends
User Guide v. 0.8
* Overview [#b47bc511]
Rapyd is minimalistic php framework made to build applica...
Its based on a widespread pattern: MVC (Model, View, Cont...
Since 0.8 It support also HMVC (Hierarchical MVC)
It's inspired by CodeIgniter and KohanaPHP.
Rapyd is probably less mature, but give it a chance.
* Features [#dd623a15]
- No compiling, no command line needed, just unzip, it sh...
- Widget oriented architecture (grids, forms, tables, etc...
- Simple syntax, oriented to build simple (or complex) da...
- Modules support (each module is just “reply” of the app...
- you can integrate rapyd with any other php script (like...
- Nice URLs / SEO oriented (since 0.8 the framework does ...
- Really open source (MIT licensed)
* Installation [#tc97ae97]
** System Requirements [#tc108637]
1. PHP 5.1 or higher (required)
2. pdo-sqlite3 to run samples (it support also mySQL, pos...
3. apache webserver with mod_rewrite enabled (for really ...
** Configuration & Deployment [#cbcdabed]
You must configure the application in /application/config...
Rapyd comes with a Demo module (with several examples of ...
but remember, you should remove the demo folder on produc...
* URLs and Flow [#zf3d67b8]
** Rapyd URLs [#b3bd06d1]
Rapyd uses URI (uniform resource identifiers) to determin...
So instead classic “php application” urls:
http://site.com/welcome.php
http://site.com/register.php?step=1
It use:
http://site.com/index.php/welcome/index
http://site.com/index.php/registration/step/1
'''(and with a simple .htaccess and mod_rewrite enabled “...
In an mvc framework there is a system gateway: the only s...
In the above examples rapyd will work as follows:
- instancing a class*: the controller “welcome”, then cal...
- instancing a class*: the controller “registration”, the...
'''(* must extend “rpd” class, and must be placed on the:...
So, in a site driven by rapyd framework, to build a “page...
This is enough but a bit poor, so in each MVC framework (...
Models are classes where you should do db-stuffs, and Vie...
A controller can instance and use models, then can pass d...
** Application Flow [#c7d7c91b]
In Rapyd, and other MVC frameworks:
- All non static resources are served by a sistem gateway...
- The gateway detect by uri the needed resource and insta...
- A Controller is a simple class where each Method is a c...
- A Controller Method can send output by echo or print.. ...
- A Controller should be placed in /application/controllers
- A Model should be placed in /application/models
- A View should be placed in /application/views
And the “flow” is:
request > gateway > controller [ > model ] [ > view ] > ...
Note:
Rapyd also support “modules” which are like “sub-applicat...
Note:
In Rapyd, there are also, “Libraries” and “Helpers” (basi...
* Filesystem [#u61d8e8b]
Rapyd Filesystem is clean, “system” is separated from “ap...
Furthermore, you can isolate application pieces in “modul...
If you need to customize “rapyd/libraries” you can build ...
Note:
Rapyd use class autoload, you do not have to worry about ...
* Controller [#pc9b545b]
A controller is a simple php class it must extend rpd sup...
Conventions/rules:
- Class name must end with _controller
- Filename must be minuscase, with the same class name (w...
- File must be deployed in /application/controllers/ (or ...
** Sample [#ta224522]
#code(php){{
<?php
class welcome_controller extends rpd {
function index()
{
$vars = array('varname' => 'value');
echo $this->view('welcome', $vars);
}
function test()
{
echo 'test';
}
}
}}
This request:
''http://site.com/welcome/inex''
will parse the View 'welcome' then the result will be pri...
This other request:
''http://site.com/welcome/test''
will output 'test'
* View [#d5a2510d]
A view is a simple php file with html, php loops, echos e...
Conventions/rules:
- Filename must be minuscase
- File must be deployed in /application/views/ (or in /mo...
** Sample [#zb0d5db9]
#code(php){{
<html>
<head>
<title>Welcome !</title>
</head>
<body>
<h1>Welcome</h1>
<p>This is a simple html file with some php var <?=$v...
</body>
</html>
}}
Note:
If you are thinking “where is smarty?.. I need a template...
my answer is .. No, there isn't a template engine, and yo...
** Sample using view in view... and HMVC! [#h41f2941]
#code(php){{
<?=rpd::view('header', $input_data)?>
<h1>Welcome</h1>
<p>This is a simple html file with some php var <?=$varna...
<h2>user info<h2>
<?=rpd::run('userbox','info', array('short_style'));?>
<?=rpd::view('footer', $input_data)?>
}}
TA-DA!..
''rpd::view'' let you call another view, “$input_data” is...
''rpd::run'' let you call $controller->method($params);
so you can gain a great level of isolation. You can isola...
* Models / DB / Active Record [#n7e60deb]
A Model is a class where you should do db stuffs. In exam...
Using active record way is great to tokenize queries (for...
#code(php){{
<?php
class articles_model extends rpd
{
function __construct()
{
$this->db = rpd::$db;
}
//using simple query
function get_categories()
{
$sql = "SELECT c.category_id as id, COUNT(a.article_id) a...
FROM articles_categories c LEFT JOIN articles a USING(cat...
WHERE c.public = 'y'
GROUP BY c.category_id
ORDER BY c.priority ASC ";
$this->db->query($sql);
if ($this->db->num_rows() > 0)
{
return $this->db->result_array();
} else {
return array();
}
}
//using active record
function get_articles($limit=10, $category="", $rand=false)
{
$this->db->select("a.*");
$this->db->from("articles a");
$this->db->where("a.public","y");
if (is_numeric($category))
{
$this->db->where("a.category_id", $category);
}
if ($rand)
$this->db->orderby("RANDOM()");
else
$this->db->orderby("article_date", "desc");
$this->db->get(null, $limit);
if ($this->db->num_rows() > 0)
{
return $this->db->result_array();
} else {
return array();
}
}
}
}}
* Widgets [#e1b5255e]
Ok, we now know how mvc works, and how to execute queries...
Rapyd is focused to build in few lines of code “CRUD” int...
Each widget extend a basic “component”, and is designed t...
** Widgets semantic [#he4abbd4]
A widget has a behavior driven by “uri segments” (this is...
''http://site.com/index.php/grid/index/pag/2''
''http://site.com/index.php/grid/index/orderby/article_id...
''http://site.com/index.php/grid/index/orderby/article_id...
'''(this show how a datagrid work with offset and order)'''
''http://site.com/index.php/edit/index/show/1''
''http://site.com/index.php/edit/index/modify/1''
''http://site.com/index.php/edit/index/create/1''
'''(this show how a dataedit change editing status)'''
''http://site.com/index.php/filtered_grid/index/search/1/...
'''(this show how datafilter and datagrid work together: ...
*DataGrid widget [#o63bd219]
**Sample [#b0e18b97]
#code(php){{
$grid = new datagrid_library();
$grid->label = 'Article List';
$grid->per_page = 5;
$grid->source('articles');
$grid->column('article_id','ID',true)->url('edit/show/{ar...
$grid->column('title','Title');
$grid->column('body','Body')->callback('escape',$this);
$grid->build();
$data['head'] = $this->head();
$data['content']= $grid->output;
}}
**Properties [#h90e99b1]
| Property | Default Value | Options | Description |
| label | '' | string | label to display for the grid |
| per_page | | integer | the number of records to display...
**Methods [#gff6cdfe]
$grid->source($source)
| $source | - | mixed may be a db-table name, a sql-query...
an associative array matrix |
$grid->column($pattern, $label, $is_orderby)
| $pattern | - | string | field pattern, field name, or c...
| $label | - | string | column label |
| $orderby | - | boolean | if column is sortable |
$grid->build()
build grid, fill $grid->output
* DataFilter widget [#ffc1aecc]
** Sample [#m3e100c1]
#code(php){{
$filter = new datafilter_library();
$filter->label = 'Article Filter';
$filter->db->select("articles.*, authors.*");
$filter->db->from("articles");
$filter->db->join("authors","authors.author_id=articles.a...
$filter->field('input','title','Title')
->attributes(array('style' => 'width:170px'));
$filter->field('radiogroup','public','Public')
->options(array("y"=>"Yes", "n"=>"No"));
$filter->buttons('reset','search');
$filter->build();
$data['head'] = $this->head();
$data['content']= $grid->output;
}}
** Properties [#u57710d1]
| Property | Default Value | Options | Description |
| label | '' | string | label to display for the filter |
** Methods [#t53135f2]
$filter->source($source)
| $source | - | mixed | may be a db-table name, or a sql-...
$filter->field($type, $name, $label)
| $type | - | string | field type (input, password, check...
radiogroup, radio, dropdown, date, editor) |
| $name | - | string | field name, usually the db table f...
where clause |
| $label | - | string | label to display for the field |
$filter->field($type, $name, $label)->attributes($attrib...
| $attributes | - | assoc.array | array of extra attribut...
$filter->field($type, $name, $label)->options($options)
| $options | - | array | array of options (for field type...
$filter->buttons($button1[,$button2...])
| $button n | - | mixed | name of buttons to build ('rese...
$filter->build()
build filter, fill $filter->output
* DataEdit widget [#wa4ef363]
** Sample [#yff2c7b1]
#code(php){{
$edit = new dataedit_library();
$edit->label = 'Manage Article';
$edit->back_url = $this->url('filtered_grid/index');
$edit->source('articles');
$edit->field('input','title','Title')->rule('trim','requi...
$edit->field('radiogroup','public','Public')
->options(array("y"=>"Yes", "n"=>"No"));
$edit->field('dropdown','author_id','Author')
->options('SELECT author_id, firstname FROM authors')
->rule('required');
$edit->field('date','datefield','Date')
->attributes(array('style'=>'width: 80px'));
$edit->field('editor','body','Description')->rule('requir...
$edit->buttons('modify','save','undo','back');
$edit->build();
$data['head'] = $this->head();
$data['content']= $edit->output;
}}
** Properties [#ecf22368]
| Property | Default Value | Options | Description |
| label | '' | string | label to display for the filter |
| back_url | '' | string | url of page where to go back (...
** Methods [#xe182d72]
$edit->source($source)
| $source | - | mixed
may be a "datamodel" object (or extended one), or the
name of a db table (in this case dataedit will instance a
new datamodel for us)
$edit->field($type, $name, $label)
$type - string field type (input, password, checkboxgroup...
radiogroup, radio, dropdown, date, editor)
$name - string field name, usually the db table field to ...
where clause
$label - string label to display for the field
$edit->field($type, $name, $label)->attributes($attributes)
$attributes - assoc.
array array of extra attributes to build for column
$edit->field($type, $name, $label)->rule($rule)
$rule - mixed
$rule can be 'required' or can be the name of a custom
or native php function (like trim), it's possible to pass...
array instead a single rule, or use a serialized sintax l...
'required|trim' using a pipe as separator
$edit->field($type, $name, $label)->options($options)
$options - array array of options (for field types like d...
radiogroup etc..)
$edit->buttons($button1[,$button2...])
$button n - mixed name of buttons to build ('modify','sav...
'back' are the standard buttons available for dataedit)
$edit->build()
build dataedit, fill $edit->output
ページ名: