下载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. java怎么创建子程序_JVM执行子程序
  2. win10运行在哪里_升级!Win10 2004版即将推送,减少CPU占用率,旧电脑也运行如飞...
  3. Word2Vec ——gensim实战教程
  4. 面试必考-从URL输入到页面展现到底发生了什么
  5. 9大训练营免费开营!阿里云大数据团队的独门绝学全在这了
  6. 实时音视频技术的演进与应用
  7. Unity 中渲染顺序的理解以及一些坑点 以及2.5D游戏中的渲染排序解决方案
  8. 风格迁移--U-GAT-IT模型(ICLR 2020)
  9. Java二维数组谷电,java二维数组遍历的2种代码
  10. 第一次作业:读优秀博文有感
  11. 使用displsy:flex + overflow:hidden时子元素被压缩
  12. 2021-03-14Java大数据Week2
  13. 如何挑选大数据分析平台
  14. 写在2013年最后一天
  15. java字典序列化_在Python中解析序列化Java对象
  16. 黑客入侵WinXP常用七个技巧
  17. 《信号与系统》(吴京)部分课后习题答案与解析——第四章(PART2)
  18. 手机屏幕为什么比电脑屏幕清晰?
  19. educoder 2-2Python 计算思维训练——循环与列表(二)
  20. 在使用vue脚手架之前你必须掌握的:vue的模版以及路由用法

热门文章

  1. JS中将 JSON 数据转换为 Excel 表格的详细步骤如下:
  2. 【阅读摘要】关于散热器的一些知识点
  3. 【热门主题:英雄联盟壁纸大全】
  4. 数据库oracle认证方式,oracle数据库启动流程及登录认证方式详解
  5. Unity_AVPro_使用AVPro插件时视频红屏
  6. 【UE4】界面打开关闭异常闪退
  7. 永久免费H5直播点播播放器SkeyeWebPlayer.js实现webrtc流播放
  8. IDEA 这样配置注释模板
  9. RHCE8学习指南第一章 安装RHEL8.4
  10. C 图形库 - 2017/11/21