Introduction to the PHP extension framework ASF

Source: Internet
Author: User
Tags coding standards php coding standards php error
This article mainly introduced about the PHP extension Framework ASF Introduction, has a certain reference value, now share to everyone, the need for friends can refer to

First, what is ASF?

The full name API Services framework, a lightweight PHP extension framework written in C, focuses on API development.

Second, what problems have been solved?

    • Simplifying complex logic (reducing the error rate and reducing the amount of code)

    • Improve project development efficiency (whether you have experienced, boss demand in the morning, will have to publish in the afternoon)

    • Norm Unreasonable Development way

    • Addressing security issues with input and output

    • Address the performance cost of the framework

Third, what are the advantages?

    • Compared to native PHP, only a small amount of performance is consumed

    • The framework provides a practical encapsulation of common classes, with the class starting with the PHP process and resident memory

    • Support for local class library auto-load rules

    • Supports multiple configuration file formats (INI, PHP, PHP Array)

    • Supports multiple routing protocols, using restful routing mode by default, providing a convenient routing configurator

    • Provides a practical mechanism: GPC, Loader, Constants, Config, SG, 999, Utili

    • Provides logging capabilities, including PHP error logs, SQL curd logs

    • provides DB auxiliary functions (MySQL, Sqlite, pgsql), humanized query Builder

    • Support for log buffer cache, log resources is automatically cleared

    • Follow PHP PSR standards, PHP Coding standards

    • Simple frame structure, PHP standard extension installation, the framework to get started quickly. Faster frame execution, less memory, CPU usage

Iv. flowchart

Five, performance

5.1 Summary

Conclusion of 5.1.1 Pressure measurement

Do not pick up beautiful data, or configure an optimal environment for pressure measurement. Simply use the environment that is used by most web machines for evaluation.
Here just gives a test method, through multiple different concurrent number test results, Asf and native PHP performance consumption is 6% ~ 15%.

5.1.2 Business Development Speed Conclusion

Using the ASF framework to develop the business, the code can save 20% ~ 25%.
If the project development takes 4 days x 8 hours, can save a full 1 days x 8 hours of working time.

VI. Installation

6.1 Environmental Requirements

PHP 7.0 +GCC 4.4.0+ (Recommended GCC 4.8+)

6.2 Downloads

git clone https://github.com/yulonghu/asf.git

6.3 Compiling under Linux/unix/mac

$/path/to/phpize$./configure--with-php-config=/path/to/php-config$ make && make install

6.4 Documentation

Http://www.box3.cn/phpasf/index.html

Vii. beginning of Use

7.1 Creating an empty project with built-in tools

/php-bin-path/php/tools/asf_project.php/to-path/project_name

7.1.1 directory Structure

+ 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 ';    }}

Eight, running in the NGINX/APACHE/LIGHTTPD

Http://www.your-domain.com

8.1 Output Results

{    "errno": 0,    "data": "Hello World"}

Nine, License

ASF is open source software under the PHP License v3.01

The above is the whole content of this article, I hope that everyone's learning has helped, more relevant content please pay attention to topic.alibabacloud.com!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.