Giter Site home page Giter Site logo

landv / phalapi Goto Github PK

View Code? Open in Web Editor NEW

This project forked from phalapi/phalapi

0.0 1.0 0.0 10.35 MB

接口,从简单开始!PhalApi简称π框架,一个轻量级PHP开源接口框架,专注于接口服务开发,支持HTTP/SOAP/RPC协议,拥有自动生成的在线文档、多种开发语言的客户端SDK包以及可重用的扩展类库,可用于快速搭建微服务、RESTful接口或Web Services。助你创造价值!

Home Page: http://www.phalapi.net

License: GNU General Public License v2.0

PHP 2.39% Shell 0.01% C# 0.23% Java 0.22% HTML 0.11% JavaScript 39.57% Ruby 0.25% Go 0.09% Python 0.08% Objective-C 12.94% TSQL 0.02% CSS 44.12%

phalapi's Introduction

apic

Latest Stable Version Total Downloads Latest Unstable Version License

PhalApi Pro 专业版 - 智慧编程,让接口开发更有趣!

1、开发文档

专为PHPer准备的优雅而详细的开发文档,请看:PhalApi 2.x 开发文档

2、在线示例

3、快速安装

composer一键安装

使用composer创建项目的命令,可实现一键安装。

$ composer create-project phalapi/phalapi

温馨提示:关于composer的使用,请参考Composer 中文网 / Packagist **全量镜像

手动下载安装

或者,也可以进行手动安装。将此Git项目代码下载解压后,进行可选的composer更新,即:

$ composer update

4、使用

调用接口

在PhalApi,你可以通过service参数(短名字是s参数)指定需要调用的接口服务。例如,访问默认接口服务。

温馨提示:推荐将访问根路径指向/path/to/phalapi/public。

对应执行的PHP代码在./src/app/Api/Site.php文件,源码片段如下:

<?php
namespace App\Api;
use PhalApi\Api;

/**
 * 默认接口服务类
 * @author: dogstar <[email protected]> 2014-10-04
 */
class Site extends Api {
    public function getRules() {
        return array(
            'index' => array(
                'username'  => array('name' => 'username', 'default' => 'PhalApi', 'desc' => '用户名'),
            ),
        );
    }

    /**
     * 默认接口服务
     * @desc 默认接口服务,当未指定接口服务时执行此接口服务
     * @return string title 标题
     * @return string content 内容
     * @return string version 版本,格式:X.X.X
     * @return int time 当前时间戳
     * @exception 400 非法请求,参数传递错误
     */
    public function index() {
        return array(
            'title' => 'Hello ' . $this->username,
            'version' => PHALAPI_VERSION,
            'time' => $_SERVER['REQUEST_TIME'],
        );
    }
}

接口请求后结果输出类似如下:

{
    "ret": 200,
    "data": {
        "title": "Hello PhalApi",
        "version": "2.4.2",
        "time": 1501079142
    },
    "msg": ""
}

运行效果,截图如下:

_20190201151943

查看在线接口文档

PhalApi会根据你编写的接口的参数配置和代码注释,自动实时生成在线接口文档。在线接口文档链接为:

浏览效果类似如下:

_20190201113515

5、一张图告诉你如何使用PhalApi 2.x

phalapi-install

6、子项目

7、还有问题,怎么办?

如发现问题,或者任何问题,欢迎提交Issue到这里,或进入PhalApi开源社区
如果喜欢,请帮忙在Github码云给个Star,也可以对PhalApi进行捐赠哦 ^_^。

phalapi's People

Contributors

dogstartest avatar phalapi avatar wenzhenxi avatar gaoyiping avatar aevit avatar ederth avatar axiosleo avatar zhao-github avatar mythg avatar xubing6243 avatar harry-1012 avatar ishwy avatar 254059780 avatar johnzhao1208 avatar linjie-guo avatar wuxyyin avatar fishersyu avatar djcn avatar prettyyjnic avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.