linux下安装PEAR、Zend Debugger和Smarty

  pear的安装其实挺简单的,他的官网也有非常详细的讲解。简化如下:

  1、安装,在终端敲入

$ sudo wget
$ sudo php go-pear.phar

  2、检查pear是否工作,在终端敲入"pear",如果正常的话应该显示下面的东西:

$pear
Commands:
build Build an Extension From C Source
bundle Unpacks a Pecl Package
channel-add Add a Channel
channel-alias Specify an alias to a channel name
channel-delete Remove a Channel From the List
channel-discover Initialize a Channel from its server

  3、检查路径。在服务器根目录,即/var/www/ ,新建一个php文件,写入下面的内容:

<?php
require_once 'System.php';
var_dump(class_exists('System', false));
?>

  如果路径是正确的,那么由浏览器打开此文件应该会显示

bool(true)

  如果出现了warning,便是路径不对了,那么就要到php.ini文件里修改 include_path。在终端敲入如下内容可以查找php.ini文件的位置

$ php --ini

  在终端敲入如下内容可以查找pear的位置

$ php -c /path/to/php.ini -r 'echo get_include_path()."\n";'

  修改完记得重启apache:

sudo /etc/init.d/apache2 restart

二、Smarty

  1、在 下载Smarty,然后找个方便的地方解压。

  2、在服务器根目录新建一个Smarty的文件夹,将刚才解压的软件包下的lib目录里的文件复制过来。

  3、在根目录下创建应用程序目录。在根目录下创建目录myapp(这个可以随便取的),在myapp下创建smarty目录。再在smarty目录下创建4个文件夹:templates,templates_c,cache和config。(虽然不知道为什么要这么建,但看起来似乎是必需的)。

  4、创建myapp/smarty.php文件,告诉PHP程序要包含的Smarty类文件和应用程序的位置

<?php
$base_path=basename(dirname(__FILE__));
require('/var/www/Smarty/Smarty.class.php');//这里是你复制lib目录下文件到的地方
$smarty=new Smarty();
$smarty->template_dir=$base_path.'/smarty/templates';
$smarty->compile_dir=$base_path.'/smarty/templates_c';
$smarty->cache_dir=$base_path.'/smarty/cache';
$smarty->config_dir=$base_path.'/smarty/configs';
?>

  此后,require_once这个文件就可以用Smarty了。

三、smartypdt。

  smartypdt是一个让eclipse更好的地支持smarty的插件,包括语法高亮,代码补全等。但smartypdt要求eclipse用zend debugger,但我之前装的是Xdebug,只好卸了重装。

[Zend Debugger]

  1、卸载xdebug

$ sudo apt-get remove php5-xdebug  2、下载Zend Debugger:,解压后找到你的php版本对应的文件夹下的ZendDebugger.so。我的是PHP 5.3.5,所以找的是5_3_x_comp文件夹下的ZendDebugger.so,然后复制到/usr/lib/php5/20090626+lfs/目录下。

  3、配置PHP.ini文件,加上

[Zend Debug]
zend_extension=http://down.chinaz.com/usr/lib/php5/20090626+lfs/ZendDebugger.so
  4、将软件包里的dummy.php文件复制到服务器根目录下。

  5、重启服务器

  6、然后就是搞eclipse的事了。

  window->preferences->PHP->Debug->PHP Debuger 选择  Zend Debugger

  window->preferences->PHP->Editor->php Executables->Add,配置如下:

Name:PHP 5.3.5 (CLI)(可以自己取一个)
Executable path: /usr/bin/php
SAPI Type: CLI
PHP Debugger: Zend Debugger

  到这里,Zend dedebugger 就算是安装完成了。

[smartypdt]

  1、在这里下载

  2、在eclipse下 Help-> Install New Software->Add..->Archive ,选择你下载的smartypdt文件(不用解压),名字随便给一个就行。OK后如果"Group items by category"被选中了,取消他,然后就可以看到一个叫"Smarty Feature"的软件可以安装,后面的就按提示Next或Finish就可以了。

  3、Window->Preferences->General->Content Type,检查HTML 和 PHP Content Type是关联了*.tpl,如果是的话,取消他。

  5、打开PHP Explore板块,选中PHP project,右键->Configure->Add Smarty Support

  到这里,就可以使用smartypdt了。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/10923.html