Yaf的安装与Hello,world测试

    xiaoxiao2025-01-30  15

    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.phpcssjsimgconf application.ini applicaion controllers Index.php librarymodelsmodulespluginsviews 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>

    测试结果:

    转载请注明原文地址: https://ju.6miu.com/read-1295911.html
    最新回复(0)