<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>超群.com的博客 &#187; ColaPHP</title>
	<atom:link href="http://www.fuchaoqun.com/tag/colaphp/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.fuchaoqun.com</link>
	<description></description>
	<lastBuildDate>Thu, 22 Jul 2010 23:31:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>ColaPHP 0.8beta发布</title>
		<link>http://www.fuchaoqun.com/2010/07/colaphp-0-8-beta/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=colaphp-0-8-beta</link>
		<comments>http://www.fuchaoqun.com/2010/07/colaphp-0-8-beta/#comments</comments>
		<pubDate>Fri, 02 Jul 2010 16:31:52 +0000</pubDate>
		<dc:creator>超群.com</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[ColaPHP]]></category>

		<guid isPermaLink="false">http://www.fuchaoqun.com/?p=378</guid>
		<description><![CDATA[代号：Mini，bugfix版本，改善框架易用性，代码重构。 下载ColaPHP 0.8beta，阅读ColaPHP文档，访问ColaPHP项目。 ColaPHP 0.8beta已经很稳定，可以在生产环境使用。]]></description>
			<content:encoded><![CDATA[<p>代号：Mini，bugfix版本，改善框架易用性，代码重构。</p>
<p><a href="http://colaphp.googlecode.com/files/ColaPHP-0.8-beta.zip" target="_blank">下载ColaPHP 0.8beta</a>，阅读<a href="http://code.google.com/p/colaphp/w/list" target="_blank">ColaPHP文档</a>，访问<a href="http://code.google.com/p/colaphp/" target="_blank">ColaPHP项目</a>。</p>
<p>ColaPHP 0.8beta已经很稳定，可以在生产环境使用。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fuchaoqun.com/2010/07/colaphp-0-8-beta/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>基于MongoDb的S3实现</title>
		<link>http://www.fuchaoqun.com/2010/05/s3-on-mongodb-with-php/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=s3-on-mongodb-with-php</link>
		<comments>http://www.fuchaoqun.com/2010/05/s3-on-mongodb-with-php/#comments</comments>
		<pubDate>Fri, 07 May 2010 10:15:11 +0000</pubDate>
		<dc:creator>超群.com</dc:creator>
				<category><![CDATA[默认分类]]></category>
		<category><![CDATA[ColaPHP]]></category>
		<category><![CDATA[mongodb]]></category>
		<category><![CDATA[S3]]></category>

		<guid isPermaLink="false">http://www.fuchaoqun.com/?p=344</guid>
		<description><![CDATA[原理是利用MongoDb的GridFS，伸展性方面交由MongoDb的auto sharding去实现，这里用PHP给MongoDb绑了个S3出来，支持选择文件存储节点，支持文件分目录存储，这样的好处是对于一些受时间影响比较明显的文件，可以按照年月的形式存储，减轻历史包袱。 首先，配置MongoDb GridFS节点信息： &#60;?php $s3Config = array&#40; 'foo' =&#62; array&#40; 'server' =&#62; '127.0.0.1', 'database' =&#62; 'test', 'user' =&#62; 'test', 'password' =&#62; 'foobar', 'domain' =&#62; 'http://s3.foobar.com' &#41;, &#160; 'bar' =&#62; array&#40; 'server' =&#62; '127.0.0.1', 'database' =&#62; 'test', 'user' =&#62; 'test', 'password' =&#62; 'foobar', 'domain' =&#62; 'http://s3.foobar.com' &#41;, &#41;; MongoDb的S3绑定： &#60;?php /** * 统一文件存储 * */ [...]]]></description>
			<content:encoded><![CDATA[<p>原理是利用MongoDb的GridFS，伸展性方面交由MongoDb的auto sharding去实现，这里用PHP给MongoDb绑了个S3出来，支持选择文件存储节点，支持文件分目录存储，这样的好处是对于一些受时间影响比较明显的文件，可以按照年月的形式存储，减轻历史包袱。</p>
<p>首先，配置MongoDb GridFS节点信息：</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$s3Config</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">'foo'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
        <span style="color: #0000ff;">'server'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'127.0.0.1'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'database'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'test'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'user'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'test'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'password'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'foobar'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'domain'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'http://s3.foobar.com'</span>
    <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
&nbsp;
    <span style="color: #0000ff;">'bar'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
        <span style="color: #0000ff;">'server'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'127.0.0.1'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'database'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'test'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'user'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'test'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'password'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'foobar'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'domain'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'http://s3.foobar.com'</span>
    <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>MongoDb的S3绑定：</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009933; font-style: italic;">/**
 * 统一文件存储
 *
 */</span>
<span style="color: #000000; font-weight: bold;">class</span> Api_S3
<span style="color: #009900;">&#123;</span>
    protected <span style="color: #000088;">$_node</span><span style="color: #339933;">;</span>
&nbsp;
    protected <span style="color: #000088;">$_dir</span><span style="color: #339933;">;</span>
&nbsp;
    protected <span style="color: #000088;">$_config</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * 构造函数
     *
     * @param string $node
     * @param string $dir
     * @param array $config
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #000088;">$node</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dir</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #000088;">$config</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_config <span style="color: #339933;">=</span> <span style="color: #000088;">$config</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">path</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$node</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dir</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * 设置文件路径
     *
     * @param string $node
     * @param string $dir
     * @return Api_S3
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> path<span style="color: #009900;">&#40;</span><span style="color: #000088;">$node</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dir</span><span style="color: #339933;">,</span> <span style="color: #000088;">$connect</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_node <span style="color: #339933;">=</span> <span style="color: #000088;">$node</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_dir <span style="color: #339933;">=</span> <span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">'fs'</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$dir</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_config<span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_node<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            throw <span style="color: #000000; font-weight: bold;">new</span> Cola_Exception<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Api_S3: invalidate node'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$connect</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_gridFS <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_gridFS<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * GridFS
     *
     * @return MongDbGridFS
     */</span>
    protected <span style="color: #000000; font-weight: bold;">function</span> _gridFS<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$mongo</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Cola_Com_Mongo<span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_config<span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_node<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$mongo</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">gridFS</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_dir<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * 获得文件句柄
     *
     * @param string $name
     * @return MongoGridFSFile
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #990000;">file</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$name</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_gridFS<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_gridFS <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_gridFS<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_gridFS<span style="color: #339933;">-&gt;</span><span style="color: #004000;">findOne</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'filename'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$name</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * 获得文件内容
     *
     * @param string $name
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> read<span style="color: #009900;">&#40;</span><span style="color: #000088;">$name</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">file</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$name</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$file</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getBytes</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * 写入文件
     *
     * @param string $name
     * @param string $data
     * @param array $extra
     * @param boolean $overWrite
     * @return boolean
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> write<span style="color: #009900;">&#40;</span><span style="color: #000088;">$name</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data</span><span style="color: #339933;">,</span> <span style="color: #000088;">$extra</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$overWrite</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$extra</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#41;</span><span style="color: #000088;">$extra</span> <span style="color: #339933;">+</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'filename'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">basename</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$name</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$filetype</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_type<span style="color: #009900;">&#40;</span><span style="color: #000088;">$name</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$extra</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'filetype'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$filetype</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">file</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$extra</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'filename'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$overWrite</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">delete</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$extra</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'filename'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
                throw <span style="color: #000000; font-weight: bold;">new</span> Cola_Exception<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Api_S3: file exists'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_gridFS<span style="color: #339933;">-&gt;</span><span style="color: #004000;">storeBytes</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #339933;">,</span> <span style="color: #000088;">$extra</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * 复制系统文件
     *
     * @param string $file
     * @param array $extra
     * @param boolean $overWrite
     * @return boolean
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #990000;">copy</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #339933;">,</span> <span style="color: #000088;">$extra</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$overWrite</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$extra</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#41;</span><span style="color: #000088;">$extra</span> <span style="color: #339933;">+</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'filename'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">basename</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$filetype</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_type<span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$extra</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'filetype'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$filetype</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">file</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$extra</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'filename'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$overWrite</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">delete</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$extra</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'filename'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
                throw <span style="color: #000000; font-weight: bold;">new</span> Cola_Exception<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Api_S3: file exists'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_gridFS<span style="color: #339933;">-&gt;</span><span style="color: #004000;">storeFile</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #339933;">,</span> <span style="color: #000088;">$extra</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * 删除文件
     *
     * @param string $name
     * @return boolean
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> delete<span style="color: #009900;">&#40;</span><span style="color: #000088;">$name</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_gridFS<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_gridFS <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_gridFS<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #b1b100;">return</span>  <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_gridFS<span style="color: #339933;">-&gt;</span><span style="color: #004000;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'filename'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$name</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * 获得文件地址
     *
     * @param string $name
     * @param string $default
     * @return string
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getUrl<span style="color: #009900;">&#40;</span><span style="color: #000088;">$name</span><span style="color: #339933;">,</span> <span style="color: #000088;">$default</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
            <span style="color: #0000ff;">'domain'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">rtrim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_config<span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_node<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'domain'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'/'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'path'</span>   <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_node <span style="color: #339933;">.</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'fs'</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_dir<span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">''</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_dir<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'name'</span>   <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$name</span>
        <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">return</span>  <span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * 设置文件属性
     *
     * @param string $name
     * @param array $attr
     * @return boolean
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setAttr<span style="color: #009900;">&#40;</span><span style="color: #000088;">$name</span><span style="color: #339933;">,</span> <span style="color: #000088;">$attr</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">file</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$name</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            throw <span style="color: #000000; font-weight: bold;">new</span> Cola_Exception<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Api_S3: file not exists'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000088;">$file</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">file</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$attr</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$file</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">file</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_gridFS<span style="color: #339933;">-&gt;</span><span style="color: #004000;">save</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * 获得文件属性
     *
     * @param string $name
     * @return array
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getAttr<span style="color: #009900;">&#40;</span><span style="color: #000088;">$name</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">file</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$name</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$file</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">file</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * 获得文件类型
     *
     * @param string $file
     * @return string
     */</span>
    protected <span style="color: #000000; font-weight: bold;">function</span> _type<span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #990000;">mime_content_type</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>文件存入，支持自选节点，自定义目录，自定义文件名，可以自动添加文件类型：</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$s3</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Api_S3<span style="color: #009900;">&#40;</span><span style="color: #000088;">$node</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dir</span><span style="color: #339933;">,</span> <span style="color: #000088;">$s3Config</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$s3</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">copy</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'filename'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$name</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'filetype'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$type</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>文件读取，以&#8221;http://s3.foobar.com/foo/201005/foobar.jpg&#8221;为例，foo映射到节点名，201005映射到目录名，foobar.jpg映射到文件名：</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$s3</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Api_S3<span style="color: #009900;">&#40;</span><span style="color: #000088;">$node</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dir</span><span style="color: #339933;">,</span> <span style="color: #000088;">$s3Config</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$s3</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">file</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$name</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
Cola_Response<span style="color: #339933;">::</span><span style="color: #004000;">lastModified</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">file</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'uploadDate'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">sec</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Cola_Response<span style="color: #339933;">::</span><span style="color: #004000;">etag</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">file</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'md5'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">file</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'filetype'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-Type: <span style="color: #006699; font-weight: bold;">{$file-&gt;file['filetype']}</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$file</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getBytes</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>注意到我们利用了文件的修改时间设置http头的last modified，以及用文件的md5信息设置etag值，这样的好处是可以大大减少带宽使用，当然，你也可以设置expire时间来减少重复请求。</p>
<p>关于性能问题，可以在PHP读取的上一层，加一个Squid之类的反向代理服务，基本上就不会有问题。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fuchaoqun.com/2010/05/s3-on-mongodb-with-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ColaPHP 0.6beta发布</title>
		<link>http://www.fuchaoqun.com/2010/02/colaphp-0-6-beta/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=colaphp-0-6-beta</link>
		<comments>http://www.fuchaoqun.com/2010/02/colaphp-0-6-beta/#comments</comments>
		<pubDate>Sat, 27 Feb 2010 17:39:33 +0000</pubDate>
		<dc:creator>超群.com</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[ColaPHP]]></category>

		<guid isPermaLink="false">http://www.fuchaoqun.com/?p=330</guid>
		<description><![CDATA[ColaPHP月度发布计划版本，代号：Easy，和0.5beta相比变化不大，主要修改如下： 增加Yaml处理，底层调用symfony yaml包处理 增加自定义异常类，后续准备将框架中的异常细分（好处是将来可以对异常做针对性处理） 少量代码重构以及bug fix 下载ColaPHP 0.6beta，阅读ColaPHP文档，访问ColaPHP项目。 下一个版本0.7beta开发代号：Recode，主要对代码做进一步重构优化。]]></description>
			<content:encoded><![CDATA[<p>ColaPHP月度发布计划版本，代号：Easy，和0.5beta相比变化不大，主要修改如下：</p>
<ul>
<li>增加Yaml处理，底层调用symfony yaml包处理</li>
<li> 增加自定义异常类，后续准备将框架中的异常细分（好处是将来可以对异常做针对性处理）</li>
<li> 少量代码重构以及bug fix</li>
</ul>
<p><a href="http://colaphp.googlecode.com/files/ColaPHP-0.6-beta.zip" target="_blank">下载ColaPHP 0.6beta</a>，阅读<a href="http://code.google.com/p/colaphp/w/list" target="_blank">ColaPHP文档</a>，访问<a href="http://code.google.com/p/colaphp/" target="_blank">ColaPHP项目</a>。</p>
<p>下一个版本0.7beta开发代号：Recode，主要对代码做进一步重构优化。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fuchaoqun.com/2010/02/colaphp-0-6-beta/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>ColaPHP 0.5beta发布</title>
		<link>http://www.fuchaoqun.com/2010/01/colaphp-0-5-beta/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=colaphp-0-5-beta</link>
		<comments>http://www.fuchaoqun.com/2010/01/colaphp-0-5-beta/#comments</comments>
		<pubDate>Sun, 24 Jan 2010 05:31:54 +0000</pubDate>
		<dc:creator>超群.com</dc:creator>
				<category><![CDATA[默认分类]]></category>
		<category><![CDATA[ColaPHP]]></category>

		<guid isPermaLink="false">http://www.fuchaoqun.com/?p=298</guid>
		<description><![CDATA[ColaPHP的第一个beta版本,代号：Practice，已经实践的优化，可以适量应用在实际项目中，相比较0.4alpha，比较大的修改如下： 增加字符串加密助手，支持XOR、mcrypt加密，支持混淆 增加分页类 重构了HTTP请求类，可定制性更强 重构了Validate类，增加批量校验 其他代码重构以及bug fix 下载ColaPHP 0.5beta，阅读ColaPHP文档，访问ColaPHP项目。 下一个版本0.6beta开发代号：Easy，将在易用性方面进一步优化。]]></description>
			<content:encoded><![CDATA[<p>ColaPHP的第一个beta版本,代号：Practice，已经实践的优化，可以适量应用在实际项目中，相比较0.4alpha，比较大的修改如下：</p>
<ul>
<li>增加字符串加密助手，支持XOR、mcrypt加密，支持混淆</li>
<li>增加分页类</li>
<li>重构了HTTP请求类，可定制性更强</li>
<li>重构了Validate类，增加批量校验</li>
<li>其他代码重构以及bug fix </li>
</ul>
<p>下载<a href="http://colaphp.googlecode.com/files/ColaPHP-0.5-beta.zip" target="_blank">ColaPHP 0.5beta</a>，阅读<a href="http://code.google.com/p/colaphp/w/list" target="_blank">ColaPHP文档</a>，访问<a href="http://code.google.com/p/colaphp/" target="_blank">ColaPHP项目</a>。</p>
<p>下一个版本0.6beta开发代号：Easy，将在易用性方面进一步优化。 </p>
]]></content:encoded>
			<wfw:commentRss>http://www.fuchaoqun.com/2010/01/colaphp-0-5-beta/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>ColaPHP-0.4-alpha发布</title>
		<link>http://www.fuchaoqun.com/2009/12/colaphp-0-4-alpha/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=colaphp-0-4-alpha</link>
		<comments>http://www.fuchaoqun.com/2009/12/colaphp-0-4-alpha/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 13:46:59 +0000</pubDate>
		<dc:creator>超群.com</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[ColaPHP]]></category>
		<category><![CDATA[PHP Framework]]></category>

		<guid isPermaLink="false">http://www.fuchaoqun.com/?p=279</guid>
		<description><![CDATA[ColaPHP月度发布计划，基本上每月发一个release，相比较0.3alpha，比较大的修改如下： 增加了动态路由模式，可不用定义URL规则 增加对MySQL Master-Slave支持，可以由单数据库无缝迁移到主从模式 去除框架中Smarty模板的绑定，可以在Controller中自行调用Smarty模板 Helper中增加了性能测试模块Benchmark.php 增加对MongoDB的简单绑定Mongo.php 性能进一步提升 大量的代码重构以及bug fix 访问ColaPHP官方网站，下载0.4alpha，不过建议随时跟进我们的svn://colaphp.googlecode.com/svn/trunk/，ColaPHP一直在活跃开发。 ColaPHP 0.4alpha已完成预期目标，所有的函数都控制在20行以内。下一个版本0.5alpha版本开发代号：Practice，ColaPHP已经在一些实际项目中使用，0.5alpha将得到更多的实践优化 招募PHP极客加入ColaPHP，联系fuchaoqun#gmail.com。]]></description>
			<content:encoded><![CDATA[<p>ColaPHP月度发布计划，基本上每月发一个release，相比较0.3alpha，比较大的修改如下：</p>
<ul>
<li>增加了动态路由模式，可不用定义URL规则</li>
<li>增加对MySQL Master-Slave支持，可以由单数据库无缝迁移到主从模式</li>
<li>去除框架中Smarty模板的绑定，可以在Controller中自行调用Smarty模板</li>
<li>Helper中增加了性能测试模块Benchmark.php</li>
<li>增加对MongoDB的简单绑定Mongo.php</li>
<li>性能进一步提升</li>
<li>大量的代码重构以及bug fix </li>
</ul>
<p>访问<a href="http://code.google.com/p/colaphp/" target="_blank">ColaPHP</a>官方网站，下载<a href="http://colaphp.googlecode.com/files/ColaPHP-0.4-alpha.zip" target="_blank">0.4alpha</a>，不过建议随时跟进我们的svn://colaphp.googlecode.com/svn/trunk/，ColaPHP一直在活跃开发。</p>
<p>ColaPHP 0.4alpha已完成预期目标，所有的函数都控制在20行以内。下一个版本0.5alpha版本开发代号：Practice，ColaPHP已经在一些实际项目中使用，0.5alpha将得到更多的实践优化</p>
<p>招募PHP极客加入ColaPHP，联系fuchaoqun#gmail.com。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fuchaoqun.com/2009/12/colaphp-0-4-alpha/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ColaPHP-0.3-alpha发布</title>
		<link>http://www.fuchaoqun.com/2009/11/colaphp-03-alpha/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=colaphp-03-alpha</link>
		<comments>http://www.fuchaoqun.com/2009/11/colaphp-03-alpha/#comments</comments>
		<pubDate>Sat, 07 Nov 2009 05:08:29 +0000</pubDate>
		<dc:creator>超群.com</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[ColaPHP]]></category>

		<guid isPermaLink="false">http://www.fuchaoqun.com/?p=255</guid>
		<description><![CDATA[开发工作很久以前就基本完成了，一直没来得及整理，今天发布0.3alpha，相比较0.2alpha，比较大的修改如下： Helper中增加了验证码模块Captcha.php、HTTP访问模块Http.php、数据校验模块Validate.php 修订DB模块中result($sql)函数，如果$sql是select语句则返回结果集，如果是insert语句则返回最后插入ID，如果是update或者delete语句，则返回受影响行数（有可能为0行），其他语句则返回query句柄 完善框架的易用性：增加了统一配置文件；可以指定models、views、controllers目录；支持默认模版名称 大量的代码重构以及bug fix 下载0.3alpha，不过建议随时跟进我们的SVN://colaphp.googlecode.com/svn/trunk/，ColaPHP一直在活跃开发。 0.4alpha版本开发代号：20 lines，目标是把所有的函数都控制在20行以内以及代码的持续重构。 继续招募PHP极客加入Cola，联系fuchaoqun#gmail.com。]]></description>
			<content:encoded><![CDATA[<p>开发工作很久以前就基本完成了，一直没来得及整理，今天发布0.3alpha，相比较0.2alpha，比较大的修改如下： </p>
<ul>
<li>Helper中增加了验证码模块Captcha.php、HTTP访问模块Http.php、数据校验模块Validate.php</li>
<li>修订DB模块中result($sql)函数，如果$sql是select语句则返回结果集，如果是insert语句则返回最后插入ID，如果是update或者delete语句，则返回受影响行数（有可能为0行），其他语句则返回query句柄</li>
<li>完善框架的易用性：增加了统一配置文件；可以指定models、views、controllers目录；支持默认模版名称 </li>
<li>大量的代码重构以及bug fix </li>
</ul>
<p><a href="http://colaphp.googlecode.com/files/ColaPHP-0.3-alpha.zip" target="_blank">下载0.3alpha</a>，不过建议随时跟进我们的SVN://colaphp.googlecode.com/svn/trunk/，ColaPHP一直在活跃开发。</p>
<p>0.4alpha版本开发代号：20 lines，目标是把所有的函数都控制在20行以内以及代码的持续重构。 </p>
<p>继续招募PHP极客加入Cola，联系fuchaoqun#gmail.com。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fuchaoqun.com/2009/11/colaphp-03-alpha/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ColaPHP-0.1-alpha发布</title>
		<link>http://www.fuchaoqun.com/2009/06/colaphp-01-alpha/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=colaphp-01-alpha</link>
		<comments>http://www.fuchaoqun.com/2009/06/colaphp-01-alpha/#comments</comments>
		<pubDate>Fri, 19 Jun 2009 11:25:43 +0000</pubDate>
		<dc:creator>超群.com</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[ColaPHP]]></category>
		<category><![CDATA[framework]]></category>

		<guid isPermaLink="false">http://www.fuchaoqun.com/?p=227</guid>
		<description><![CDATA[非常简陋的一个PHP框架，只是把架子搭起来了，地址：http://code.google.com/p/colaphp/ 现在PHP框架已经很多了，为什么还要去&#8221;重复的发明轮子&#8221;？ 你和我一样不想重新学习一门&#8221;框架语言&#8221; 你和我一样希望规范的MVC开发 你和我一样希望一个高性能的框架 你和我一样不希望改变已有的PHP开发方式 现在，ColaPHP还很不成熟，暂且当做一个&#8221;玩具&#8221;试试，有兴趣的可以阅读一下代码，品味好的代码和指出坏味道的代码都是一个好的过程。 文档方面现在还很不全，我希望只用一个Tutorial就能讲明白，以后也不会有别的新的文档（文档越多，表明系统越复杂，学习成本也越高），当然，Tutorial会是一个持续完善的过程。 ColaPHP是写给PHP程序员的一个框架，信奉KISS的同学可以试试。]]></description>
			<content:encoded><![CDATA[<p>非常简陋的一个PHP框架，只是把架子搭起来了，地址：<a href="http://code.google.com/p/colaphp/" target="_blank">http://code.google.com/p/colaphp/</a></p>
<p>现在PHP框架已经很多了，为什么还要去&#8221;重复的发明轮子&#8221;？</p>
<ul>
<li>你和我一样不想重新学习一门&#8221;框架语言&#8221;</li>
<li>你和我一样希望规范的MVC开发</li>
<li>你和我一样希望一个高性能的框架</li>
<li>你和我一样不希望改变已有的PHP开发方式</li>
</ul>
<p>现在，ColaPHP还很不成熟，暂且当做一个&#8221;玩具&#8221;试试，有兴趣的可以阅读一下代码，品味好的代码和指出坏味道的代码都是一个好的过程。</p>
<p>文档方面现在还很不全，我希望只用一个<a href="http://code.google.com/p/colaphp/wiki/Tutorial_ZH_CN" target="_blank">Tutorial</a>就能讲明白，以后也不会有别的新的文档（文档越多，表明系统越复杂，学习成本也越高），当然，Tutorial会是一个持续完善的过程。</p>
<p>ColaPHP是写给PHP程序员的一个框架，信奉KISS的同学可以<a href="http://colaphp.googlecode.com/files/ColaPHP-0.1-alpha.zip" target="_blank">试试</a>。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fuchaoqun.com/2009/06/colaphp-01-alpha/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->