<?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>4's symfony blog &#187; symfony</title>
	<atom:link href="http://www.foolbirds.com/t/symfony/feed" rel="self" type="application/rss+xml" />
	<link>http://www.foolbirds.com</link>
	<description>all about symfony</description>
	<lastBuildDate>Fri, 14 Oct 2011 12:36:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>使用symfony filter 过滤URL</title>
		<link>http://www.foolbirds.com/use_symfony_filter_to_filteredurl.html</link>
		<comments>http://www.foolbirds.com/use_symfony_filter_to_filteredurl.html#comments</comments>
		<pubDate>Wed, 26 May 2010 01:30:27 +0000</pubDate>
		<dc:creator>szn000</dc:creator>
				<category><![CDATA[symfony]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[url]]></category>

		<guid isPermaLink="false">http://www.foolbirds.com/?p=1254</guid>
		<description><![CDATA[这是一个过滤URL中 多个&#8217;/'的例子
修改 apps/myapp/config/filters.yml
添加代码
myFilter:
  class: myFilter
(myFilter可自定义)
创建文件myFilter.class.php
创建位置apps/myapp/lib/
文件内容如下
使用preg_match 是因为 ereg 过时
注意preg_match 匹配正则时以&#8217;/'开始和结束
class myFilter extends sfFilter
{
 public function execute ($filterChain)
 {
   //提取uri
   $str = $_SERVER['REQUEST_URI'];
   //判断是否匹配正则
   if(preg_match("/(.*\/{2,}.*)((\.html)*)/",$str)){
     //要跳转的页面
     header("Location:/error.html");
     //跳转后代码不执行
     exit();
   }
 [...]]]></description>
			<content:encoded><![CDATA[<p>这是一个过滤URL中 多个&#8217;/'的例子<br />
修改 apps/myapp/config/filters.yml<br />
添加代码<br />
<code>myFilter:<br />
  class: myFilter</code><br />
(myFilter可自定义)<br />
创建文件myFilter.class.php<br />
创建位置apps/myapp/lib/<br />
文件内容如下<br />
使用preg_match 是因为 ereg 过时<br />
注意preg_match 匹配正则时以&#8217;/'开始和结束<br />
<code>class myFilter extends sfFilter<br />
{<br />
 public function execute ($filterChain)<br />
 {<br />
   //提取uri<br />
   $str = $_SERVER['REQUEST_URI'];<br />
   //判断是否匹配正则<br />
   if(preg_match("/(.*\/{2,}.*)((\.html)*)/",$str)){<br />
     //要跳转的页面<br />
     header("Location:/error.html");<br />
     //跳转后代码不执行<br />
     exit();<br />
   }<br />
   //执行下一个filter<br />
   $filterChain->execute();<br />
  }<br />
}</code><br />
修改apps/myapp/config/routing.yml<br />
添加代码 此代码用来定义URL /error.html 要执行的模块和动作<br />
<code>Error:<br />
  url:   /error.html<br />
  param: { module: index, action: error404}</code></p>
<ul class="related_post"><li><a href="http://www.foolbirds.com/%e4%bb%bfsymfony%e6%9c%ba%e5%88%b6%e5%ae%9e%e7%8e%b0%e4%b8%8d%e7%94%a8require%e6%88%96%e8%80%85include%e6%9d%a5%e5%ae%9e%e4%be%8b%e5%8c%96%e7%b1%bb.html" title="仿symfony机制实现不用require或者include来实例化类">仿symfony机制实现不用require或者include来实例化类</a></li><li><a href="http://www.foolbirds.com/use-datetime-in-php5-1-x-with-symfony.html" title="symfony1.4 DateTime对于PHP低版本的兼容问题">symfony1.4 DateTime对于PHP低版本的兼容问题</a></li><li><a href="http://www.foolbirds.com/%e5%a6%82%e4%bd%95%e5%9c%a8fixtures-yml%e5%86%99%e5%be%aa%e7%8e%af%e6%b7%bb%e5%8a%a0%e6%95%b0%e6%8d%ae.html" title="如何在fixtures.yml写循环添加数据">如何在fixtures.yml写循环添加数据</a></li><li><a href="http://www.foolbirds.com/use_symfony_routing_change_url.html" title="使用symfony routing.yml 修改URL">使用symfony routing.yml 修改URL</a></li><li><a href="http://www.foolbirds.com/symfony-1-4-database-utf8.html" title="symfony 1.4 数据库 utf8设置">symfony 1.4 数据库 utf8设置</a></li><li><a href="http://www.foolbirds.com/symfony-cheat-sheet.html" title="symfony cheat sheet">symfony cheat sheet</a></li><li><a href="http://www.foolbirds.com/cheat-sheets.html" title="Cheat Sheets!">Cheat Sheets!</a></li><li><a href="http://www.foolbirds.com/url-in-other-apps2.html" title="怎么在app中构造其它app的链接(二)">怎么在app中构造其它app的链接(二)</a></li><li><a href="http://www.foolbirds.com/url-in-other-apps-one.html" title="怎么在app中构造其它app的链接(一)">怎么在app中构造其它app的链接(一)</a></li><li><a href="http://www.foolbirds.com/how-to-use-swift-to-send-mail-in-symfon.html" title="如何使用swift发送邮件">如何使用swift发送邮件</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.foolbirds.com/use_symfony_filter_to_filteredurl.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>仿symfony机制实现不用require或者include来实例化类</title>
		<link>http://www.foolbirds.com/%e4%bb%bfsymfony%e6%9c%ba%e5%88%b6%e5%ae%9e%e7%8e%b0%e4%b8%8d%e7%94%a8require%e6%88%96%e8%80%85include%e6%9d%a5%e5%ae%9e%e4%be%8b%e5%8c%96%e7%b1%bb.html</link>
		<comments>http://www.foolbirds.com/%e4%bb%bfsymfony%e6%9c%ba%e5%88%b6%e5%ae%9e%e7%8e%b0%e4%b8%8d%e7%94%a8require%e6%88%96%e8%80%85include%e6%9d%a5%e5%ae%9e%e4%be%8b%e5%8c%96%e7%b1%bb.html#comments</comments>
		<pubDate>Tue, 25 May 2010 02:35:33 +0000</pubDate>
		<dc:creator>kthiz2006</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[symfony]]></category>

		<guid isPermaLink="false">http://www.foolbirds.com/?p=1223</guid>
		<description><![CDATA[
class MyClass {
  public static function register() {
    //如果解串行器发现有未定义类要被实例化,则设置spl_autoload_call函数加载请求类.
    ini_set('unserialize_callback_func', 'spl_autoload_call');
    //自动载入类，类似于__autoload
    if (false === spl_autoload_register(array("MyClass","autoLoad"))) {
      throw new Exception('wrong');
    }
  }
  //处理自动载入类
  public static function autoload($className) {
    [...]]]></description>
			<content:encoded><![CDATA[<p><code><br />
class MyClass {<br />
  public static function register() {<br />
    //如果解串行器发现有未定义类要被实例化,则设置spl_autoload_call函数加载请求类.<br />
    ini_set('unserialize_callback_func', 'spl_autoload_call');<br />
    //自动载入类，类似于__autoload<br />
    if (false === spl_autoload_register(array("MyClass","autoLoad"))) {<br />
      throw new Exception('wrong');<br />
    }<br />
  }<br />
  //处理自动载入类<br />
  public static function autoload($className) {<br />
    require realpath(dirname(__FILE__)).'/lib/'.strtolower($className).'.class.php';<br />
  }<br />
}<br />
</code><br />
只要在项目目录中创建一个类的目录，这里我创建的叫lib，往这里放入你要放的类的文件。<br />
注:<br />
1.类的文件名要统一规则，这样方便系统快速地进行查找,避免消耗更多的内存。<br />
2.autoload的函数的载入类的规则可以依据需要进行设置，我这里规定要载入我的lib目录里文件的扩展名是class.php的类的文件。</p>
<p>以下是使用的例子：<br />
在创建的lib目录里方了一个叫cache的类的文件。<br />
接着在你要编写的程序文件里载入上边的说的自动载入类的文件，使用MyClass::register()，就可以不用载入要实例化的类的文件直接实例化刚才的cache的类的文件。</p>
<p>以上说的实现的效果必须是php的版本>=5.1.2</p>
<ul class="related_post"><li><a href="http://www.foolbirds.com/use-datetime-in-php5-1-x-with-symfony.html" title="symfony1.4 DateTime对于PHP低版本的兼容问题">symfony1.4 DateTime对于PHP低版本的兼容问题</a></li><li><a href="http://www.foolbirds.com/symfony-cheat-sheet.html" title="symfony cheat sheet">symfony cheat sheet</a></li><li><a href="http://www.foolbirds.com/cheat-sheets.html" title="Cheat Sheets!">Cheat Sheets!</a></li><li><a href="http://www.foolbirds.com/php%e4%b8%ad%e9%9d%99%e6%80%81%e8%b0%83%e7%94%a8%e9%9d%9e%e9%9d%99%e6%80%81%e6%96%b9%e6%b3%95.html" title="PHP中静态调用非静态方法">PHP中静态调用非静态方法</a></li><li><a href="http://www.foolbirds.com/use_symfony_filter_to_filteredurl.html" title="使用symfony filter 过滤URL">使用symfony filter 过滤URL</a></li><li><a href="http://www.foolbirds.com/vim%e9%85%8d%e5%90%88phpcs%e5%ae%9e%e7%8e%b0p%e8%87%aa%e5%8a%a8%e8%af%ad%e6%b3%95%e6%a3%80%e6%9f%a5.html" title="vim配合phpcs实现自动语法检查">vim配合phpcs实现自动语法检查</a></li><li><a href="http://www.foolbirds.com/%e5%a6%82%e4%bd%95%e5%9c%a8fixtures-yml%e5%86%99%e5%be%aa%e7%8e%af%e6%b7%bb%e5%8a%a0%e6%95%b0%e6%8d%ae.html" title="如何在fixtures.yml写循环添加数据">如何在fixtures.yml写循环添加数据</a></li><li><a href="http://www.foolbirds.com/%e4%bd%bf%e7%94%a8bit-ly%e7%9f%ad%e7%bd%91%e5%9d%80%e6%9c%8d%e5%8a%a1api%e7%ae%80%e5%8c%96url.html" title="使用Bit.ly短网址服务API简化URL">使用Bit.ly短网址服务API简化URL</a></li><li><a href="http://www.foolbirds.com/%e8%a7%a3%e5%86%b3php%e7%94%9f%e6%88%90utf-8%e7%bc%96%e7%a0%81%e7%9a%84csv%e6%96%87%e4%bb%b6%e7%94%a8excel%e6%89%93%e5%bc%80%e4%b9%b1%e7%a0%81%e7%9a%84%e9%97%ae%e9%a2%98.html" title="解决PHP生成UTF-8编码的CSV文件用Excel打开乱码的问题">解决PHP生成UTF-8编码的CSV文件用Excel打开乱码的问题</a></li><li><a href="http://www.foolbirds.com/symfony-1-4-database-utf8.html" title="symfony 1.4 数据库 utf8设置">symfony 1.4 数据库 utf8设置</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.foolbirds.com/%e4%bb%bfsymfony%e6%9c%ba%e5%88%b6%e5%ae%9e%e7%8e%b0%e4%b8%8d%e7%94%a8require%e6%88%96%e8%80%85include%e6%9d%a5%e5%ae%9e%e4%be%8b%e5%8c%96%e7%b1%bb.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>symfony1.4 DateTime对于PHP低版本的兼容问题</title>
		<link>http://www.foolbirds.com/use-datetime-in-php5-1-x-with-symfony.html</link>
		<comments>http://www.foolbirds.com/use-datetime-in-php5-1-x-with-symfony.html#comments</comments>
		<pubDate>Fri, 21 May 2010 05:17:53 +0000</pubDate>
		<dc:creator>szn000</dc:creator>
				<category><![CDATA[symfony]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.foolbirds.com/?p=1209</guid>
		<description><![CDATA[在symfony1.4中使用DateTime 类 但是该类出现于 PHP 5.2.0以后 所以在使用(部分方法需要在PHP5.3.0以后版本才能使用)PHP5.2.0以前版本的服务器上 调用symfony调用该函数会出错 为了解决该类问题根据 PHP5.2.0 的DateTime类 写了俩个类 用以在低版本中使用该类
以重写方法
DateTime.class.php
__construct ([ string $time = "now" [, DateTimeZone $timezone = NULL ]] )
string format ( string $format )
int getOffset ( void )
int getTimestamp ( void )
DateTimeZone getTimezone ( void )
DateTime setDate ( int $year , int $month , int $day )
DateTime setISODate ( int [...]]]></description>
			<content:encoded><![CDATA[<p>在symfony1.4中使用DateTime 类 但是该类出现于 PHP 5.2.0以后 所以在使用(部分方法需要在PHP5.3.0以后版本才能使用)PHP5.2.0以前版本的服务器上 调用symfony调用该函数会出错 为了解决该类问题根据 PHP5.2.0 的DateTime类 写了俩个类 用以在低版本中使用该类<br />
以重写方法<br />
DateTime.class.php<br />
<code>__construct ([ string $time = "now" [, DateTimeZone $timezone = NULL ]] )<br />
string format ( string $format )<br />
int getOffset ( void )<br />
int getTimestamp ( void )<br />
DateTimeZone getTimezone ( void )<br />
DateTime setDate ( int $year , int $month , int $day )<br />
DateTime setISODate ( int $year , int $week [, int $day = 1 ] )<br />
DateTime setTime ( int $hour , int $minute [, int $second = 0 ] )<br />
DateTime setTimestamp ( int $unixtimestamp )<br />
DateTime setTimezone ( DateTimeZone $timezone )<br />
DateTime __wakeup ( void )</code></p>
<p>DateTimeZone.class.php<br />
<code>__construct ( string $timezone )<br />
string getName ( void )<br />
int getOffset ( DateTime $datetime )</code><br />
文件下载地址: <a target = "_blank" href = "http://www.xun6.com/file/dbedf4439/DateTime_DateTimeZone.tar.gz.html">下载点击我</a><br />
附件使用时把类名中的My删除</p>
<ul class="related_post"><li><a href="http://www.foolbirds.com/%e4%bb%bfsymfony%e6%9c%ba%e5%88%b6%e5%ae%9e%e7%8e%b0%e4%b8%8d%e7%94%a8require%e6%88%96%e8%80%85include%e6%9d%a5%e5%ae%9e%e4%be%8b%e5%8c%96%e7%b1%bb.html" title="仿symfony机制实现不用require或者include来实例化类">仿symfony机制实现不用require或者include来实例化类</a></li><li><a href="http://www.foolbirds.com/symfony-cheat-sheet.html" title="symfony cheat sheet">symfony cheat sheet</a></li><li><a href="http://www.foolbirds.com/cheat-sheets.html" title="Cheat Sheets!">Cheat Sheets!</a></li><li><a href="http://www.foolbirds.com/php%e4%b8%ad%e9%9d%99%e6%80%81%e8%b0%83%e7%94%a8%e9%9d%9e%e9%9d%99%e6%80%81%e6%96%b9%e6%b3%95.html" title="PHP中静态调用非静态方法">PHP中静态调用非静态方法</a></li><li><a href="http://www.foolbirds.com/use_symfony_filter_to_filteredurl.html" title="使用symfony filter 过滤URL">使用symfony filter 过滤URL</a></li><li><a href="http://www.foolbirds.com/vim%e9%85%8d%e5%90%88phpcs%e5%ae%9e%e7%8e%b0p%e8%87%aa%e5%8a%a8%e8%af%ad%e6%b3%95%e6%a3%80%e6%9f%a5.html" title="vim配合phpcs实现自动语法检查">vim配合phpcs实现自动语法检查</a></li><li><a href="http://www.foolbirds.com/%e5%a6%82%e4%bd%95%e5%9c%a8fixtures-yml%e5%86%99%e5%be%aa%e7%8e%af%e6%b7%bb%e5%8a%a0%e6%95%b0%e6%8d%ae.html" title="如何在fixtures.yml写循环添加数据">如何在fixtures.yml写循环添加数据</a></li><li><a href="http://www.foolbirds.com/%e4%bd%bf%e7%94%a8bit-ly%e7%9f%ad%e7%bd%91%e5%9d%80%e6%9c%8d%e5%8a%a1api%e7%ae%80%e5%8c%96url.html" title="使用Bit.ly短网址服务API简化URL">使用Bit.ly短网址服务API简化URL</a></li><li><a href="http://www.foolbirds.com/%e8%a7%a3%e5%86%b3php%e7%94%9f%e6%88%90utf-8%e7%bc%96%e7%a0%81%e7%9a%84csv%e6%96%87%e4%bb%b6%e7%94%a8excel%e6%89%93%e5%bc%80%e4%b9%b1%e7%a0%81%e7%9a%84%e9%97%ae%e9%a2%98.html" title="解决PHP生成UTF-8编码的CSV文件用Excel打开乱码的问题">解决PHP生成UTF-8编码的CSV文件用Excel打开乱码的问题</a></li><li><a href="http://www.foolbirds.com/symfony-1-4-database-utf8.html" title="symfony 1.4 数据库 utf8设置">symfony 1.4 数据库 utf8设置</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.foolbirds.com/use-datetime-in-php5-1-x-with-symfony.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>如何在fixtures.yml写循环添加数据</title>
		<link>http://www.foolbirds.com/%e5%a6%82%e4%bd%95%e5%9c%a8fixtures-yml%e5%86%99%e5%be%aa%e7%8e%af%e6%b7%bb%e5%8a%a0%e6%95%b0%e6%8d%ae.html</link>
		<comments>http://www.foolbirds.com/%e5%a6%82%e4%bd%95%e5%9c%a8fixtures-yml%e5%86%99%e5%be%aa%e7%8e%af%e6%b7%bb%e5%8a%a0%e6%95%b0%e6%8d%ae.html#comments</comments>
		<pubDate>Thu, 20 May 2010 08:03:36 +0000</pubDate>
		<dc:creator>kthiz2006</dc:creator>
				<category><![CDATA[symfony]]></category>

		<guid isPermaLink="false">http://www.foolbirds.com/?p=802</guid>
		<description><![CDATA[举一个简单的例子：
city表的字段有id,enabled,name
那么往city表插入字段的写法如下:

city:
&#60;?php for ($i = 1; $i &#60;= 6; $i++): ?&#62;
city_&#60;?php echo $i ?&#62;:
enabled: 1
name:    city&#60;?php echo $i."\n" ?&#62;//用php写表的字段的数据结尾时一定写上"\n"
&#60;?php endfor; ?&#62;

注意：书写时一定要注意fixtures.yml的写法,注意空格.
使用symfony filter 过滤URL仿symfony机制实现不用require或者include来实例化类symfony1.4 DateTime对于PHP低版本的兼容问题symfony 1.4 数据库 utf8设置symfony cheat sheetCheat Sheets!如何使用swift发送邮件symfony1.2下的命令行程序(batch)symfony1.2的后台(generate-admin)模板结构在Symfony中使用第三方图片处理工具WideImage]]></description>
			<content:encoded><![CDATA[<p>举一个简单的例子：<br />
city表的字段有id,enabled,name<br />
那么往city表插入字段的写法如下:<br />
<code><br />
city:<br />
&lt;?php for ($i = 1; $i &lt;= 6; $i++): ?&gt;<br />
city_&lt;?php echo $i ?&gt;:<br />
enabled: 1<br />
name:    city&lt;?php echo $i."\n" ?&gt;//用php写表的字段的数据结尾时一定写上"\n"<br />
&lt;?php endfor; ?&gt;<br />
</code><br />
注意：书写时一定要注意fixtures.yml的写法,注意空格.</p>
<ul class="related_post"><li><a href="http://www.foolbirds.com/use_symfony_filter_to_filteredurl.html" title="使用symfony filter 过滤URL">使用symfony filter 过滤URL</a></li><li><a href="http://www.foolbirds.com/%e4%bb%bfsymfony%e6%9c%ba%e5%88%b6%e5%ae%9e%e7%8e%b0%e4%b8%8d%e7%94%a8require%e6%88%96%e8%80%85include%e6%9d%a5%e5%ae%9e%e4%be%8b%e5%8c%96%e7%b1%bb.html" title="仿symfony机制实现不用require或者include来实例化类">仿symfony机制实现不用require或者include来实例化类</a></li><li><a href="http://www.foolbirds.com/use-datetime-in-php5-1-x-with-symfony.html" title="symfony1.4 DateTime对于PHP低版本的兼容问题">symfony1.4 DateTime对于PHP低版本的兼容问题</a></li><li><a href="http://www.foolbirds.com/symfony-1-4-database-utf8.html" title="symfony 1.4 数据库 utf8设置">symfony 1.4 数据库 utf8设置</a></li><li><a href="http://www.foolbirds.com/symfony-cheat-sheet.html" title="symfony cheat sheet">symfony cheat sheet</a></li><li><a href="http://www.foolbirds.com/cheat-sheets.html" title="Cheat Sheets!">Cheat Sheets!</a></li><li><a href="http://www.foolbirds.com/how-to-use-swift-to-send-mail-in-symfon.html" title="如何使用swift发送邮件">如何使用swift发送邮件</a></li><li><a href="http://www.foolbirds.com/batch-in-symfony12.html" title="symfony1.2下的命令行程序(batch)">symfony1.2下的命令行程序(batch)</a></li><li><a href="http://www.foolbirds.com/generate-admin-templates-structure.html" title="symfony1.2的后台(generate-admin)模板结构">symfony1.2的后台(generate-admin)模板结构</a></li><li><a href="http://www.foolbirds.com/wideimage-in-symfony.html" title="在Symfony中使用第三方图片处理工具WideImage">在Symfony中使用第三方图片处理工具WideImage</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.foolbirds.com/%e5%a6%82%e4%bd%95%e5%9c%a8fixtures-yml%e5%86%99%e5%be%aa%e7%8e%af%e6%b7%bb%e5%8a%a0%e6%95%b0%e6%8d%ae.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>symfony 1.4 数据库 utf8设置</title>
		<link>http://www.foolbirds.com/symfony-1-4-database-utf8.html</link>
		<comments>http://www.foolbirds.com/symfony-1-4-database-utf8.html#comments</comments>
		<pubDate>Tue, 02 Feb 2010 09:30:52 +0000</pubDate>
		<dc:creator>bobhero</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[symfony]]></category>
		<category><![CDATA[1.4]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[utf8]]></category>

		<guid isPermaLink="false">http://www.foolbirds.com/?p=1099</guid>
		<description><![CDATA[symfony 1.4 更新好长时间了
也准备放弃 symfony1.2 改投 1.4
1.4照比 1.2有了很多更新 官方文档 我不是很满意，感觉有很多东西在文档上找不到全靠自己看代码 及 搜 英文blog
其中  symfony 1.4 对utf8  数据库的支持 我在 官方的文档中并没有找到好的例子 ，在英文blog中找到了一些个解决办法
如下

dsn:      sqlite:%SF_DATA_DIR%/database.db
username: root
password: 123456
attributes:
default_table_collate: utf8_general_ci
default_table_charset: utf8

使用symfony filter 过滤URL仿symfony机制实现不用require或者include来实例化类symfony1.4 DateTime对于PHP低版本的兼容问题如何在fixtures.yml写循环添加数据symfony cheat sheetCheat Sheets!如何使用swift发送邮件symfony1.2下的命令行程序(batch)symfony1.2的后台(generate-admin)模板结构在Symfony中使用第三方图片处理工具WideImage]]></description>
			<content:encoded><![CDATA[<p>symfony 1.4 更新好长时间了</p>
<p>也准备放弃 symfony1.2 改投 1.4</p>
<p>1.4照比 1.2有了很多更新 官方文档 我不是很满意，感觉有很多东西在文档上找不到全靠自己看代码 及 搜 英文blog</p>
<p>其中  symfony 1.4 对utf8  数据库的支持 我在 官方的文档中并没有找到好的例子 ，在英文blog中找到了一些个解决办法<br />
如下<br />
<code><br />
dsn:      sqlite:%SF_DATA_DIR%/database.db<br />
username: root<br />
password: 123456<br />
attributes:<br />
default_table_collate: utf8_general_ci<br />
default_table_charset: utf8<br />
</code></p>
<ul class="related_post"><li><a href="http://www.foolbirds.com/use_symfony_filter_to_filteredurl.html" title="使用symfony filter 过滤URL">使用symfony filter 过滤URL</a></li><li><a href="http://www.foolbirds.com/%e4%bb%bfsymfony%e6%9c%ba%e5%88%b6%e5%ae%9e%e7%8e%b0%e4%b8%8d%e7%94%a8require%e6%88%96%e8%80%85include%e6%9d%a5%e5%ae%9e%e4%be%8b%e5%8c%96%e7%b1%bb.html" title="仿symfony机制实现不用require或者include来实例化类">仿symfony机制实现不用require或者include来实例化类</a></li><li><a href="http://www.foolbirds.com/use-datetime-in-php5-1-x-with-symfony.html" title="symfony1.4 DateTime对于PHP低版本的兼容问题">symfony1.4 DateTime对于PHP低版本的兼容问题</a></li><li><a href="http://www.foolbirds.com/%e5%a6%82%e4%bd%95%e5%9c%a8fixtures-yml%e5%86%99%e5%be%aa%e7%8e%af%e6%b7%bb%e5%8a%a0%e6%95%b0%e6%8d%ae.html" title="如何在fixtures.yml写循环添加数据">如何在fixtures.yml写循环添加数据</a></li><li><a href="http://www.foolbirds.com/symfony-cheat-sheet.html" title="symfony cheat sheet">symfony cheat sheet</a></li><li><a href="http://www.foolbirds.com/cheat-sheets.html" title="Cheat Sheets!">Cheat Sheets!</a></li><li><a href="http://www.foolbirds.com/how-to-use-swift-to-send-mail-in-symfon.html" title="如何使用swift发送邮件">如何使用swift发送邮件</a></li><li><a href="http://www.foolbirds.com/batch-in-symfony12.html" title="symfony1.2下的命令行程序(batch)">symfony1.2下的命令行程序(batch)</a></li><li><a href="http://www.foolbirds.com/generate-admin-templates-structure.html" title="symfony1.2的后台(generate-admin)模板结构">symfony1.2的后台(generate-admin)模板结构</a></li><li><a href="http://www.foolbirds.com/wideimage-in-symfony.html" title="在Symfony中使用第三方图片处理工具WideImage">在Symfony中使用第三方图片处理工具WideImage</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.foolbirds.com/symfony-1-4-database-utf8.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>symfony cheat sheet</title>
		<link>http://www.foolbirds.com/symfony-cheat-sheet.html</link>
		<comments>http://www.foolbirds.com/symfony-cheat-sheet.html#comments</comments>
		<pubDate>Tue, 27 Oct 2009 04:44:54 +0000</pubDate>
		<dc:creator>maker</dc:creator>
				<category><![CDATA[symfony]]></category>
		<category><![CDATA[Cheat Sheets]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.foolbirds.com/?p=1037</guid>
		<description><![CDATA[上一篇文章里介绍了symfony的cheat sheet，但官方的下载地址貌似被墙，所以我也没有下载到全部的cheat sheet，不过还好bobhero那里有，虽然是1.0的，但很多内容依然很有用。
































Cheat Sheets!仿symfony机制实现不用require或者include来实例化类symfony1.4 DateTime对于PHP低版本的兼容问题PHP中静态调用非静态方法使用symfony filter 过滤URLvim配合phpcs实现自动语法检查如何在fixtures.yml写循环添加数据使用Bit.ly短网址服务API简化URL解决PHP生成UTF-8编码的CSV文件用Excel打开乱码的问题symfony 1.4 数据库 utf8设置]]></description>
			<content:encoded><![CDATA[<p><a href="/cheat-sheets.html">上一篇文章</a>里介绍了symfony的cheat sheet，但官方的下载地址貌似被墙，所以我也没有下载到全部的cheat sheet，不过还好bobhero那里有，虽然是1.0的，但很多内容依然很有用。</p>
<table>
<tr>
<td>
<div id="attachment_1051" class="wp-caption alignnone" style="width: 221px"><a href="http://www.foolbirds.com/wp-content/uploads/2009/10/symfony-cheatsheet-directory-structure-and-cli.pdf"><img class="size-medium wp-image-1051 " title="symfony directory structure and CLI" src="http://www.foolbirds.com/wp-content/uploads/2009/10/symfony-cheatsheet-directory-structure-and-cli-211x299.jpg" alt="symfony cheatsheet directory structure and cli" width="211" height="299" /></a><p class="wp-caption-text">symfony directory structure and CLI</p></div>
</td>
<td>
<div id="attachment_1052" class="wp-caption alignnone" style="width: 221px"><a href="http://www.foolbirds.com/wp-content/uploads/2009/10/symfony-cheatsheet-helpers-part1-js-and-ajax.pdf"><img class="size-medium wp-image-1052  " title="symfony helpers js and ajax" src="http://www.foolbirds.com/wp-content/uploads/2009/10/symfony-cheatsheet-helpers-part1-js-and-ajax-211x299.jpg" alt="symfony cheatsheet helpers part1 javascript and AJAX" width="211" height="299" /></a><p class="wp-caption-text">symfony helpers javascript and AJAX</p></div>
</td>
<td>
<div id="attachment_1053" class="wp-caption alignnone" style="width: 221px"><a href="http://www.foolbirds.com/wp-content/uploads/2009/10/symfony-cheatsheet-helpers-part2-forms.pdf"><img class="size-medium wp-image-1053" title="symfony helpers forms" src="http://www.foolbirds.com/wp-content/uploads/2009/10/symfony-cheatsheet-helpers-part2-forms-211x299.jpg" alt="symfony helpers forms" width="211" height="299" /></a><p class="wp-caption-text">symfony helpers forms</p></div>
</td>
</tr>
<tr>
<td>
<div id="attachment_1060" class="wp-caption alignnone" style="width: 221px"><a href="http://www.foolbirds.com/wp-content/uploads/2009/10/symfony-cheatsheet-views-part1.pdf"><img class="size-medium wp-image-1060 " title="symfony views part1" src="http://www.foolbirds.com/wp-content/uploads/2009/10/symfony-cheatsheet-views-part1-211x299.jpg" alt="symfony cheatsheet views part1" width="211" height="299" /></a><p class="wp-caption-text">symfony views part1</p></div>
</td>
<td>
<div id="attachment_1050" class="wp-caption alignnone" style="width: 221px"><a href="http://www.foolbirds.com/wp-content/uploads/2009/10/symfony-cheatsheet-views-part2.pdf"><img class="size-medium wp-image-1050 " title="symfony views part2" src="http://www.foolbirds.com/wp-content/uploads/2009/10/symfony-cheatsheet-views-part2-211x299.jpg" alt="symfony cheatsheet views part2" width="211" height="299" /></a><p class="wp-caption-text">symfony views part2</p></div>
</td>
<td>
<div id="attachment_1056" class="wp-caption alignnone" style="width: 221px"><a href="http://www.foolbirds.com/wp-content/uploads/2009/10/symfony-cheatsheet-model-part1.pdf"><img class="size-medium wp-image-1056 " title="symfony model part1" src="http://www.foolbirds.com/wp-content/uploads/2009/10/symfony-cheatsheet-model-part1-211x299.jpg" alt="symfony cheatsheet model part1" width="211" height="299" /></a><p class="wp-caption-text">symfony model part1</p></div>
</td>
</tr>
<tr>
<td>
<div id="attachment_1057" class="wp-caption alignnone" style="width: 221px"><a href="http://www.foolbirds.com/wp-content/uploads/2009/10/symfony-cheatsheet-model-part2.pdf"><img class="size-medium wp-image-1057 " title="symfony model part2" src="http://www.foolbirds.com/wp-content/uploads/2009/10/symfony-cheatsheet-model-part2-211x299.jpg" alt="symfony cheatsheet model part2" width="211" height="299" /></a><p class="wp-caption-text">symfony model part2</p></div>
</td>
<td>
<div id="attachment_1055" class="wp-caption alignnone" style="width: 221px"><a href="http://www.foolbirds.com/wp-content/uploads/2009/10/symfony-cheatsheet-model-criteria-criterionrs.pdf"><img class="size-medium wp-image-1055" title="symfony model criteria criterionrs" src="http://www.foolbirds.com/wp-content/uploads/2009/10/symfony-cheatsheet-model-criteria-criterionrs-211x299.jpg" alt="symfony model criteria criterionrs" width="211" height="299" /></a><p class="wp-caption-text">symfony model criteria criterionrs</p></div>
</td>
<td>
<div id="attachment_1059" class="wp-caption alignnone" style="width: 221px"><a href="http://www.foolbirds.com/wp-content/uploads/2009/10/symfony-cheatsheet-server-validation.pdf"><img class="size-medium wp-image-1059 " title="symfony server validation" src="http://www.foolbirds.com/wp-content/uploads/2009/10/symfony-cheatsheet-server-validation-211x299.jpg" alt="symfony cheatsheet server validation" width="211" height="299" /></a><p class="wp-caption-text">symfony server validation</p></div>
</td>
</tr>
<tr>
<td>
<div id="attachment_1054" class="wp-caption alignnone" style="width: 242px"><a href="http://www.foolbirds.com/wp-content/uploads/2009/10/symfony-cheatsheet-lime.pdf"><img class="size-medium wp-image-1054" title="symfony lime" src="http://www.foolbirds.com/wp-content/uploads/2009/10/symfony-cheatsheet-lime-232x300.jpg" alt="symfony lime" width="232" height="300" /></a><p class="wp-caption-text">symfony lime</p></div>
</td>
<td colspan='2'>
<div id="attachment_1058" class="wp-caption alignnone" style="width: 310px"><a href="http://www.foolbirds.com/wp-content/uploads/2009/10/symfony-cheatsheet-orm.pdf"><img class="size-medium wp-image-1058" title="symfony orm" src="http://www.foolbirds.com/wp-content/uploads/2009/10/symfony-cheatsheet-orm-300x212.jpg" alt="symfony orm" width="300" height="212" /></a><p class="wp-caption-text">symfony orm</p></div>
</td>
</tr>
</table>
<ul class="related_post"><li><a href="http://www.foolbirds.com/cheat-sheets.html" title="Cheat Sheets!">Cheat Sheets!</a></li><li><a href="http://www.foolbirds.com/%e4%bb%bfsymfony%e6%9c%ba%e5%88%b6%e5%ae%9e%e7%8e%b0%e4%b8%8d%e7%94%a8require%e6%88%96%e8%80%85include%e6%9d%a5%e5%ae%9e%e4%be%8b%e5%8c%96%e7%b1%bb.html" title="仿symfony机制实现不用require或者include来实例化类">仿symfony机制实现不用require或者include来实例化类</a></li><li><a href="http://www.foolbirds.com/use-datetime-in-php5-1-x-with-symfony.html" title="symfony1.4 DateTime对于PHP低版本的兼容问题">symfony1.4 DateTime对于PHP低版本的兼容问题</a></li><li><a href="http://www.foolbirds.com/php%e4%b8%ad%e9%9d%99%e6%80%81%e8%b0%83%e7%94%a8%e9%9d%9e%e9%9d%99%e6%80%81%e6%96%b9%e6%b3%95.html" title="PHP中静态调用非静态方法">PHP中静态调用非静态方法</a></li><li><a href="http://www.foolbirds.com/use_symfony_filter_to_filteredurl.html" title="使用symfony filter 过滤URL">使用symfony filter 过滤URL</a></li><li><a href="http://www.foolbirds.com/vim%e9%85%8d%e5%90%88phpcs%e5%ae%9e%e7%8e%b0p%e8%87%aa%e5%8a%a8%e8%af%ad%e6%b3%95%e6%a3%80%e6%9f%a5.html" title="vim配合phpcs实现自动语法检查">vim配合phpcs实现自动语法检查</a></li><li><a href="http://www.foolbirds.com/%e5%a6%82%e4%bd%95%e5%9c%a8fixtures-yml%e5%86%99%e5%be%aa%e7%8e%af%e6%b7%bb%e5%8a%a0%e6%95%b0%e6%8d%ae.html" title="如何在fixtures.yml写循环添加数据">如何在fixtures.yml写循环添加数据</a></li><li><a href="http://www.foolbirds.com/%e4%bd%bf%e7%94%a8bit-ly%e7%9f%ad%e7%bd%91%e5%9d%80%e6%9c%8d%e5%8a%a1api%e7%ae%80%e5%8c%96url.html" title="使用Bit.ly短网址服务API简化URL">使用Bit.ly短网址服务API简化URL</a></li><li><a href="http://www.foolbirds.com/%e8%a7%a3%e5%86%b3php%e7%94%9f%e6%88%90utf-8%e7%bc%96%e7%a0%81%e7%9a%84csv%e6%96%87%e4%bb%b6%e7%94%a8excel%e6%89%93%e5%bc%80%e4%b9%b1%e7%a0%81%e7%9a%84%e9%97%ae%e9%a2%98.html" title="解决PHP生成UTF-8编码的CSV文件用Excel打开乱码的问题">解决PHP生成UTF-8编码的CSV文件用Excel打开乱码的问题</a></li><li><a href="http://www.foolbirds.com/symfony-1-4-database-utf8.html" title="symfony 1.4 数据库 utf8设置">symfony 1.4 数据库 utf8设置</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.foolbirds.com/symfony-cheat-sheet.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Cheat Sheets!</title>
		<link>http://www.foolbirds.com/cheat-sheets.html</link>
		<comments>http://www.foolbirds.com/cheat-sheets.html#comments</comments>
		<pubDate>Thu, 22 Oct 2009 08:59:25 +0000</pubDate>
		<dc:creator>maker</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[symfony]]></category>
		<category><![CDATA[Cheat Sheets]]></category>

		<guid isPermaLink="false">http://www.foolbirds.com/?p=1005</guid>
		<description><![CDATA[bobhero就喜欢搞一些稀奇古怪的东西，800块的古董式键盘买了两个外加一个超级怪异的轨迹球鼠标，智能手机买了两个一个打电话一个玩日历，Arch Linux装了Awesome然后接了两个显示器。早在两年之前，我刚来公司的时候，就对他的这些卡片很感兴趣。

这个东西的英文名叫cheat sheet，找了很久也没有找到一个合适的中文名，不过我觉得叫备忘卡很合适。从以往的工作上来看，cheatsheet的确帮了不少忙，最关键是省了翻手册的时间，网上有很多的cheat sheet，打印下来，塑封，然后放在电脑旁，下面是来自Added Bytes的cheat sheets。



PHP  (V1)
PHP (V2)
Mysql







JavaScript 
CSS (V1)
CSS  (V2)







mod_rewrite  (V1)
mod_rewrite (V2)
HTML







正则表达式 (V1)
正则表达式 (V2)
ASP/VBScript







Python (V1)
Ruby on Rails
Subversion(SVN)








请访问 http://www.addedbytes.com/cheat-sheets/获取更多的CheatSheets.
注意：打印cheatsheet最好打印pdf版本的，图片格式的清晰度可能不是很好。忘了提醒大家了，塑封的时候可以把两张塑封到一起，比如PHP(V1)和PHP(V2)可以塑封个反正面。
下面这些是symfony官方提供的cheat sheets，貌似是1.0的，不过或多或少还有些用处。



Symfony Admin Generator
Symfony Directory Structure And CLI







请访问http://trac.symfony-project.org/wiki/CheatSheets来获取更多的symfony cheat sheets。下载链接我这里访问不了，不知道是删掉了还是被墙了，有新的发现我会再发出来。
http://www.addedbytes.com/cheat-sheets/php-cheat-sheet/
symfony cheat sheet仿symfony机制实现不用require或者include来实例化类symfony1.4 DateTime对于PHP低版本的兼容问题PHP中静态调用非静态方法使用symfony filter 过滤URLvim配合phpcs实现自动语法检查如何在fixtures.yml写循环添加数据使用Bit.ly短网址服务API简化URL解决PHP生成UTF-8编码的CSV文件用Excel打开乱码的问题symfony 1.4 数据库 utf8设置]]></description>
			<content:encoded><![CDATA[<p>bobhero就喜欢搞一些稀奇古怪的东西，800块的古董式键盘买了两个外加一个超级怪异的轨迹球鼠标，智能手机买了两个一个打电话一个玩日历，Arch Linux装了Awesome然后接了两个显示器。早在两年之前，我刚来公司的时候，就对他的这些卡片很感兴趣。</p>
<p style="text-align: center;"><a href="http://www.foolbirds.com/wp-content/uploads/2009/10/cheatsheets.jpg"><img class="size-medium wp-image-1007 aligncenter" title="cheatsheets" src="http://www.foolbirds.com/wp-content/uploads/2009/10/cheatsheets-222x300.jpg" alt="cheatsheets" width="222" height="300" /></a></p>
<p>这个东西的英文名叫cheat sheet，找了很久也没有找到一个合适的中文名，不过我觉得叫备忘卡很合适。从以往的工作上来看，cheatsheet的确帮了不少忙，最关键是省了翻手册的时间，网上有很多的cheat sheet，打印下来，塑封，然后放在电脑旁，下面是来自<a href="http://www.addedbytes.com/cheat-sheets/">Added Bytes</a>的cheat sheets。</p>
<table border="0">
<tbody>
<tr>
<td><a href="http://www.addedbytes.com/cheat-sheets/php-cheat-sheet-version-1/">PHP  (V1)</a></td>
<td><a href="http://www.addedbytes.com/cheat-sheets/php-cheat-sheet/">PHP (V2)</a></td>
<td><a href="http://www.addedbytes.com/cheat-sheets/mysql-cheat-sheet/">Mysql</a></td>
</tr>
<tr>
<td><a href="http://www.addedbytes.com/cheat-sheets/php-cheat-sheet-version-1/"><img class="alignnone size-medium wp-image-1006" title="php-cheat-sheet-v1" src="http://www.foolbirds.com/wp-content/uploads/2009/10/php-cheat-sheet-v1-230x300.png" alt="php-cheat-sheet-v1" width="230" height="300" /></a></td>
<td><a href="http://www.addedbytes.com/cheat-sheets/php-cheat-sheet/"><img class="alignnone size-medium wp-image-1008" title="php-cheat-sheet-v2" src="http://www.foolbirds.com/wp-content/uploads/2009/10/php-cheat-sheet-v2-220x300.png" alt="php-cheat-sheet-v2" width="220" height="300" /></a></td>
<td><a href="http://www.addedbytes.com/cheat-sheets/mysql-cheat-sheet/"><img class="alignnone size-medium wp-image-1009" title="mysql-cheat-sheet-v1" src="http://www.foolbirds.com/wp-content/uploads/2009/10/mysql-cheat-sheet-v1-230x300.png" alt="mysql-cheat-sheet-v1" width="230" height="300" /></a></td>
</tr>
<tr>
<td><a href="http://www.addedbytes.com/cheat-sheets/javascript-cheat-sheet/">JavaScript </a></td>
<td><a href="http://www.addedbytes.com/cheat-sheets/css-cheat-sheet-version-1/">CSS (V1)</a></td>
<td><a href="http://www.addedbytes.com/cheat-sheets/css-cheat-sheet/">CSS  (V2)</a></td>
</tr>
<tr>
<td><a href="http://www.addedbytes.com/cheat-sheets/javascript-cheat-sheet/"><img class="alignnone size-medium wp-image-1010" title="javascript-cheat-sheet-v1" src="http://www.foolbirds.com/wp-content/uploads/2009/10/javascript-cheat-sheet-v1-220x300.png" alt="javascript-cheat-sheet-v1" width="220" height="300" /></a></td>
<td><a href="http://www.addedbytes.com/cheat-sheets/css-cheat-sheet-version-1/"><img class="alignnone size-medium wp-image-1011" title="css-cheat-sheet-v1" src="http://www.foolbirds.com/wp-content/uploads/2009/10/css-cheat-sheet-v1-220x300.png" alt="css-cheat-sheet-v1" width="220" height="300" /></a></td>
<td><a href="http://www.addedbytes.com/cheat-sheets/css-cheat-sheet/"><img class="alignnone size-medium wp-image-1012" title="css-cheat-sheet-v2" src="http://www.foolbirds.com/wp-content/uploads/2009/10/css-cheat-sheet-v2-220x300.png" alt="css-cheat-sheet-v2" width="220" height="300" /></a></td>
</tr>
<tr>
<td><a href="http://www.addedbytes.com/cheat-sheets/mod_rewrite-cheat-sheet-version-1/">mod_rewrite  (V1)</a></td>
<td><a href="http://www.addedbytes.com/apache/mod_rewrite-cheat-sheet/">mod_rewrite (V2)</a></td>
<td><a href="http://www.addedbytes.com/cheat-sheets/html-cheat-sheet/">HTML</a></td>
</tr>
<tr>
<td><a href="http://www.addedbytes.com/cheat-sheets/mod_rewrite-cheat-sheet-version-1/"><img class="alignnone size-medium wp-image-1013" title="mod_rewrite-cheat-sheet-v1" src="http://www.foolbirds.com/wp-content/uploads/2009/10/mod_rewrite-cheat-sheet-v1-221x300.png" alt="mod_rewrite-cheat-sheet-v1" width="221" height="300" /></a></td>
<td><a href="http://www.addedbytes.com/apache/mod_rewrite-cheat-sheet/"><img class="alignnone size-medium wp-image-1014" title="mod_rewrite-cheat-sheet-v2" src="http://www.foolbirds.com/wp-content/uploads/2009/10/mod_rewrite-cheat-sheet-v2-220x300.png" alt="mod_rewrite-cheat-sheet-v2" width="220" height="300" /></a></td>
<td><a href="http://www.addedbytes.com/cheat-sheets/html-cheat-sheet/"><img class="alignnone size-medium wp-image-1015" title="html-cheat-sheet-v1" src="http://www.foolbirds.com/wp-content/uploads/2009/10/html-cheat-sheet-v1-220x300.png" alt="html-cheat-sheet-v1" width="220" height="300" /></a></td>
</tr>
<tr>
<td><a href="http://www.addedbytes.com/cheat-sheets/regular-expressions-cheat-sheet-version-1/">正则表达式 (V1)</a></td>
<td><a href="http://www.addedbytes.com/cheat-sheets/regular-expressions-cheat-sheet/">正则表达式 (V2)</a></td>
<td><a href="http://www.addedbytes.com/cheat-sheets/asp-vbscript-cheat-sheet/">ASP/VBScript</a></td>
</tr>
<tr>
<td><a href="http://www.addedbytes.com/cheat-sheets/regular-expressions-cheat-sheet-version-1/"><img class="alignnone size-medium wp-image-1016" title="regular-expressions-cheat-sheet-v1" src="http://www.foolbirds.com/wp-content/uploads/2009/10/regular-expressions-cheat-sheet-v1-220x300.png" alt="regular-expressions-cheat-sheet-v1" width="220" height="300" /></a></td>
<td><a href="http://www.addedbytes.com/cheat-sheets/regular-expressions-cheat-sheet/"></a><a href="http://www.addedbytes.com/cheat-sheets/regular-expressions-cheat-sheet/"><img class="alignnone size-medium wp-image-1017" title="regular-expressions-cheat-sheet-v2" src="http://www.foolbirds.com/wp-content/uploads/2009/10/regular-expressions-cheat-sheet-v2-220x300.png" alt="regular-expressions-cheat-sheet-v2" width="220" height="300" /></a></td>
<td><a href="http://www.addedbytes.com/cheat-sheets/asp-vbscript-cheat-sheet/"></a><a href="http://www.addedbytes.com/cheat-sheets/asp-vbscript-cheat-sheet/"><img class="alignnone size-medium wp-image-1018" title="asp-cheat-sheet-v1" src="http://www.foolbirds.com/wp-content/uploads/2009/10/asp-cheat-sheet-v1-230x300.png" alt="asp-cheat-sheet-v1" width="230" height="300" /></a></td>
</tr>
<tr>
<td><a href="python-cheat-sheet-v1">Python (V1)</a></td>
<td><a href="http://www.addedbytes.com/cheat-sheets/ruby-on-rails-cheat-sheet/">Ruby on Rails</a></td>
<td><a href="http://www.addedbytes.com/cheat-sheets/subversion-cheat-sheet/">Subversion(SVN)</a></td>
</tr>
<tr>
<td><a href="http://www.addedbytes.com/cheat-sheets/python-cheat-sheet/"><img class="alignnone size-medium wp-image-1019" title="python-cheat-sheet-v1" src="http://www.foolbirds.com/wp-content/uploads/2009/10/python-cheat-sheet-v1-220x300.png" alt="python-cheat-sheet-v1" width="220" height="300" /></a></td>
<td><a href="http://www.addedbytes.com/cheat-sheets/ruby-on-rails-cheat-sheet/"><img class="alignnone size-medium wp-image-1020" title="ruby-on-rails-cheat-sheet-v1" src="http://www.foolbirds.com/wp-content/uploads/2009/10/ruby-on-rails-cheat-sheet-v1-220x300.png" alt="ruby-on-rails-cheat-sheet-v1" width="220" height="300" /></a></td>
<td><a href="http://www.addedbytes.com/cheat-sheets/subversion-cheat-sheet/"><img class="alignnone size-medium wp-image-1021" title="subversion-cheat-sheet-v1" src="http://www.foolbirds.com/wp-content/uploads/2009/10/subversion-cheat-sheet-v1-220x300.png" alt="subversion-cheat-sheet-v1" width="220" height="300" /></a></td>
</tr>
</tbody>
</table>
<p>请访问 <a href="http://www.addedbytes.com/cheat-sheets/">http://www.addedbytes.com/cheat-sheets/</a>获取更多的CheatSheets.</p>
<p><span style="color: #ff0000;">注意：打印cheatsheet最好打印pdf版本的，图片格式的清晰度可能不是很好。忘了提醒大家了，塑封的时候可以把两张塑封到一起，比如PHP(V1)和PHP(V2)可以塑封个反正面。</span></p>
<p>下面这些是<a href="http://www.symfony-project.com">symfony</a>官方提供的cheat sheets，貌似是1.0的，不过或多或少还有些用处。</p>
<table border="0">
<tbody>
<tr>
<td><a href="http://www.symfony-project.com/uploads/assets/sfAdminGeneratorRefCard.pdf">Symfony Admin Generator</a></td>
<td><a href="http://www.foolbirds.com/wp-content/uploads/2009/10/symfony-directory-structure-and-cli.jpg">Symfony Directory Structure And CLI</a></td>
</tr>
<tr>
<td><a href="http://www.symfony-project.com/uploads/assets/sfAdminGeneratorRefCard.pdf"><img class="alignnone size-medium wp-image-1025" title="symfony-admin-generator" src="http://www.foolbirds.com/wp-content/uploads/2009/10/symfony-admin-generator-300x216.jpg" alt="symfony-admin-generator" width="300" height="216" /></a></td>
<td><a href="http://www.foolbirds.com/wp-content/uploads/2009/10/symfony-directory-structure-and-cli.jpg"><img class="alignnone size-medium wp-image-1026" title="symfony-directory-structure-and-cli" src="http://www.foolbirds.com/wp-content/uploads/2009/10/symfony-directory-structure-and-cli-212x300.jpg" alt="symfony-directory-structure-and-cli" width="212" height="300" /></a></td>
</tr>
</tbody>
</table>
<p>请访问<a href="http://trac.symfony-project.org/wiki/CheatSheets">http://trac.symfony-project.org/wiki/CheatSheets</a>来获取更多的symfony cheat sheets。下载链接我这里访问不了，不知道是删掉了还是被墙了，有新的发现我会再发出来。</p>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 389px; width: 1px; height: 1px;">http://www.addedbytes.com/cheat-sheets/php-cheat-sheet/</div>
<ul class="related_post"><li><a href="http://www.foolbirds.com/symfony-cheat-sheet.html" title="symfony cheat sheet">symfony cheat sheet</a></li><li><a href="http://www.foolbirds.com/%e4%bb%bfsymfony%e6%9c%ba%e5%88%b6%e5%ae%9e%e7%8e%b0%e4%b8%8d%e7%94%a8require%e6%88%96%e8%80%85include%e6%9d%a5%e5%ae%9e%e4%be%8b%e5%8c%96%e7%b1%bb.html" title="仿symfony机制实现不用require或者include来实例化类">仿symfony机制实现不用require或者include来实例化类</a></li><li><a href="http://www.foolbirds.com/use-datetime-in-php5-1-x-with-symfony.html" title="symfony1.4 DateTime对于PHP低版本的兼容问题">symfony1.4 DateTime对于PHP低版本的兼容问题</a></li><li><a href="http://www.foolbirds.com/php%e4%b8%ad%e9%9d%99%e6%80%81%e8%b0%83%e7%94%a8%e9%9d%9e%e9%9d%99%e6%80%81%e6%96%b9%e6%b3%95.html" title="PHP中静态调用非静态方法">PHP中静态调用非静态方法</a></li><li><a href="http://www.foolbirds.com/use_symfony_filter_to_filteredurl.html" title="使用symfony filter 过滤URL">使用symfony filter 过滤URL</a></li><li><a href="http://www.foolbirds.com/vim%e9%85%8d%e5%90%88phpcs%e5%ae%9e%e7%8e%b0p%e8%87%aa%e5%8a%a8%e8%af%ad%e6%b3%95%e6%a3%80%e6%9f%a5.html" title="vim配合phpcs实现自动语法检查">vim配合phpcs实现自动语法检查</a></li><li><a href="http://www.foolbirds.com/%e5%a6%82%e4%bd%95%e5%9c%a8fixtures-yml%e5%86%99%e5%be%aa%e7%8e%af%e6%b7%bb%e5%8a%a0%e6%95%b0%e6%8d%ae.html" title="如何在fixtures.yml写循环添加数据">如何在fixtures.yml写循环添加数据</a></li><li><a href="http://www.foolbirds.com/%e4%bd%bf%e7%94%a8bit-ly%e7%9f%ad%e7%bd%91%e5%9d%80%e6%9c%8d%e5%8a%a1api%e7%ae%80%e5%8c%96url.html" title="使用Bit.ly短网址服务API简化URL">使用Bit.ly短网址服务API简化URL</a></li><li><a href="http://www.foolbirds.com/%e8%a7%a3%e5%86%b3php%e7%94%9f%e6%88%90utf-8%e7%bc%96%e7%a0%81%e7%9a%84csv%e6%96%87%e4%bb%b6%e7%94%a8excel%e6%89%93%e5%bc%80%e4%b9%b1%e7%a0%81%e7%9a%84%e9%97%ae%e9%a2%98.html" title="解决PHP生成UTF-8编码的CSV文件用Excel打开乱码的问题">解决PHP生成UTF-8编码的CSV文件用Excel打开乱码的问题</a></li><li><a href="http://www.foolbirds.com/symfony-1-4-database-utf8.html" title="symfony 1.4 数据库 utf8设置">symfony 1.4 数据库 utf8设置</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.foolbirds.com/cheat-sheets.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>如何使用swift发送邮件</title>
		<link>http://www.foolbirds.com/how-to-use-swift-to-send-mail-in-symfon.html</link>
		<comments>http://www.foolbirds.com/how-to-use-swift-to-send-mail-in-symfon.html#comments</comments>
		<pubDate>Mon, 11 May 2009 08:24:21 +0000</pubDate>
		<dc:creator>kthiz2006</dc:creator>
				<category><![CDATA[symfony]]></category>
		<category><![CDATA[mail]]></category>

		<guid isPermaLink="false">http://www.foolbirds.com/?p=771</guid>
		<description><![CDATA[首先在项目的lib下建立vendor的文件夹
然后
svn checkout http://swiftmailer.svn.sourceforge.net/svnroot/swiftmailer/tags/php5/3.3.3/lib/ swift
接着把svn剪出的文件夹里的文件放到vendor目录下.
这样就可以使用swift发送邮件了
下面是一个简单的例子

&#60;?php
try
{
// Create the mailer and message objects
$mailer = new Swift(new Swift_Connection_NativeMail());
$message = new Swift_Message('Mail\'s subject', $mailBody, 'text/html');
// Send
$mailer-&#62;send($message, $mailTo, $mailFrom);
$mailer-&#62;disconnect();
}
catch (Exception $e)
{
$mailer-&#62;disconnect();
// handle errors here
}
?&#62;

使用symfony filter 过滤URL仿symfony机制实现不用require或者include来实例化类symfony1.4 DateTime对于PHP低版本的兼容问题如何在fixtures.yml写循环添加数据symfony 1.4 数据库 utf8设置symfony cheat sheetCheat Sheets!symfony1.2下的命令行程序(batch)symfony1.2的后台(generate-admin)模板结构在Symfony中使用第三方图片处理工具WideImage]]></description>
			<content:encoded><![CDATA[<p>首先在项目的lib下建立vendor的文件夹<br />
然后<br />
svn checkout http://swiftmailer.svn.sourceforge.net/svnroot/swiftmailer/tags/php5/3.3.3/lib/ swift<br />
接着把svn剪出的文件夹里的文件放到vendor目录下.<br />
这样就可以使用swift发送邮件了<br />
下面是一个简单的例子<br />
<code><br />
&lt;?php<br />
try<br />
{<br />
// Create the mailer and message objects<br />
$mailer = new Swift(new Swift_Connection_NativeMail());<br />
$message = new Swift_Message('Mail\'s subject', $mailBody, 'text/html');<br />
// Send<br />
$mailer-&gt;send($message, $mailTo, $mailFrom);<br />
$mailer-&gt;disconnect();<br />
}<br />
catch (Exception $e)<br />
{<br />
$mailer-&gt;disconnect();<br />
// handle errors here<br />
}<br />
?&gt;<br />
</code></p>
<ul class="related_post"><li><a href="http://www.foolbirds.com/use_symfony_filter_to_filteredurl.html" title="使用symfony filter 过滤URL">使用symfony filter 过滤URL</a></li><li><a href="http://www.foolbirds.com/%e4%bb%bfsymfony%e6%9c%ba%e5%88%b6%e5%ae%9e%e7%8e%b0%e4%b8%8d%e7%94%a8require%e6%88%96%e8%80%85include%e6%9d%a5%e5%ae%9e%e4%be%8b%e5%8c%96%e7%b1%bb.html" title="仿symfony机制实现不用require或者include来实例化类">仿symfony机制实现不用require或者include来实例化类</a></li><li><a href="http://www.foolbirds.com/use-datetime-in-php5-1-x-with-symfony.html" title="symfony1.4 DateTime对于PHP低版本的兼容问题">symfony1.4 DateTime对于PHP低版本的兼容问题</a></li><li><a href="http://www.foolbirds.com/%e5%a6%82%e4%bd%95%e5%9c%a8fixtures-yml%e5%86%99%e5%be%aa%e7%8e%af%e6%b7%bb%e5%8a%a0%e6%95%b0%e6%8d%ae.html" title="如何在fixtures.yml写循环添加数据">如何在fixtures.yml写循环添加数据</a></li><li><a href="http://www.foolbirds.com/symfony-1-4-database-utf8.html" title="symfony 1.4 数据库 utf8设置">symfony 1.4 数据库 utf8设置</a></li><li><a href="http://www.foolbirds.com/symfony-cheat-sheet.html" title="symfony cheat sheet">symfony cheat sheet</a></li><li><a href="http://www.foolbirds.com/cheat-sheets.html" title="Cheat Sheets!">Cheat Sheets!</a></li><li><a href="http://www.foolbirds.com/batch-in-symfony12.html" title="symfony1.2下的命令行程序(batch)">symfony1.2下的命令行程序(batch)</a></li><li><a href="http://www.foolbirds.com/generate-admin-templates-structure.html" title="symfony1.2的后台(generate-admin)模板结构">symfony1.2的后台(generate-admin)模板结构</a></li><li><a href="http://www.foolbirds.com/wideimage-in-symfony.html" title="在Symfony中使用第三方图片处理工具WideImage">在Symfony中使用第三方图片处理工具WideImage</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.foolbirds.com/how-to-use-swift-to-send-mail-in-symfon.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>symfony1.2下的命令行程序(batch)</title>
		<link>http://www.foolbirds.com/batch-in-symfony12.html</link>
		<comments>http://www.foolbirds.com/batch-in-symfony12.html#comments</comments>
		<pubDate>Wed, 06 May 2009 07:09:15 +0000</pubDate>
		<dc:creator>maker</dc:creator>
				<category><![CDATA[symfony]]></category>
		<category><![CDATA[batch]]></category>
		<category><![CDATA[task]]></category>

		<guid isPermaLink="false">http://www.foolbirds.com/?p=745</guid>
		<description><![CDATA[这里说的命令行程序就是在命令行(或者叫shell)下执行的程序,　因为我们多数时间是用浏览器来访问symfony程序的,　而有些时候,　我们也需要在shell下来执行我们的程序,　比如定时任务.
在网上一番搜索并没有找到相关内容,　在１.０的&#60;The Definitive Guide To symfony&#62;里提到了一个init-batch的命令,　但是这个命令在１.２中已经不存在了.
后来终于在symfony命令中发现了generate:task命令,　这个命令的帮助文档是这样写的.
语法:
symfony generate:task [--dir="..."] [--use-database="..."] [--brief-description="..."] task_name
参数:
task_name            The task name (can contain namespace)
选项:
–dir                The directory to create the task in (default: lib/task)
–use-database     [...]]]></description>
			<content:encoded><![CDATA[<p>这里说的命令行程序就是在命令行(或者叫shell)下执行的程序,　因为我们多数时间是用浏览器来访问symfony程序的,　而有些时候,　我们也需要在shell下来执行我们的程序,　比如定时任务.</p>
<p>在网上一番搜索并没有找到相关内容,　在１.０的&lt;<a href="http://www.symfony-project.org/book/1_0/">The Definitive Guide To symfony</a>&gt;里提到了一个init-batch的命令,　但是这个命令在１.２中已经不存在了.</p>
<p>后来终于在symfony命令中发现了generate:task命令,　这个命令的帮助文档是这样写的.</p>
<blockquote><p>语法:<br />
symfony generate:task [--dir="..."] [--use-database="..."] [--brief-description="..."] task_name</p>
<p>参数:<br />
task_name            The task name (can contain namespace)</p>
<p>选项:<br />
–dir                The directory to create the task in (default: lib/task)<br />
–use-database       Whether the task needs model initialization to access database (default: propel)<br />
–brief-description  A brief task description (appears in task list)</p>
<p>描述:<br />
The generate:task creates a new sfTask class based on the name passed as<br />
argument:</p>
<p>./symfony generate:task namespace:name</p>
<p>The namespaceNameTask.class.php skeleton task is created under the lib/task/<br />
directory. Note that the namespace is optional.</p>
<p>If you want to create the file in another directory (relative to the project<br />
root folder), pass it in the –dir option. This directory will be created<br />
if it does not already exist.</p>
<p>./symfony generate:task namespace:name –dir=plugins/myPlugin/lib/task</p>
<p>If you want the task to default to a connection other than propel, provide<br />
the name of this connection with the –use-database option:</p>
<p>./symfony generate:task namespace:name –use-database=main</p>
<p>The –use-database option can also be used to disable database<br />
initialization in the generated task:</p>
<p>./symfony generate:task namespace:name –use-database=false</p>
<p>You can also specify a description:</p>
<p>./symfony generate:task namespace:name –brief-description=”Does interesting things”</p></blockquote>
<p>简单来说, 这个命令是用来创建命令行任务的, 我们来做一个简单的测试.</p>
<p><code>./symfony generate:task test</code></p>
<p>这样我们就生成了test命令, 我们可以象下面这样使用test命令</p>
<p><code>./symfony test</code></p>
<p>虽然什么也没有输出, 但是没有报错说明命令存在. 如果要给命令添加动作需要修改 /lib/task/testTask.class.php</p>
<p>我们写一个简单的例子</p>
<p><code>// add your code here<br />
echo "it runing\n";<br />
$users = UserPeer::doSelect(new Criteria);<br />
echo count($users);</code></p>
<p>这段代码执行了数据库操作, 这说明在task中类都是自动在载的, 详细阅读testTask.class.php中的代码我们会发现task还支持很多功能, 设置参数, 命名空间等等.</p>
<p>(未完待续)</p>
<ul class="related_post"><li><a href="http://www.foolbirds.com/use_symfony_filter_to_filteredurl.html" title="使用symfony filter 过滤URL">使用symfony filter 过滤URL</a></li><li><a href="http://www.foolbirds.com/%e4%bb%bfsymfony%e6%9c%ba%e5%88%b6%e5%ae%9e%e7%8e%b0%e4%b8%8d%e7%94%a8require%e6%88%96%e8%80%85include%e6%9d%a5%e5%ae%9e%e4%be%8b%e5%8c%96%e7%b1%bb.html" title="仿symfony机制实现不用require或者include来实例化类">仿symfony机制实现不用require或者include来实例化类</a></li><li><a href="http://www.foolbirds.com/use-datetime-in-php5-1-x-with-symfony.html" title="symfony1.4 DateTime对于PHP低版本的兼容问题">symfony1.4 DateTime对于PHP低版本的兼容问题</a></li><li><a href="http://www.foolbirds.com/%e5%a6%82%e4%bd%95%e5%9c%a8fixtures-yml%e5%86%99%e5%be%aa%e7%8e%af%e6%b7%bb%e5%8a%a0%e6%95%b0%e6%8d%ae.html" title="如何在fixtures.yml写循环添加数据">如何在fixtures.yml写循环添加数据</a></li><li><a href="http://www.foolbirds.com/symfony-1-4-database-utf8.html" title="symfony 1.4 数据库 utf8设置">symfony 1.4 数据库 utf8设置</a></li><li><a href="http://www.foolbirds.com/symfony-cheat-sheet.html" title="symfony cheat sheet">symfony cheat sheet</a></li><li><a href="http://www.foolbirds.com/cheat-sheets.html" title="Cheat Sheets!">Cheat Sheets!</a></li><li><a href="http://www.foolbirds.com/how-to-use-swift-to-send-mail-in-symfon.html" title="如何使用swift发送邮件">如何使用swift发送邮件</a></li><li><a href="http://www.foolbirds.com/generate-admin-templates-structure.html" title="symfony1.2的后台(generate-admin)模板结构">symfony1.2的后台(generate-admin)模板结构</a></li><li><a href="http://www.foolbirds.com/wideimage-in-symfony.html" title="在Symfony中使用第三方图片处理工具WideImage">在Symfony中使用第三方图片处理工具WideImage</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.foolbirds.com/batch-in-symfony12.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>symfony1.2的后台(generate-admin)模板结构</title>
		<link>http://www.foolbirds.com/generate-admin-templates-structure.html</link>
		<comments>http://www.foolbirds.com/generate-admin-templates-structure.html#comments</comments>
		<pubDate>Wed, 08 Apr 2009 09:24:43 +0000</pubDate>
		<dc:creator>maker</dc:creator>
				<category><![CDATA[symfony]]></category>
		<category><![CDATA[后台]]></category>
		<category><![CDATA[模板]]></category>
		<category><![CDATA[结构]]></category>

		<guid isPermaLink="false">http://www.foolbirds.com/?p=722</guid>
		<description><![CDATA[这里所指的后台模块是指由propel:generate-admin生成的后台管理模块，在symfony中可以自动生成一套强大的管理后台，并且可以订制或者重写模块中的动作或者模板，这里我们简单介绍一下模板的组成结构。
比如我们要给Test对象生成一套管理后台，那么我们使用命令
./symfony propel:generate-admin backend Test --module=test
然后我们访问backend/test, 这样你会看到一个自动生成的管理页面, 其程序在cache/app_name/env_name/modules/autoMudule/ 目录下. 我们这里主要分析模板目录templates, symfony1.2生成了以下的模板
indexSuccess.php # 列表页
_assets.php # 载入样式和脚本
_flashes.php # 消息框
_list_header.php # 页首
_list.php # 列表
_list_td_stacked.php
_list_th_stacked.php
_list_th_tabular.php # 列标题
_list_td_batch_actions.php # 复选框
_list_td_tabular.php # 一条记录
_list_field_boolean.php # boolean类型的表示方式
_list_td_actions.php # 对象操作
_list_batch_actions.php # 批量操作
_pagination.php # 分页条
_list_actions.php # 操作, 新建等
_filters.php # 过滤器
_filters_field.php # 过滤器中的一项
_list_footer.php # 页尾
newSuccess.php # 新建页
editSuccess.php # 编辑页和新建页用了同一种结构
_assets.php # 载入样式和脚本
_flashes.php # 消息框
_form.php # 表单
_form_fieldset.php # 一组表单项
_form_field.php [...]]]></description>
			<content:encoded><![CDATA[<p>这里所指的后台模块是指由propel:generate-admin生成的后台管理模块，在symfony中可以自动生成一套强大的管理后台，并且可以订制或者重写模块中的动作或者模板，这里我们简单介绍一下模板的组成结构。</p>
<p>比如我们要给Test对象生成一套管理后台，那么我们使用命令</p>
<p><code>./symfony propel:generate-admin backend Test --module=test</code></p>
<p>然后我们访问backend/test, 这样你会看到一个自动生成的管理页面, 其程序在cache/app_name/env_name/modules/autoMudule/ 目录下. 我们这里主要分析模板目录templates, symfony1.2生成了以下的模板</p>
<blockquote><p>indexSuccess.php # 列表页</p>
<p style="padding-left: 30px;">_assets.php # 载入样式和脚本<br />
_flashes.php # 消息框<br />
_list_header.php # 页首<br />
_list.php # 列表</p>
<p style="padding-left: 60px;">_list_td_stacked.php<br />
_list_th_stacked.php<br />
_list_th_tabular.php # 列标题<br />
_list_td_batch_actions.php # 复选框<br />
_list_td_tabular.php # 一条记录</p>
<p style="padding-left: 90px;">_list_field_boolean.php # boolean类型的表示方式</p>
<p style="padding-left: 60px;">_list_td_actions.php # 对象操作</p>
<p style="padding-left: 30px;">_list_batch_actions.php # 批量操作</p>
<p style="padding-left: 30px;">_pagination.php # 分页条<br />
_list_actions.php # 操作, 新建等<br />
_filters.php # 过滤器</p>
<p style="padding-left: 60px;">_filters_field.php # 过滤器中的一项</p>
<p style="padding-left: 30px;">_list_footer.php # 页尾</p>
<p>newSuccess.php # 新建页<br />
editSuccess.php # 编辑页和新建页用了同一种结构</p>
<p style="padding-left: 30px;">_assets.php # 载入样式和脚本<br />
_flashes.php # 消息框<br />
_form.php # 表单</p>
<p style="padding-left: 60px;">_form_fieldset.php # 一组表单项</p>
<p style="padding-left: 90px;">_form_field.php # 一个表单项</p>
<p style="padding-left: 30px;">_form_actions.php # 操作, 提交, 取消等<br />
_form_footer.php # 页尾</p>
<p style="padding-left: 30px;">
</blockquote>
<p>上面的缩进代表了调用关系, 为了更直观的表现出模板的结构, 做了下面两个图片</p>
<p>图1, 列表页的组成</p>
<p><img class="aligncenter size-full wp-image-723" title="index" src="http://www.foolbirds.com/wp-content/uploads/2009/04/index.png" alt="index" width="808" height="456" /></p>
<p>图2, 新建和修改页的结构</p>
<p><img class="aligncenter size-full wp-image-724" title="new" src="http://www.foolbirds.com/wp-content/uploads/2009/04/new.png" alt="new" width="555" height="377" /></p>
<p>本文完.</p>
<ul class="related_post"><li><a href="http://www.foolbirds.com/use_symfony_filter_to_filteredurl.html" title="使用symfony filter 过滤URL">使用symfony filter 过滤URL</a></li><li><a href="http://www.foolbirds.com/%e4%bb%bfsymfony%e6%9c%ba%e5%88%b6%e5%ae%9e%e7%8e%b0%e4%b8%8d%e7%94%a8require%e6%88%96%e8%80%85include%e6%9d%a5%e5%ae%9e%e4%be%8b%e5%8c%96%e7%b1%bb.html" title="仿symfony机制实现不用require或者include来实例化类">仿symfony机制实现不用require或者include来实例化类</a></li><li><a href="http://www.foolbirds.com/use-datetime-in-php5-1-x-with-symfony.html" title="symfony1.4 DateTime对于PHP低版本的兼容问题">symfony1.4 DateTime对于PHP低版本的兼容问题</a></li><li><a href="http://www.foolbirds.com/%e5%a6%82%e4%bd%95%e5%9c%a8fixtures-yml%e5%86%99%e5%be%aa%e7%8e%af%e6%b7%bb%e5%8a%a0%e6%95%b0%e6%8d%ae.html" title="如何在fixtures.yml写循环添加数据">如何在fixtures.yml写循环添加数据</a></li><li><a href="http://www.foolbirds.com/symfony-1-4-database-utf8.html" title="symfony 1.4 数据库 utf8设置">symfony 1.4 数据库 utf8设置</a></li><li><a href="http://www.foolbirds.com/symfony-cheat-sheet.html" title="symfony cheat sheet">symfony cheat sheet</a></li><li><a href="http://www.foolbirds.com/cheat-sheets.html" title="Cheat Sheets!">Cheat Sheets!</a></li><li><a href="http://www.foolbirds.com/how-to-use-swift-to-send-mail-in-symfon.html" title="如何使用swift发送邮件">如何使用swift发送邮件</a></li><li><a href="http://www.foolbirds.com/batch-in-symfony12.html" title="symfony1.2下的命令行程序(batch)">symfony1.2下的命令行程序(batch)</a></li><li><a href="http://www.foolbirds.com/wideimage-in-symfony.html" title="在Symfony中使用第三方图片处理工具WideImage">在Symfony中使用第三方图片处理工具WideImage</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.foolbirds.com/generate-admin-templates-structure.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>在Symfony中使用第三方图片处理工具WideImage</title>
		<link>http://www.foolbirds.com/wideimage-in-symfony.html</link>
		<comments>http://www.foolbirds.com/wideimage-in-symfony.html#comments</comments>
		<pubDate>Tue, 31 Mar 2009 06:01:00 +0000</pubDate>
		<dc:creator>maker</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[symfony]]></category>
		<category><![CDATA[wideimage]]></category>
		<category><![CDATA[中文]]></category>
		<category><![CDATA[图片]]></category>

		<guid isPermaLink="false">http://www.foolbirds.com/?p=693</guid>
		<description><![CDATA[最近在整理php的一些库，同时也在研究图片处理的相关功能，所以就发现了WideImage, 虽然是很强大的一个图片处理库，但貌似在国内没有很多人知道。
看了网上很多的图片处理类，功能也就是简单的水印和缩略图，这些WideImage都不在话下，在WideImage源代码中的demos里，我们可以看到转换灰度图，反色，遮罩（Mask）处理，通道（Channels）处理，水印，滤镜，缩放，旋转，翻转和Canvas(我理解也就是在图片上写字)等等功能。
下面简单记录一下如何将WideImage用在symfony中。
首先我们去WideImage的主页（http://wideimage.sourceforge.net/）下载源码包，解包之后会有三个目录，lib，tests，demos，lib是库文件，tests是测试文件，demos中是作者提供的代码示例，可以直接运行访问，要在symfony中使用WideImage，只要将lib目录放在项目的lib目录中就可以。
下面是一些简单的例子：

/**
* 遮罩处理
*/
public function executeMask(sfWebRequest $request)
{
$dir = sfConfig::get('sf_web_dir').DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR;
$img = wiImage::load($dir.'test.gif');
$mask = wiImage::load($dir.'m.gif');
$img-&#62;applyMask($mask, 0, 0)-&#62;saveToFile($dir.'mask.png');
return sfView::NONE;
}
/**
* 过滤器和格式转换
*
*/
public function executeFilter(sfWebRequest $request)
{
$dir = sfConfig::get('sf_web_dir').DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR;
$img = wiImage::load($dir.'test.gif');
$img-&#62;applyFilter(IMG_FILTER_GRAYSCALE, 111, 222, 111)-&#62;saveToFile($dir.'filter.png');
return sfView::NONE;
}
/**
* 缩放
*/
public function executeResize(sfWebRequest $request)
{
$dir = sfConfig::get('sf_web_dir').DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR;
$img = wiImage::load($dir.'test.jpg');
$img-&#62;resize(100, '30%', 'fill')-&#62;saveToFile($dir.'resizefill.jpg');
$img-&#62;resize(100, '30%', 'inside')-&#62;saveToFile($dir.'resizeinside.jpg');
$img-&#62;resize(100, '30%', 'outside')-&#62;saveToFile($dir.'resizeoutside.jpg');
return sfView::NONE;
}
/**
* 文字水印
*/
public function executeFont(sfWebRequest $request)
{
$dir = sfConfig::get('sf_web_dir').DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR;
$img = wiImage::load($dir.'test.jpg');
/*
在图片上输出中文的问题困扰了我很久，有些字体始终是乱码，这里使
用的是方正仿宋简体，可以正常输出UTF-8编码的中文简体字符串。
*/
$font = $dir.'fzfsjt.ttf';
$text = '你好';
$canvas = [...]]]></description>
			<content:encoded><![CDATA[<p>最近在整理php的一些库，同时也在研究图片处理的相关功能，所以就发现了<a href="http://wideimage.sourceforge.net/">WideImage</a>, 虽然是很强大的一个图片处理库，但貌似在国内没有很多人知道。</p>
<p>看了网上很多的图片处理类，功能也就是简单的水印和缩略图，这些WideImage都不在话下，在WideImage源代码中的demos里，我们可以看到转换灰度图，反色，遮罩（Mask）处理，通道（Channels）处理，水印，滤镜，缩放，旋转，翻转和Canvas(我理解也就是在图片上写字)等等功能。</p>
<p>下面简单记录一下如何将WideImage用在symfony中。</p>
<p>首先我们去WideImage的主页（<a href="http://wideimage.sourceforge.net/">http://wideimage.sourceforge.net/</a>）下载源码包，解包之后会有三个目录，lib，tests，demos，lib是库文件，tests是测试文件，demos中是作者提供的代码示例，可以直接运行访问，要在symfony中使用WideImage，只要将lib目录放在项目的lib目录中就可以。</p>
<p>下面是一些简单的例子：<br />
<code><br />
/**<br />
* 遮罩处理<br />
*/<br />
public function executeMask(sfWebRequest $request)<br />
{<br />
$dir = sfConfig::get('sf_web_dir').DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR;<br />
$img = wiImage::load($dir.'test.gif');<br />
$mask = wiImage::load($dir.'m.gif');<br />
$img-&gt;applyMask($mask, 0, 0)-&gt;saveToFile($dir.'mask.png');<br />
return sfView::NONE;<br />
}</code></p>
<p><code>/**<br />
* 过滤器和格式转换<br />
*<br />
*/<br />
public function executeFilter(sfWebRequest $request)<br />
{<br />
$dir = sfConfig::get('sf_web_dir').DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR;<br />
$img = wiImage::load($dir.'test.gif');<br />
$img-&gt;applyFilter(IMG_FILTER_GRAYSCALE, 111, 222, 111)-&gt;saveToFile($dir.'filter.png');<br />
return sfView::NONE;<br />
}</code></p>
<p><code>/**<br />
* 缩放<br />
*/<br />
public function executeResize(sfWebRequest $request)<br />
{<br />
$dir = sfConfig::get('sf_web_dir').DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR;<br />
$img = wiImage::load($dir.'test.jpg');<br />
$img-&gt;resize(100, '30%', 'fill')-&gt;saveToFile($dir.'resizefill.jpg');<br />
$img-&gt;resize(100, '30%', 'inside')-&gt;saveToFile($dir.'resizeinside.jpg');<br />
$img-&gt;resize(100, '30%', 'outside')-&gt;saveToFile($dir.'resizeoutside.jpg');<br />
return sfView::NONE;<br />
}</code></p>
<p><code>/**<br />
* 文字水印<br />
*/<br />
public function executeFont(sfWebRequest $request)<br />
{<br />
$dir = sfConfig::get('sf_web_dir').DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR;<br />
$img = wiImage::load($dir.'test.jpg');<br />
/*<br />
在图片上输出中文的问题困扰了我很久，有些字体始终是乱码，这里使<br />
用的是方正仿宋简体，可以正常输出UTF-8编码的中文简体字符串。<br />
*/<br />
$font = $dir.'fzfsjt.ttf';<br />
$text = '你好';<br />
$canvas = $img-&gt;getCanvas();<br />
$canvas-&gt;setFont(new wiFont_TTF($font, 10, $img-&gt;allocateColor(0,0,255)));<br />
// 参数 x y text angel<br />
$canvas-&gt;writeText(60, 50, $text, 0);<br />
$img-&gt;saveToFile($dir.'font.png');<br />
return sfView::NONE;<br />
}<br />
</code><br />
更多的示例请查阅WideImage的主页（<a href="http://wideimage.sourceforge.net/">http://wideimage.sourceforge.net/</a>）或者查看demos。</p>
<ul class="related_post"><li><a href="http://www.foolbirds.com/about-upload-images-path.html" title="关于上传图片后显示上传图片的路径问题">关于上传图片后显示上传图片的路径问题</a></li><li><a href="http://www.foolbirds.com/use_symfony_filter_to_filteredurl.html" title="使用symfony filter 过滤URL">使用symfony filter 过滤URL</a></li><li><a href="http://www.foolbirds.com/%e4%bb%bfsymfony%e6%9c%ba%e5%88%b6%e5%ae%9e%e7%8e%b0%e4%b8%8d%e7%94%a8require%e6%88%96%e8%80%85include%e6%9d%a5%e5%ae%9e%e4%be%8b%e5%8c%96%e7%b1%bb.html" title="仿symfony机制实现不用require或者include来实例化类">仿symfony机制实现不用require或者include来实例化类</a></li><li><a href="http://www.foolbirds.com/use-datetime-in-php5-1-x-with-symfony.html" title="symfony1.4 DateTime对于PHP低版本的兼容问题">symfony1.4 DateTime对于PHP低版本的兼容问题</a></li><li><a href="http://www.foolbirds.com/%e5%a6%82%e4%bd%95%e5%9c%a8fixtures-yml%e5%86%99%e5%be%aa%e7%8e%af%e6%b7%bb%e5%8a%a0%e6%95%b0%e6%8d%ae.html" title="如何在fixtures.yml写循环添加数据">如何在fixtures.yml写循环添加数据</a></li><li><a href="http://www.foolbirds.com/symfony-1-4-database-utf8.html" title="symfony 1.4 数据库 utf8设置">symfony 1.4 数据库 utf8设置</a></li><li><a href="http://www.foolbirds.com/symfony-cheat-sheet.html" title="symfony cheat sheet">symfony cheat sheet</a></li><li><a href="http://www.foolbirds.com/cheat-sheets.html" title="Cheat Sheets!">Cheat Sheets!</a></li><li><a href="http://www.foolbirds.com/image-upload-preview.html" title="兼容IE6,IE7,IE8和Firefox的图片上传预览效果">兼容IE6,IE7,IE8和Firefox的图片上传预览效果</a></li><li><a href="http://www.foolbirds.com/how-to-use-swift-to-send-mail-in-symfon.html" title="如何使用swift发送邮件">如何使用swift发送邮件</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.foolbirds.com/wideimage-in-symfony.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>如何在WINDOWS下设置SYMFONY1.2</title>
		<link>http://www.foolbirds.com/how-to-install-symfony12-in-windows.html</link>
		<comments>http://www.foolbirds.com/how-to-install-symfony12-in-windows.html#comments</comments>
		<pubDate>Thu, 26 Mar 2009 08:24:07 +0000</pubDate>
		<dc:creator>kthiz2006</dc:creator>
				<category><![CDATA[symfony]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.foolbirds.com/?p=680</guid>
		<description><![CDATA[   1. SVN SYMFONY
         1. svn http://svn.symfony-project.com/branches/1.2
   2. 设置PHP环境变量
         1. 设置系统的 path 将 php.exe 的目录添加到path中，这样就可以用 php symfony 来运行命令
   3. 安装pear
         1. cmd 下运行　　go-pear.bat
   [...]]]></description>
			<content:encoded><![CDATA[<p>   1. SVN SYMFONY<br />
         1. svn http://svn.symfony-project.com/branches/1.2<br />
   2. 设置PHP环境变量<br />
         1. 设置系统的 path 将 php.exe 的目录添加到path中，这样就可以用 php symfony 来运行命令<br />
   3. 安装pear<br />
         1. cmd 下运行　　go-pear.bat<br />
         2. pear upgrade-all  将pear 升级到最新版<br />
               1. 过程中可能会报内存不足的错，自行修改php.ini 的设置 可以解决<br />
   4. 设置虚拟机<br />
         1. 需要打开rewrite功能<br />
         2. <VirtualHost *:80><br />
                DocumentRoot &#8220;d:/wamp/www/sftest/web&#8221;<br />
                ServerName sftest<br />
                alias /sf &#8220;d:/symfony1.2/data/web/sf/&#8221;<br />
                <Directory "d:/symfony1.2/data/web/sf/" ><br />
                    AllowOverride All<br />
                    Allow from All<br />
                </Directory><br />
                <Directory "d:/wamp/www/sftest/web" ><br />
                    AllowOverride All<br />
                    Allow from All<br />
                </Directory><br />
            </VirtualHost><br />
   5. 设置php扩展<br />
         1. xsl 扩展需要打开<br />
         2. mysqlpdo需要打开<br />
         3. domxml扩展需要屏闭掉，否则会影响symfony解析xml<br />
   6. 以 php d:\symfony1.2\data\bin\symfony init-proj sftest 的形式  来使用命令行(因为symonfy文件命的不同，地址也会不同) 或将 symfony 命令所在目录设在PATH 里 就可以直接通过 symfony init-proj sftest 这样的办法执行命令了（这一办法在1.1的时候行不通,在1.2下测试通过.</p>
<ul class="related_post"><li><a href="http://www.foolbirds.com/use_symfony_filter_to_filteredurl.html" title="使用symfony filter 过滤URL">使用symfony filter 过滤URL</a></li><li><a href="http://www.foolbirds.com/%e4%bb%bfsymfony%e6%9c%ba%e5%88%b6%e5%ae%9e%e7%8e%b0%e4%b8%8d%e7%94%a8require%e6%88%96%e8%80%85include%e6%9d%a5%e5%ae%9e%e4%be%8b%e5%8c%96%e7%b1%bb.html" title="仿symfony机制实现不用require或者include来实例化类">仿symfony机制实现不用require或者include来实例化类</a></li><li><a href="http://www.foolbirds.com/use-datetime-in-php5-1-x-with-symfony.html" title="symfony1.4 DateTime对于PHP低版本的兼容问题">symfony1.4 DateTime对于PHP低版本的兼容问题</a></li><li><a href="http://www.foolbirds.com/%e5%a6%82%e4%bd%95%e5%9c%a8fixtures-yml%e5%86%99%e5%be%aa%e7%8e%af%e6%b7%bb%e5%8a%a0%e6%95%b0%e6%8d%ae.html" title="如何在fixtures.yml写循环添加数据">如何在fixtures.yml写循环添加数据</a></li><li><a href="http://www.foolbirds.com/symfony-1-4-database-utf8.html" title="symfony 1.4 数据库 utf8设置">symfony 1.4 数据库 utf8设置</a></li><li><a href="http://www.foolbirds.com/symfony-cheat-sheet.html" title="symfony cheat sheet">symfony cheat sheet</a></li><li><a href="http://www.foolbirds.com/cheat-sheets.html" title="Cheat Sheets!">Cheat Sheets!</a></li><li><a href="http://www.foolbirds.com/how-to-use-swift-to-send-mail-in-symfon.html" title="如何使用swift发送邮件">如何使用swift发送邮件</a></li><li><a href="http://www.foolbirds.com/batch-in-symfony12.html" title="symfony1.2下的命令行程序(batch)">symfony1.2下的命令行程序(batch)</a></li><li><a href="http://www.foolbirds.com/generate-admin-templates-structure.html" title="symfony1.2的后台(generate-admin)模板结构">symfony1.2的后台(generate-admin)模板结构</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.foolbirds.com/how-to-install-symfony12-in-windows.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Add table prefix  in symfony－在symfony中使用表前缀</title>
		<link>http://www.foolbirds.com/add-table-prefix-in-symfony.html</link>
		<comments>http://www.foolbirds.com/add-table-prefix-in-symfony.html#comments</comments>
		<pubDate>Tue, 24 Mar 2009 08:51:30 +0000</pubDate>
		<dc:creator>maker</dc:creator>
				<category><![CDATA[symfony]]></category>
		<category><![CDATA[prefix]]></category>
		<category><![CDATA[propel]]></category>
		<category><![CDATA[表前缀]]></category>

		<guid isPermaLink="false">http://www.foolbirds.com/?p=675</guid>
		<description><![CDATA[The propel 1.3 is support table prefixes.
In your config/propel.ini add the following:
propel.tablePrefix=prefix_
then run the propel:build-all-load task.
Done!
网上找不到任何关于symfony或者propel支持表前缀的资料，只在propel1.3的修改历史中发现了1.3是支持表前缀的，但文档却没有更新相关内容，无奈之下只能查看源码，最后终于让我找到了。
补遗：还有一种方法我觉得是更加可靠的，那就是手动修改schema.yml中的全部数据库名，手动加前缀，同时强制设定表的phpName保证其不会随着表名一同变化,然后重新./symfony propel:build-all
symfony数据表关联详解(for propel)关于数据查询的使用使用symfony filter 过滤URL仿symfony机制实现不用require或者include来实例化类symfony1.4 DateTime对于PHP低版本的兼容问题如何在fixtures.yml写循环添加数据symfony 1.4 数据库 utf8设置symfony cheat sheetCheat Sheets!如何使用swift发送邮件]]></description>
			<content:encoded><![CDATA[<p>The propel 1.3 is support table prefixes.</p>
<p>In your config/propel.ini add the following:</p>
<p><code>propel.tablePrefix=prefix_</code></p>
<p>then run the propel:build-all-load task.</p>
<p>Done!</p>
<p>网上找不到任何关于symfony或者propel支持表前缀的资料，只在propel1.3的修改历史中发现了1.3是支持表前缀的，但文档却没有更新相关内容，无奈之下只能查看源码，最后终于让我找到了。</p>
<p>补遗：还有一种方法我觉得是更加可靠的，那就是手动修改schema.yml中的全部数据库名，手动加前缀，同时强制设定表的phpName保证其不会随着表名一同变化,然后重新./symfony propel:build-all</p>
<ul class="related_post"><li><a href="http://www.foolbirds.com/symfony-references-with-propel.html" title="symfony数据表关联详解(for propel)">symfony数据表关联详解(for propel)</a></li><li><a href="http://www.foolbirds.com/use-orm-propel.html" title="关于数据查询的使用">关于数据查询的使用</a></li><li><a href="http://www.foolbirds.com/use_symfony_filter_to_filteredurl.html" title="使用symfony filter 过滤URL">使用symfony filter 过滤URL</a></li><li><a href="http://www.foolbirds.com/%e4%bb%bfsymfony%e6%9c%ba%e5%88%b6%e5%ae%9e%e7%8e%b0%e4%b8%8d%e7%94%a8require%e6%88%96%e8%80%85include%e6%9d%a5%e5%ae%9e%e4%be%8b%e5%8c%96%e7%b1%bb.html" title="仿symfony机制实现不用require或者include来实例化类">仿symfony机制实现不用require或者include来实例化类</a></li><li><a href="http://www.foolbirds.com/use-datetime-in-php5-1-x-with-symfony.html" title="symfony1.4 DateTime对于PHP低版本的兼容问题">symfony1.4 DateTime对于PHP低版本的兼容问题</a></li><li><a href="http://www.foolbirds.com/%e5%a6%82%e4%bd%95%e5%9c%a8fixtures-yml%e5%86%99%e5%be%aa%e7%8e%af%e6%b7%bb%e5%8a%a0%e6%95%b0%e6%8d%ae.html" title="如何在fixtures.yml写循环添加数据">如何在fixtures.yml写循环添加数据</a></li><li><a href="http://www.foolbirds.com/symfony-1-4-database-utf8.html" title="symfony 1.4 数据库 utf8设置">symfony 1.4 数据库 utf8设置</a></li><li><a href="http://www.foolbirds.com/symfony-cheat-sheet.html" title="symfony cheat sheet">symfony cheat sheet</a></li><li><a href="http://www.foolbirds.com/cheat-sheets.html" title="Cheat Sheets!">Cheat Sheets!</a></li><li><a href="http://www.foolbirds.com/how-to-use-swift-to-send-mail-in-symfon.html" title="如何使用swift发送邮件">如何使用swift发送邮件</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.foolbirds.com/add-table-prefix-in-symfony.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Symfony中的action和actions</title>
		<link>http://www.foolbirds.com/symfony%e4%b8%ad%e7%9a%84action%e5%92%8cactions.html</link>
		<comments>http://www.foolbirds.com/symfony%e4%b8%ad%e7%9a%84action%e5%92%8cactions.html#comments</comments>
		<pubDate>Tue, 17 Mar 2009 08:10:06 +0000</pubDate>
		<dc:creator>zhuozi</dc:creator>
				<category><![CDATA[symfony]]></category>

		<guid isPermaLink="false">http://www.foolbirds.com/?p=667</guid>
		<description><![CDATA[Action Class with Two Actions, in frontend/modules/mymodule/actions/actions.class.php

class mymoduleActions extends sfActions
{
  public function executeIndex()
  {
    // ...
  }
  public function executeList()
  {
    // ...
  }
}

Single Action File, in frontend/modules/mymodule/actions/indexAction.class.php

class indexAction extends sfAction
{
  public function execute($request)
  {
    // ...
  [...]]]></description>
			<content:encoded><![CDATA[<p>Action Class with Two Actions, in frontend/modules/mymodule/actions/actions.class.php<br />
<code><br />
class mymoduleActions extends sfActions<br />
{<br />
  public function executeIndex()<br />
  {<br />
    // ...<br />
  }<br />
  public function executeList()<br />
  {<br />
    // ...<br />
  }<br />
}<br />
</code><br />
Single Action File, in frontend/modules/mymodule/actions/indexAction.class.php<br />
<code><br />
class indexAction extends sfAction<br />
{<br />
  public function execute($request)<br />
  {<br />
    // ...<br />
  }<br />
}<br />
</code><br />
Single Action File, in frontend/modules/mymodule/actions/listAction.class.php<br />
<code><br />
class listAction extends sfAction<br />
{<br />
  public function execute($request)<br />
  {<br />
    // ...<br />
  }<br />
}<br />
</code><br />
由于项目需要，需要多人同时针对一个module的相关操作进行修改，虽然是各修改各的，可是在合并的时候，如果采用acitons的方法，文件一定会出现很大的冲突，还好symfony可以定义单个的action，这样我们就可以有效的避免这个问题。</p>
<ul class="related_post"><li><a href="http://www.foolbirds.com/use_symfony_filter_to_filteredurl.html" title="使用symfony filter 过滤URL">使用symfony filter 过滤URL</a></li><li><a href="http://www.foolbirds.com/%e4%bb%bfsymfony%e6%9c%ba%e5%88%b6%e5%ae%9e%e7%8e%b0%e4%b8%8d%e7%94%a8require%e6%88%96%e8%80%85include%e6%9d%a5%e5%ae%9e%e4%be%8b%e5%8c%96%e7%b1%bb.html" title="仿symfony机制实现不用require或者include来实例化类">仿symfony机制实现不用require或者include来实例化类</a></li><li><a href="http://www.foolbirds.com/use-datetime-in-php5-1-x-with-symfony.html" title="symfony1.4 DateTime对于PHP低版本的兼容问题">symfony1.4 DateTime对于PHP低版本的兼容问题</a></li><li><a href="http://www.foolbirds.com/%e5%a6%82%e4%bd%95%e5%9c%a8fixtures-yml%e5%86%99%e5%be%aa%e7%8e%af%e6%b7%bb%e5%8a%a0%e6%95%b0%e6%8d%ae.html" title="如何在fixtures.yml写循环添加数据">如何在fixtures.yml写循环添加数据</a></li><li><a href="http://www.foolbirds.com/symfony-1-4-database-utf8.html" title="symfony 1.4 数据库 utf8设置">symfony 1.4 数据库 utf8设置</a></li><li><a href="http://www.foolbirds.com/symfony-cheat-sheet.html" title="symfony cheat sheet">symfony cheat sheet</a></li><li><a href="http://www.foolbirds.com/cheat-sheets.html" title="Cheat Sheets!">Cheat Sheets!</a></li><li><a href="http://www.foolbirds.com/how-to-use-swift-to-send-mail-in-symfon.html" title="如何使用swift发送邮件">如何使用swift发送邮件</a></li><li><a href="http://www.foolbirds.com/batch-in-symfony12.html" title="symfony1.2下的命令行程序(batch)">symfony1.2下的命令行程序(batch)</a></li><li><a href="http://www.foolbirds.com/generate-admin-templates-structure.html" title="symfony1.2的后台(generate-admin)模板结构">symfony1.2的后台(generate-admin)模板结构</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.foolbirds.com/symfony%e4%b8%ad%e7%9a%84action%e5%92%8cactions.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>跳并快乐着－symfony跳转指南</title>
		<link>http://www.foolbirds.com/redirect-and-forward-in-symfony.html</link>
		<comments>http://www.foolbirds.com/redirect-and-forward-in-symfony.html#comments</comments>
		<pubDate>Tue, 17 Mar 2009 04:24:39 +0000</pubDate>
		<dc:creator>maker</dc:creator>
				<category><![CDATA[symfony]]></category>
		<category><![CDATA[forward]]></category>
		<category><![CDATA[redirect]]></category>
		<category><![CDATA[跳转]]></category>

		<guid isPermaLink="false">http://www.foolbirds.com/?p=649</guid>
		<description><![CDATA[项目接近尾声，闲来无事写一点东西活跃活跃气氛。在日常的web开发中，跳转是一个很常见的操作，成功了要跳转，错误了要跳转，满足某某条件也要跳转，symfony作为一款成熟的开发框架对跳转的处理也是非常多样的。
一. 关于跳转
虽说多样，但万变不离其宗，一般的跳转分为两种，forward（转发）和redirect（重定向），两种方法虽然目的都是为了进行跳转但是本质上还是有很大差别的。
所谓forward，是一个action将当前的请求交给另外一个action处理，这个过程是在同一个http请求中完成的，整个过程不涉及客户端，url地址也不会发生改变。
示例1
public function executeActionA($request)
{
// 一些处理
// to ActionB: 剩下的就交给你了
$this-&#62;forward('default', 'actionb');
}
public function executeActionB($request)
{
// to ActionA: 交给我你就放心吧
// 又一些处理
}
示例一中，ActionA将处理工作交给的ActionB，其实其效果是和下例一样的。
示例2
public function executeActionC($request)
{
// 一些处理
// 又一些处理
// ps : 我是全能，ActionA和ActionB能做的我自己就能做
}
上面这两个例子就如同我们雇佣一个程序员一个美工或者雇佣一个懂美工的程序员一样，我们将事件处理过程分开总是有各种各样的原因，比如为了逻辑清晰，代码重用等等等等，所以在很多情况下我们就需要使用forward。
说完forward我们再来说redirect，其实我觉得redirect才能够叫做真正的跳转，很多时候我觉得forward就象调用函数。一个真正的redirect涉及了两次http请求，浏览器发送了一个http请求之后，服务端根据业务需要进行跳转，这样服务端会向浏览器返回一个跳转信息，这个跳转信息可能是一个重定向的http header，也可能是一段带有跳转代码的html或者javascript，浏览器接到请求根据跳转信息进行第二次http 请求，这个第二次请求不同于forward的第二个Action，这个请求可以在程序内，也可以在程序外，比如说跳到google, 而用forward就象蹲监狱，再怎么跳也就是换换牢房，想出去是不可能了，除非你是Michael Scofield。
示例3
public function executeActionA($request)
{
// 我要换牢房
$this-&#62;redirect('fox/room');
}
public function executeActionB($request)
{
// 我要换去Sucre的牢房拆马桶
$this-&#62;redirect("fox/room?user='Fernando Sucre'");
}
public function executeActionC($request)
{
// 和哥哥越狱到谷歌去
$this-&#62;redirect('http://g.cn/?with_my_brother=true');
}
这里扯的有点远，其实我觉得在看我文章的朋友其实已经有一定的symfony基础的，所以不需要细细的去讲，只要给大家一些提示就可以。forward和redirect还有很关键的一点区别，就是forward进行转发之后原来的请求参数不会变，这里的请求参数指post, get, cookie什么什么什么的， 而redirect就需要你通过url将你需要的参数再传过去， symfony中貌似有http_build_query()这么一个函数.
示例4
public function executeActionA($request)
{
// 所有和我从Fox River跑出来的朋友一起去巴拿马
$this-&#62;redirect('panama.com?'.http_build_query($request-&#62;getPostParameters()));
}
二. symfony中的跳转
关于forward和redirect就介绍到这里，下面来介绍symfony中的跳转方法。
function forward($module, $action)
最基本的转发动作，参数是模块名和动作名。
示例5，新建立模块的Index方法都是这样的。
public function executeIndex(sfWebRequest $request)
{
// 将默认动作转发到默认模块
$this-&#62;forward('default', 'index');
}

function forward404($message = null)
forward404动作其实和throw [...]]]></description>
			<content:encoded><![CDATA[<p>项目接近尾声，闲来无事写一点东西活跃活跃气氛。在日常的web开发中，跳转是一个很常见的操作，成功了要跳转，错误了要跳转，满足某某条件也要跳转，symfony作为一款成熟的开发框架对跳转的处理也是非常多样的。</p>
<p><strong>一. 关于跳转</strong></p>
<p style="padding-left: 30px;">虽说多样，但万变不离其宗，一般的跳转分为两种，forward（转发）和redirect（重定向），两种方法虽然目的都是为了进行跳转但是本质上还是有很大差别的。</p>
<p style="padding-left: 30px;">所谓forward，是一个action将当前的请求交给另外一个action处理，这个过程是在同一个http请求中完成的，整个过程不涉及客户端，url地址也不会发生改变。</p>
<p style="padding-left: 30px;">示例1</p>
<p style="padding-left: 30px;"><code>public function executeActionA($request)<br />
{<br />
// 一些处理<br />
// to ActionB: 剩下的就交给你了<br />
$this-&gt;forward('default', 'actionb');<br />
}<br />
public function executeActionB($request)<br />
{<br />
// to ActionA: 交给我你就放心吧<br />
// 又一些处理<br />
}</code></p>
<p style="padding-left: 30px;">示例一中，ActionA将处理工作交给的ActionB，其实其效果是和下例一样的。</p>
<p style="padding-left: 30px;">示例2</p>
<p style="padding-left: 30px;"><code>public function executeActionC($request)<br />
{<br />
// 一些处理<br />
// 又一些处理<br />
// ps : 我是全能，ActionA和ActionB能做的我自己就能做<br />
}</code></p>
<p style="padding-left: 30px;">上面这两个例子就如同我们雇佣一个程序员一个美工或者雇佣一个懂美工的程序员一样，我们将事件处理过程分开总是有各种各样的原因，比如为了逻辑清晰，代码重用等等等等，所以在很多情况下我们就需要使用forward。</p>
<p style="padding-left: 30px;">说完forward我们再来说redirect，其实我觉得redirect才能够叫做真正的跳转，很多时候我觉得forward就象调用函数。一个真正的redirect涉及了两次http请求，浏览器发送了一个http请求之后，服务端根据业务需要进行跳转，这样服务端会向浏览器返回一个跳转信息，这个跳转信息可能是一个重定向的http header，也可能是一段带有跳转代码的html或者javascript，浏览器接到请求根据跳转信息进行第二次http 请求，这个第二次请求不同于forward的第二个Action，这个请求可以在程序内，也可以在程序外，比如说跳到google, 而用forward就象蹲监狱，再怎么跳也就是换换牢房，想出去是不可能了，除非你是Michael Scofield。</p>
<p style="padding-left: 30px;">示例3</p>
<p style="padding-left: 30px;"><code>public function executeActionA($request)<br />
{<br />
// 我要换牢房<br />
$this-&gt;redirect('fox/room');<br />
}<br />
public function executeActionB($request)<br />
{<br />
// 我要换去Sucre的牢房拆马桶<br />
$this-&gt;redirect("fox/room?user='Fernando Sucre'");<br />
}<br />
public function executeActionC($request)<br />
{<br />
// 和哥哥越狱到谷歌去<br />
$this-&gt;redirect('http://g.cn/?with_my_brother=true');<br />
}</code></p>
<p style="padding-left: 30px;">这里扯的有点远，其实我觉得在看我文章的朋友其实已经有一定的symfony基础的，所以不需要细细的去讲，只要给大家一些提示就可以。forward和redirect还有很关键的一点区别，就是forward进行转发之后原来的请求参数不会变，这里的请求参数指post, get, cookie什么什么什么的， 而redirect就需要你通过url将你需要的参数再传过去， symfony中貌似有http_build_query()这么一个函数.</p>
<p style="padding-left: 30px;">示例4</p>
<p style="padding-left: 30px;"><code>public function executeActionA($request)<br />
{<br />
// 所有和我从Fox River跑出来的朋友一起去巴拿马<br />
$this-&gt;redirect('panama.com?'.http_build_query($request-&gt;getPostParameters()));<br />
}</code></p>
<p><strong>二. symfony中的跳转</strong></p>
<p style="padding-left: 30px;">关于forward和redirect就介绍到这里，下面来介绍symfony中的跳转方法。</p>
<p style="padding-left: 30px;"><strong>function <span style="color: #ff0000;">forward</span>($module, $action)</strong></p>
<p style="padding-left: 60px;">最基本的转发动作，参数是模块名和动作名。</p>
<p style="padding-left: 60px;">示例5，新建立模块的Index方法都是这样的。</p>
<p style="padding-left: 60px;"><code>public function executeIndex(sfWebRequest $request)<br />
{<br />
// 将默认动作转发到默认模块<br />
$this-&gt;forward('default', 'index');<br />
}</code></p>
<p style="padding-left: 60px;">
<p style="padding-left: 30px;"><strong>function <span style="color: #ff0000;">forward404</span>($message = null)</strong></p>
<p style="padding-left: 60px;">forward404动作其实和throw new sfError404Exception的效果是一样的， 在symfony中可以通过设置404动作来控制404的输出，这样实际上就是一个转发到404错误处理动作的跳转， 返回404异常在程序中是很常见的，比如参数错误，数据错误等等等等等等，我们都可以直接抛出404异常。</p>
<p style="padding-left: 60px;">示例6</p>
<p style="padding-left: 60px;"><code>public function executeActionA($request)<br />
{<br />
$id = (int) $request-&gt;getParameter('id');<br />
if ($id &lt; 1) {<br />
$this-&gt;forward404();<br />
}<br />
$product = ProductPeer::retrieveByPk($id);<br />
if (!is_object($product)) {<br />
$this-&gt;forward404();<br />
}<br />
//我们将对象注册到模板中去，其实和$this-&gt;product=$product是一样的<br />
$this-&gt;setVar('product', $product);<br />
}</code></p>
<p style="padding-left: 30px;"><strong>function <span style="color: #ff0000;">forwardIf</span>($condition, $module, $action)</strong></p>
<p style="padding-left: 60px;">当$condition为&#8221;真&#8221;的时候转发到$module/$action</p>
<p style="padding-left: 60px;">示例7</p>
<p style="padding-left: 60px;"><code>public function executeCreate($request)<br />
{<br />
$product = new Product;<br />
$product-&gt;setName('产品1');<br />
// 创建产品，成功则跳转到列表，创建失败则抛出404<br />
$this-&gt;forwardIf($product, 'product', 'list');<br />
$this-&gt;forward404();<br />
}</code></p>
<p style="padding-left: 30px;"><strong>function <span style="color: #ff0000;">forwardUnless</span>($condition, $module, $action)</strong></p>
<p style="padding-left: 60px;">当$condition为&#8221;假&#8221;的时候转发到$module/$action</p>
<p style="padding-left: 60px;">示例8</p>
<p style="padding-left: 60px;"><code>public function  executeAction($request)<br />
{<br />
$product = ProductPeer::retrieveByPk($this-&gt;getParameter('id'));<br />
$this-&gt;forward($product, 'default', 'error404');<br />
}</code></p>
<p style="padding-left: 30px;"><strong>function <span style="color: #ff0000;">forward404If</span>($condition, $message = null)</strong></p>
<p style="padding-left: 60px;">当$condition为“真“的时候抛出404异常</p>
<p style="padding-left: 60px;">示例9</p>
<p style="padding-left: 60px;"><code>public function executeShow($request)<br />
{<br />
$id = intval($request-&gt;getParameter('id'));<br />
// 如果id小于0抛出异常<br />
$this-&gt;forward404If($id&lt;0, 'parameter error');<br />
$product = ProductPeer::retrieveByPk($id);<br />
// 如果产品不存在抛出异常<br />
$this-&gt;forward404If(!$product, 'product not exists');<br />
$this-&gt;object = $product;<br />
}</code></p>
<p style="padding-left: 30px;"><strong>function <span style="color: #ff0000;">forward404Unless</span>($condition, $message = null)</strong></p>
<p style="padding-left: 60px;">当$condition为“假“的时候抛出404异常, 实际应用中这个方法比forward404If更方便</p>
<p style="padding-left: 60px;">示例10</p>
<p style="padding-left: 60px;"><code>public function executeShow($request)<br />
{<br />
$id = intval($request-&gt;getParameter('id'));<br />
// 如果id小于0抛出异常<br />
$this-&gt;forward404If($id&lt;0, 'parameter error');<br />
$product = ProductPeer::retrieveByPk($id);<br />
// 如果产品不存在抛出异常<br />
$this-&gt;forward404Unless($product, 'product not exists');<br />
$this-&gt;object = $product;<br />
}</code></p>
<p style="padding-left: 30px;"><strong>function <span style="color: #ff0000;">redirect</span>($url, $statusCode = 302)</strong></p>
<p style="padding-left: 60px;">跳转到$url，返回http状态码，$url可以是内部url也可以是外部url.</p>
<p style="padding-left: 60px;">示例11</p>
<p style="padding-left: 60px;"><code>public function executeActionA($request)<br />
{<br />
$this-&gt;redirect('g.cn');<br />
}<br />
public function executeActionB($request)<br />
{<br />
$this-&gt;redirect('default/index?action=b');<br />
}</code></p>
<p style="padding-left: 30px;"><strong>function <span style="color: #ff0000;">redirect404</span>()</strong></p>
<p style="padding-left: 60px;">跳转到404动作，404处理动作可以通过settings.yml进行设置, 这个动作是不用给参数的，symfony会自动调用系统设置。</p>
<p style="padding-left: 30px;"><strong>function <span style="color: #ff0000;">redirectIf</span>($condition, $url, $statusCode = 302)</strong></p>
<p style="padding-left: 60px;">如果$condition为“真”则跳转到$url</p>
<p style="padding-left: 60px;">示例12</p>
<p style="padding-left: 60px;"><code>public function executeCreate($request)<br />
{<br />
$product = new Product;<br />
$product-&gt;setName('产品2');<br />
//创建成功进入编辑页面<br />
$this-&gt;redirectIf($product-&gt;save(), 'product/update?id='.$product-&gt;getId());<br />
//创建失败加载Error模板<br />
return sfView::ERROR;<br />
}</code></p>
<p style="padding-left: 30px;"><strong>function <span style="color: #ff0000;">redirectUnless</span>($condition, $url, $statusCode = 302)</strong></p>
<p style="padding-left: 60px;">如果$condition为“假”则跳转到$url, 参考forwardUnless</p>
<p><strong>三. 结束语</strong></p>
<p style="padding-left: 30px;">本文旨在抛砖引玉，其实关于跳转还有很多的技巧，这个就要在实际应用中慢慢积累了。</p>
<ul class="related_post"><li><a href="http://www.foolbirds.com/use_symfony_filter_to_filteredurl.html" title="使用symfony filter 过滤URL">使用symfony filter 过滤URL</a></li><li><a href="http://www.foolbirds.com/%e4%bb%bfsymfony%e6%9c%ba%e5%88%b6%e5%ae%9e%e7%8e%b0%e4%b8%8d%e7%94%a8require%e6%88%96%e8%80%85include%e6%9d%a5%e5%ae%9e%e4%be%8b%e5%8c%96%e7%b1%bb.html" title="仿symfony机制实现不用require或者include来实例化类">仿symfony机制实现不用require或者include来实例化类</a></li><li><a href="http://www.foolbirds.com/use-datetime-in-php5-1-x-with-symfony.html" title="symfony1.4 DateTime对于PHP低版本的兼容问题">symfony1.4 DateTime对于PHP低版本的兼容问题</a></li><li><a href="http://www.foolbirds.com/%e5%a6%82%e4%bd%95%e5%9c%a8fixtures-yml%e5%86%99%e5%be%aa%e7%8e%af%e6%b7%bb%e5%8a%a0%e6%95%b0%e6%8d%ae.html" title="如何在fixtures.yml写循环添加数据">如何在fixtures.yml写循环添加数据</a></li><li><a href="http://www.foolbirds.com/symfony-1-4-database-utf8.html" title="symfony 1.4 数据库 utf8设置">symfony 1.4 数据库 utf8设置</a></li><li><a href="http://www.foolbirds.com/symfony-cheat-sheet.html" title="symfony cheat sheet">symfony cheat sheet</a></li><li><a href="http://www.foolbirds.com/cheat-sheets.html" title="Cheat Sheets!">Cheat Sheets!</a></li><li><a href="http://www.foolbirds.com/how-to-use-swift-to-send-mail-in-symfon.html" title="如何使用swift发送邮件">如何使用swift发送邮件</a></li><li><a href="http://www.foolbirds.com/batch-in-symfony12.html" title="symfony1.2下的命令行程序(batch)">symfony1.2下的命令行程序(batch)</a></li><li><a href="http://www.foolbirds.com/generate-admin-templates-structure.html" title="symfony1.2的后台(generate-admin)模板结构">symfony1.2的后台(generate-admin)模板结构</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.foolbirds.com/redirect-and-forward-in-symfony.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

