这篇文章主要介绍了关于php扩展框架 asf 的介绍,有着一定的参考价值,现在分享给大家,有需要的朋友可以参考一下
全称 API Services Framework, 用C语言编写的轻量级PHP扩展框架, 专注于 API 开发。
把复杂的逻辑简单化(降低错误率, 减少代码量)
提升项目开发效率(您是否经历过,老板上午提需求,下午就得对外发布)
规范不合理的开发方式
立即学习“PHP免费学习笔记(深入)”;
解决输入输出的安全性问题
解决框架带来的性能消耗
与原生PHP做比较,只有少量的性能消耗
框架对常用类进行了实用的封装, 类随PHP进程启动就常驻内存
支持本地类库自动加载规则
支持多种配置文件格式(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](https://img.php.cn//upload/image/434/543/354/1530953916883397.png)
![1530953924884870.png 3334184775-5af538e3c0088_articlex[1].png](https://img.php.cn//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
|+ daos7.1.2 config/config.php
<?php
$configs = array(
'asf' => array(
'root_path' => realpath(dirname(__FILE__)),
)
);
return $configs;7.1.3 public/index.php
<?php
define('APP_PATH', dirname(__DIR__));
$app = new Asf_Application(APP_PATH . '/config/config.php');
$app->run();7.1.4 Default service
<?php
class IndexService
{
public function indexAction()
{
return 'Hello World';
}
}http://www.your-domain.com
8.1 输出结果
{
"errno": 0,
"data": "Hello World"
}Asf is open source software under the PHP License v3.01
以上就是本文的全部内容,希望对大家的学习有所帮助,更多相关内容请关注PHP中文网!
相关推荐:
以上就是PHP扩展框架 Asf 的介绍的详细内容,更多请关注php中文网其它相关文章!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号