Yaf的安装与Hello,world测试

1. 安装

Yaf是国内牛人惠新宸写的PHP扩展,是Yet Another Frameword的简称,php官网的文档维护的不好,可参考开发者自己网站上的手册:http://www.laruence.com/manual/

有三种安装方式:源码、PECL和安装操作系统提供的包。

我用阿里云的服务器,ubuntu12.04,使用apt-get intall安装报错:

The following packages have unmet dependencies:
php5-yaf : Depends: phpapi-20090626

因此从https://pecl.php.net/package/yaf上下载源码,再安装:
其中XXX为源码解压后的目录

cd XXX
sudo phpize
sudo ./configure
sudo make
sudo make install

PS:查看命令行输出,注意解决报错信息。

自己本地的机器是ubuntu14.04,可以直接暗中系统提供的包:

sudo add-apt-repository ppa:mikespook/php5-yaf
sudo apt-get update
sudo apt-get install php5-yaf

至于PECL的安装方法,参考

pecl install yaf

安装成功后别忘记重启APACHE,使新安装的PHP插件生效:

sudo /etc/init.d/apache2 restart

sudo service apache2 restart

2. 测试

安装成功后可以测试一下,参照http://www.laruence.com/manual/,建立目录结构如下:

  • public
    • index.php
    • css
    • js
    • img
  • conf
    • application.ini
  • applicaion
    • controllers
      • Index.php
    • library
    • models
    • modules
    • plugins
    • views
      • index
        • index.phtml

其中:
index.php

<?php
define("APP_PATH",realpath(dirname(__FILE__).'/../'));
$app = new Yaf_Application(APP_PATH.'/conf/application.ini');
$app->run();
?>

application.ini

[product]
application.directory=APP_PATH"/application/"

Index.php

<?php
class IndexController extends Yaf_Controller_Abstract{
        public function indexAction(){
                $this->getView()->assign("content","Hello, world!");
        }
}
?>

index.phtml

<html>
        <head>
                <title>Test Page</title>
        </head>
        <body>
                <?php echo $content?>
        </body>
</html>

测试结果:

结果

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值