下载yaf源码
wget http://pecl.php.net/get/yaf-3.0.8.tgz
或者从github下载 https://github.com/laruence/yaf(github中有tools目录,可用来生成脚手架)
tar -zxvf yaf*
cd yaf*
$PHP_BIN/phpize  使用phpize生成configure文件
再安装yaf扩展库
./configure --with-php-config==$PHP_BIN/php-config(PHP_BIN是PHP的bin目录)
make && make install

安装扩展库完成

配置php

在php.ini中载入yaf.so, 重启PHP.

运行代码生成工具:

cd tools/cg
./yaf_cg demo
会在yaf_cg文件相同的目录下创建一个output文件夹:

/Users/helloxiaozhu/php-yaf/tools/cg/output
进入之后就会看见你刚才创建的文件夹:demo
然后在这个目录中的output目录中就可以看到新生成的test脚手架代码了,拷贝到你的项目目录继续开发即可。

yaf官方安装文档

Yaf - Yet Another Framework

PHP framework written in c and built as a PHP extension.

Requirement

PHP 5.2 +

Install

Install Yaf

Yaf is a PECL extension, thus you can simply install it by:

$pecl install yaf

Compile Yaf in Linux

wget http://pecl.php.net/get/yaf-3.0.8.tgz
$/path/to/phpize
$./configure --with-php-config=/path/to/php-config
$make && make install

Document

Yaf manual could be found at: http://www.php.net/manual/en/book.yaf.php

IRC

efnet.org #php.yaf

For IDE

You could find a documented prototype script here: https://github.com/elad-yosifon/php-yaf-doc

Tutorial

layout

A classic application directory layout:

  • .htaccess // Rewrite rules
  • public
    | - index.php // Application entry
    | + css
    | + js
    | + img
  • conf
    | - application.ini // Configure
  • application/

    • Bootstrap.php // Bootstrap
    • controllers

      • Index.php // Default controller
    • views
      |+ index
      - index.phtml // View template for default controller
    • library
    • models // Models
    • plugins // Plugins
DocumentRoot

You should set DocumentRoot to application/public, thus only the public folder can be accessed by user

index.php

index.php in the public directory is the only way in of the application, you should rewrite all request to it(you can use .htaccess in Apache+php mod)

<?php
define("APPLICATION_PATH",  dirname(dirname(__FILE__)));$app  = new Yaf_Application(APPLICATION_PATH . "/conf/application.ini");
$app->bootstrap() //call bootstrap methods defined in Bootstrap.php->run();
Rewrite rules
Apache

#.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* index.php

Nginx

server {
listen ****;
server_name domain.com;
root document_root;
index index.php index.html index.htm;

if (!-e $request_filename) {
rewrite ^/(.*) /index.php/$1 last;
}
}

Lighttpd

H T T P [ &quot; h o s t &quot; ] = &quot; ( w w w . ) ? d o m a i n . c o m HTTP[&quot;host&quot;] =~ &quot;(www.)?domain.com HTTP["host"]= "(www.)?domain.com" {
url.rewrite = (
“^/(.+)/?$” => “/index.php/$1”,
)
}

application.ini

application.ini is the application config file

[product]
;CONSTANTS is supported
application.directory = APPLICATION_PATH "/application/"

Alternatively, you can use a PHP array instead:

 <?php$config = array("application" => array("directory" => application_path . "/application/",),);

