全称 API Services Framework, 用C语言编写的轻量级PHP扩展框架, 专注于 API 开发。
二、解决了什么问题?把复杂的逻辑简单化(降低错误率, 减少代码量)
提升项目开发效率(您是否经历过,老板上午提需求,下午就得对外发布)
规范不合理的开发方式
解决输入输出的安全性问题
解决框架带来的性能消耗
三、有哪些优点呢?与原生PHP做比较,只有少量的性能消耗
框架对常用类进行了实用的封装, 类随PHP进程启动就常驻内存
支持本地类库自动加载规则
支持多种配置html' target='_blank'>文件格式(INI, PHP, PHP Array)
支持多种路由协议, 默认使用RESTful路由模式, 提供方便的路由配置器
提供实用的机制: GPC, Loader, Constants, Config, SG, 999, Utili
提供日志记录功能, 包括PHP错误日志, SQL CURD日志
提供DB辅助函数(MySQL, Sqlite, Pgsql), 人性化Query Builder
支持Log buffer cache, Log resources are automatically cleared
遵循PHP PSR Standards, PHP Coding Standards
框架结构简单, PHP标准的扩展安装方式, 框架上手快。框架执行速度快, 更少的内存、CPU使用
四、流程图![1530953916883397.png 2395502858-5af53899e776c_articlex[1].png](http://img.VeVb.com//upload/image/434/543/354/1530953916883397.png)
![1530953924884870.png 3334184775-5af538e3c0088_articlex[1].png](http://img.VeVb.com//upload/image/840/335/263/1530953924884870.png)
5.1 总结
5.1.1 压测结论
没有挑取漂亮的数据, 或者配置一个为了压测的最优环境. 只是简单地采用以大部分web机器使用的环境进行测评。
这里只是给出了一种测试方法, 通过多次不同并发数测试结果得知, Asf 与原生 PHP 性能消耗是 6% ~ 15%。
5.1.2 业务开发速度结论
采用Asf框架开发业务, 代码量能节约 20% ~ 25%。
假如项目开发需要4天 x 8小时, 能节约出整整1天 x 8小时的工作时间。
6.1 环境要求
PHP 7.0 +GCC 4.4.0+ (Recommended GCC 4.8+)
6.2 下载
git clone https://github.com/yulonghu/asf.git
6.3 在Linux/Unix/Mac下编译
$ /path/to/phpize$ ./configure --with-php-config=/path/to/php-config$ make make install
6.4 文档
http://www.box3.cn/phpasf/index.html七、开始使用
7.1 使用内置工具生成空项目
/php-bin-path/php /tools/asf_project.php /to-path/project_name
7.1.1 目录结构
+ public | - index.php+ config | - config.php+ library+ modules | - Bootstrap.php | - Constants.php + api |+ services |- Index.php // Default service |+ logics |+ daos
7.1.2 config/config.php
?php$configs = array( asf = array( root_path = realpath(dirname(__FILE__)),return $configs;
7.1.3 public/index.php
?phpdefine( APP_PATH , dirname(__DIR__));$app = new Asf_Application(APP_PATH . /config/config.php $app- run();
7.1.4 Default service
?phpclass IndexService public function indexAction() return Hello World }八、在Nginx/Apache/Lighttpd中运行
http://www.your-domain.com
8.1 输出结果
{ errno : 0, data : Hello World }九、LicenseAsf is open source software under the PHP License v3.01
以上就是本文的全部内容,希望对大家的学习有所帮助,更多相关内容请关注PHP !
相关推荐:
Asf PHP 开发之配置信息常驻系统内存
以上就是PHP扩展框架 Asf 的介绍的详细内容,PHP教程
郑重声明:本文版权归原作者所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,多谢。
新闻热点
疑难解答