PHP

Becareful the heredoc!

today , i was spent half hour to find a bug, it said , Parse error: syntax error, unexpected ‘]’, expecting T_STRING or T_VARIABLE or T_NUM_STRING in xx line, i check that lline all words , on by one , cannot find the problem where it is , even i remove them , still has some error , check all file line by line , i found it ! because i run a function of emacs to indent line, so EOQ not in the very begin of line ! stupid me !

Simple is hard

这两天看了看Rasmus(PHP作者)的一个讲座,关于Scalability、Performance 、 Security ,比较了一些PHP Framework的性能,对于Python, RoR 等语言也有一些评论,还有一些Profiling 和 Benchmarking 工具,自己需要在这一方面加强了,以前都根本没有概念,简单的一个时区的设置在php.ini里都会有影响,include_path的设置等。 Tools for PHP debug and profiling 1. apd ( Zend extension) sudo pear install pear/apd 2. xdebug 3. apc sudo pear install apc extension=apc.so (added it to php.ini) 4. xdebugtoolkit A toolkit for analyzing and visualizing xdebug cachegrind files http://code.google.com/p/xdebugtoolkit/ 5.cg2dot – converter from Xdebug cachegrind files to the dot format. http://code.google.com/p/xdebugtoolkit/wiki/cg2dot http://www.xdebug.org/docs/profiler http://www.graphviz.org/

  1. cgsplit – splitter for appended cachegrind files. http://code.google.com/p/xdebugtoolkit/wiki/cgsplit

相关连接:

 

Back on the joomlaconsole development

After a short kind of vacation, i back and working on the Joomla console development, hope I can release it before the new year (2010.1.1) .hurry up !!!

Fixed the Joomla Plugin Error

I have created a Joomla website with Joomfish & Nook-framwork extensions, then I got a error on frontent :

Fatal error:  Class 'interceptDB' not found 
in **/plugins/system/jfdatabase/jfdatabase_inherit.php 
on line 58

why ?? because the nooku change the the getDBO of JFactory, in the jfdatae_inherit.php try to include the db file based getDbo method, so , just that based on the configuration file. solved !

How to override a core controller in the magento

How to Override a core controoler in magento ?? Magento controller class override is something different then others classes. Controller override is not same as model, helper, block override. I found lot of thread on magento forum , but not working for me (1.3.2.x),  few hours debug, I got it .so how ? a example  is override the ProductControoler ( I already create a module call Webcaker_Catalog),steps for override Step1 : add xml config to confg.xml





standard

Webcaker_Catalog
catalog






...

  
  #^/catalog/product/#
    /catalog/product/
  



Note: for from node, need use CDATA to warp it . Step2 : add new file ProductControler.php in the controllers in Webcaker/Catalog with code below

//important! Magento cannot load the ProductController automatically
require_once 'require_once 'Mage/Catalog/controllers/ProductController.php';
class Webcaker_Catalog_ProductController extends Mage_Catalog_ProductController
{
public function viewAction()
{
//your logic here
}
}

done , magento rock!

在NetBeans给magento添加提示方法功能

在 magento中,如果你用getModel得到一个对象时,默认没有方法提示的,可以通过添加一个注释来实现

 $quote = Mage::getModel('sales/quote')
         ->setStoreId(Mage::app()->getStore()->getId());
/* @var $quote Mage_Sales_Model_Quote */

通过var的定义,就可以有自动的方法提示了。

How to call your hlper class in magento

在magento中,如果你在local下面有自己的模块,并且有自己的空间(象是公司名等),如果你想引用一个 helper的时候,默认magento不能找到你的类,需要在config.xml里定义你的helper类

set cakephp to use utf8

  • for the app ,need set the
    $html->charset('utf-8') 
    in your layouts file
  • for database, set the encoding in the database.php in the configure folder

Class ‘Spyc’ not found when use the Migrations in cakephp

下载 了这个migrations,执行时候的时候发现提示没有找到Spyc,这里是大写的S,修改migrate.php里的vendor(‘Spyc’) 改成小写的s,修复!

Undefined class ‘String’ when use the console of cakephp

today ,I try to learn the console of cakephp , when i ran ‘cake schema generate ‘command, i got a undefined the String class ,and i try to get answer to #cakephp on IRC.solution: adding this line :

uses('String');

at the top of all classes in cakelibsmodeldatasourcesdbo_source.php ,works fine!!