ziopod/flatfile
Composer 安装命令:
composer require ziopod/flatfile
包简介
A simple FlatFile ORM
README 文档
README
A simple Flatfile ORM
How to use it
This is a example with a Welcome controller.
Create your model
Create a page model:
| application
| classes
| Model
Page.php
In your model:
class Model_Page extend Flatfile {
/**
* Somes filters
*
* @return array
**/
public function filters()
{
return array(
array(
'content' => array('Flatfile::Markdown'),
),
);
}
}
Create your content
In your root project:
| content
| pages
hello-world.md
In your hello-world file:
title: Hi!
---
Hello **World**
Grab your content
Create your controller
| application
| classes
| Controller
Welcome.php
In your controller, in classic Kohana MVC design pattern
class Controller_Welcome extends Controller {
/**
* Action call by defaults
*
* @return void
**/
public function action_index()
{
$view = View::factory('welcome/index')
->bind('page', $page);
$page = new Model_Page('hello-world');
$this->response->body($view);
}
}
Show your content
Create your View
| application
| views
| welcome
index.php
In your view index
<html>
<head>
<title>
<?php echo $page->title; ?>
</title>
</head>
<body>
<?php echo $page->content; ?>
</body>
</html>
The result
<html>
<head>
<title>Hi!</title>
</head>
<body>
Hello <strong>World</strong>
</body>
</html>
Filters
Similar usage to Kohana ORM.
Flatfile embed a specifics filters :
Markdown
Process a Markdown transformation.
str_to_list
Convert a comma separate list to an array of term and slug.
For example :
tags: Laitue, Choux rouge
Be converted to
array(
array(
'name' => 'Laitue',
'slug' => 'laitue',
),
array(
'name' => 'Choux rouge',
'slug' => 'choux-rouge',
),
)
Usefull, for example, to create a list of tags; in your view :
<uL>
<?php foreach($page->tags as $tag): ?>
<li>
<a href="http://my_awesome_blog.com/posts/tag/<?php echo $tag['slug']; ?>">
<?php echo $tag['name']; ?>
</a>
</li>
<?php endforeach; ?>
</ul>
json_api
Give him a json API service address, it will return a result ready to use.
For example :
bloginfo: https://api.tumblr.com/v2/blog/blogdamientran.tumblr.com/info?api_key=fuiKNFp9vQFvjLNvx4sUwti4Yb5yGutBN4Xh10LXZhhRKjWlV4
Resulting to
stdClass Object
(
[blog] => stdClass Object
(
[title] => Damien Tran
[name] => blogdamientran
[posts] => 66
[url] => http://blogdamientran.tumblr.com/
[updated] => 1434963170
[description] => damientran.com - palefroi.net
[is_nsfw] =>
[ask] =>
[ask_page_title] => Ask me anything
[ask_anon] =>
[share_likes] => 1
[likes] => 6
)
)
You can use the result in your view
<a href="<?php echo $page->bloginfo->blog->url; ?>">
See the blog <?php echo $page->bloginfo->blog->title; ?>
</a>
Flatfile methods
Flatfile contain somes usefull methods
order
query
Operators
like
Multiple queries
date and slug
offset
limit
find
find_all
ziopod/flatfile 适用场景与选型建议
ziopod/flatfile 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 138 次下载、GitHub Stars 达 2, 最近一次更新时间为 2015 年 07 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「orm」 「markdown」 「kohana」 「kohana module」 「flatfile」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ziopod/flatfile 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ziopod/flatfile 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ziopod/flatfile 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Geoip and IP integration
Jam Taxonomy
Admin Builder for Kohana, using Jam ORM
Add complex shipping to openbuildings/purchases package
Texy converts plain text in easy to read Texy syntax into structurally valid (X)HTML. It supports adding of images, links, nested lists, tables and has full support for CSS. Texy supports hyphenation of long words (which reflects language rules), clickable emails and URL (emails are obfuscated again
A php port of jnicklas's capybara, and handles Functional / Integration testing
统计信息
- 总下载量: 138
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 24
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2015-07-27