Get Started

首先确认 PHP7 扩展 Asf 已经安装完成


目录结构

+ public
  | - index.php //入口文件
+ config
  | - config.ini //配置文件
+ library      //本地类库
+ application
    | - Bootstrap.php
    | - Constants.php
  + api // 模块名称
    |+ services  
	   |- Index.php //默认控制器
    |+ logics       //logic目录
    |+ daos         //DB操作目录

配置文件 (采用 PHP变量配置)

支持三种配置文件模式 ini文件 、 php文件 、 PHP变量array

<?php
$configs = array(
    'asf' => array(
        'root_path' => realpath(dirname(__FILE__)),
    )
);

入口文件 (index.php, asf.use_namespace = Off)

<?php
$configs = array(
    'asf' => array(
        'root_path' => realpath(dirname(__FILE__)),
    )
);

$handle = new Asf_Application($configs);
$handle->run();

入口文件, 开启命名空间 (index.php, asf.use_namespace = On)

<?php
use Asf\Application;

$configs = array(
    'asf' => array(
        'root_path' => realpath(dirname(__FILE__)),
    )
);

$handle = new Application($configs);
$handle->run();

通过浏览器访问

http://www.domain.cn/index.php

浏览器显示结果

// asf.ctype_id = 5 (default)
{
    "errno": 0,
    "data": ""
}

// asf.ctype_id = 1
{
    "errno": 0,
    "errmsg": "",
    "data": ""
}

使用内置工具生成空目录结构

Asf 框架提供了一个小工具, 能快速生成一个空项目目录

asf_project 没有任何配置要求, 执行程序在当前目录下生成指定名称的空项目结构

asf_project 如果未填写项目名称, 默认 example

[asf@test:/] ./asf_project 项目名称