pear php linux,linux下安装PEAR、Zend Debugger和Smarty

一、PEAR

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

1、安装,在终端敲入$ sudo wget http://pear.php.net/go-pear.phar

$ 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

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:http://downloads.zend.com/pdt/server-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=/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]

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了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值