a p p = n e w y a f a p p l i c a t i o n ( app = new yaf_application( app=newyafa​pplication(config);

default controller

In Yaf, the default controller is named IndexController:

<?php
class IndexController extends Yaf_Controller_Abstract {// default action namepublic function indexAction() {  $this->getView()->content = "Hello World";}
}
?>

###view script The view script for default controller and default action is in the application/views/index/index.phtml, Yaf provides a simple view engine called “Yaf_View_Simple”, which support the view template written in PHP.

<html><head><title>Hello World</title></head><body><?php echo $content; ?></body>
</html>
Run the Applicatioin

http://www.yourhostname.com/

Alternative

You can generate the example above by using Yaf Code Generator: https://github.com/laruence/php-yaf/tree/master/tools/cg

More

More info could be found at Yaf Manual: http://www.php.net/manual/en/book.yaf.php

linux 安装yaf框架相关推荐

  1. CENTOS php 7.0 +nginx 环境下 安装yaf框架

    1 2 3 4  #php -v PHP 7.0.19 (cli) (built: May 12 2017 21:01:27) ( NTS ) Copyright (c) 1997-2017 The  ...

  2. linux 卸载yaf,LINUX操作系统怎么搭建YAF框架

    如何在已经搭建好的php环境下,继续搭建yaf框架环境?那么小编就在本文给大家介绍下搭建方法 LINUX操作系统怎么搭建YAF框架 命令: wget 地址参考图片 命令: tar zxvf yaf-2 ...

  3. Mac系统下PHP7.2和Yaf框架安装

    Mac系统下PHP7.2和Yaf框架安装 目标 执行步骤 brew 安装PHP7.2 完善PHP7.2配置 安装yaf扩展 Todo:yymb项目搭建 参考说明资料 命令 & 配置文件路径 Y ...

  4. Yaf框架视频教程之入门篇【已完成】

    2019独角兽企业重金招聘Python工程师标准>>> 本系列主要介绍PHP的Yaf框架,包含从安装到配置,如何快速的生成代码骨架,也讲解了框架的运行流程,应用在使用前该如何配置,重 ...

  5. linux安装eclipse运行web,Linux安装Tomcat,运行Eclipse,web项目

    到官网下载:https://tomcat.apache.org/download-80.cgi  在这里是8.5.39版本 下载tar,gz 提取解压后,我这里是放到opt目录下 cd  切换目录 / ...

  6. 适合初学者对Yaf框架的学习(一)

    前言 最近接触到Yaf框架,从最初按照鸟哥惠新宸的写的关于Yaf手册,到自己写一个hello world 程序,对于我这个新手来说还是蛮曲折的,大家都知道yaf框架是用C写的,所以自身的效率和性能,还 ...

  7. Linux安装程序Anaconda分析

    1.概述     Anaconda是RedHat.CentOS.Fedora等Linux的安装管理程序.它能够提供文本.图形等安装管理方式,并支持Kickstart等脚本提供自己主动安装的功能.此外, ...

  8. Kali Linux安装字典StarDict

     Kali Linux安装字典StarDict StartDict是国外知名的字典框架,也可以加入国内翻译工具的字典.Kali Linux软件源提供该字典框架.用户需要安装qstardict软件包和词 ...

  9. Arch Linux 安装记(安装到移动硬盘)

    一转眼传说中装起来难于上青天,用起来险如上刀梯(容易滚挂),绰号"洗发水"并被戏称为"邪教"的 Arch Linux 已经用了几个月.某些关于其安装难度和稳定性 ...

最新文章

  1. 安装证书服务:为Web站点启用HTTPS
  2. log4j配置文件详解
  3. 图数据库应用:金融反欺诈实践
  4. 003 PECompact 2.55
  5. 什么样的 RPC 才是好用的 RPC
  6. java for循环 嵌套for循环-标签使用
  7. Codeforce 189B——Counting Rhombi
  8. python getopterror_python3 getopt用法
  9. 用自己的ID在appstore中更新app-黑苹果之路
  10. php用到的mysql语句_PHP中常用到的一些MySQL语句_php
  11. MATLAB定时器的简单使用
  12. 大数据之-Hadoop之HDFS_HDFS的优缺点---大数据之hadoop工作笔记0049
  13. python期望输出隐藏_【归纳综述】马尔可夫、隐马尔可夫 HMM 、条件随机场 CRF 全解析及其python实现...
  14. Tomcat安装后没有出现tomcat主页
  15. Centos 7 一键安装openstack
  16. java 日历_java的日历类(Calendar)详解
  17. Java HotSpot(TM)64位服务器虚拟机警告
  18. win10传真服务器位置,win10系统电脑发传真的操作方法
  19. 群晖7.X版安装cpolar内网穿透套件
  20. 电池的使用误区、电池损耗修复方法以及笔记本电脑使用注意事项

热门文章

  1. Kmeans算法基于三维点云数据
  2. 随机生成10个整数,冒泡排序算法
  3. python输入10个数输出最大值流程图_用传统流程图表示该算法:依次将10个数输入,要求将其中最大的数输出...
  4. 8g内存和16g内存区别 mac_「苹果8g和16g的区别」电脑内存4G/8G/16G有什么区别? - seo实验室...
  5. 用GPUImage来给视频加入水印
  6. 机器学习随笔(拾人牙慧)
  7. 身为职场女性,我想和你聊聊天
  8. 人一旦选择活下去,就必须为了生活起早贪黑,四处奔波
  9. 手机开门——门禁系统进入“互联网+”时代
  10. JS的对象与内置对象详细介绍