All Projects → phalapi → Phalapi

phalapi / Phalapi

Licence: apache-2.0
A PHP framework foucs on API fast development.接口,从简单开始!PhalApi简称π框架,一个轻量级PHP开源接口框架,专注于接口服务开发。

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Phalapi

Typescript Rest
This is a lightweight annotation-based expressjs extension for typescript.
Stars: ✭ 458 (-66.45%)
Mutual labels:  api, microservice, restful
Api Strategy
Equinor API Strategy
Stars: ✭ 56 (-95.9%)
Mutual labels:  api, restful
Flask Restx
Fork of Flask-RESTPlus: Fully featured framework for fast, easy and documented API development with Flask
Stars: ✭ 1,050 (-23.08%)
Mutual labels:  api, restful
Silverstripe Restfulapi
SilverStripe RESTful API with a default JSON serializer.
Stars: ✭ 63 (-95.38%)
Mutual labels:  api, restful
Python Api Development Fundamentals
Develop a full-stack web application with Python and Flask
Stars: ✭ 44 (-96.78%)
Mutual labels:  api, restful
Go Restful Api
An idiomatic Go REST API starter kit (boilerplate) following SOLID principles and Clean Architecture
Stars: ✭ 1,043 (-23.59%)
Mutual labels:  api, microservice
Up
Up focuses on deploying "vanilla" HTTP servers so there's nothing new to learn, just develop with your favorite existing frameworks such as Express, Koa, Django, Golang net/http or others.
Stars: ✭ 8,439 (+518.24%)
Mutual labels:  api, microservice
Fusio
Open source API management platform
Stars: ✭ 946 (-30.7%)
Mutual labels:  api, microservice
Graphql Microservices
Showcasing a graphql microservice setup
Stars: ✭ 68 (-95.02%)
Mutual labels:  api, microservice
Spring Boot Api Project Seed
🌱🚀一个基于Spring Boot & MyBatis的种子项目,用于快速构建中小型API、RESTful API项目~
Stars: ✭ 8,979 (+557.8%)
Mutual labels:  api, restful
Health Checks Api
Standardize the way services and applications expose their status in a distributed application
Stars: ✭ 78 (-94.29%)
Mutual labels:  api, microservice
Es6 Express Mongoose Passport Rest Api
Lightweight boilerplate for Node RESTful API, ES6, Express, Mongoose and Passport 🎁
Stars: ✭ 36 (-97.36%)
Mutual labels:  api, restful
Altair
Lightweight and Robust API Gateway written in Go
Stars: ✭ 34 (-97.51%)
Mutual labels:  api, microservice
Generator Http Fake Backend
Yeoman generator for building a fake backend by providing the content of JSON files or JavaScript objects through configurable routes.
Stars: ✭ 49 (-96.41%)
Mutual labels:  api, restful
Server
Serve your Rubix ML models in production with scalable stand-alone model inference servers.
Stars: ✭ 30 (-97.8%)
Mutual labels:  api, microservice
Httplive
HTTP Request & Response Service, Mock HTTP
Stars: ✭ 1,094 (-19.85%)
Mutual labels:  api, restful
Soundcloud
Soundcloud.com API wrapper written in PHP with OAuth2 support.
Stars: ✭ 94 (-93.11%)
Mutual labels:  api, restful
Go Zero
go-zero is a web and rpc framework written in Go. It's born to ensure the stability of the busy sites with resilient design. Builtin goctl greatly improves the development productivity.
Stars: ✭ 13,156 (+863.81%)
Mutual labels:  microservice, restful
Got Auth Service
A professional role-based-authorization(also supports resource and group) service with restful and graphql api for enterprise applications.
Stars: ✭ 12 (-99.12%)
Mutual labels:  microservice, restful
Flowa
🔥Service level control flow for Node.js
Stars: ✭ 66 (-95.16%)
Mutual labels:  api, restful

apic

PhalApi开源接口框架 / PhalApi API Framework

读音:派框架

Latest Stable Version Total Downloads Latest Unstable Version License

Stargazers over time

Stargazers over time

开发文档 / Documents

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

在线示例 / Demo

快速安装 / Install

composer一键安装 / Install by composer

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

One-click installation can be achieved by using the command of composer to create a project.

$ composer create-project phalapi/phalapi

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

手动下载安装 / Download and Install manually

或者,也可以进行手动安装。将此Git项目代码下载解压后,进行可选的composer更新,即:
Alternatively, manual installation is also possible. Download PhalApi Project master-2x branch Source code. After downloading and unzipping, perform an optional composer update:

$ composer update

部署 / Deployment

Nginx配置 / Nginx Configuration

如果使用的是Nginx,可参考以下配置。
If you are using Nginx, you can refer to the following configuration.

server {
    listen 80;
    server_name dev.phalapi.net;
    # 将根目录设置到public目录
    root /path/to/phalapi/public;
    charset utf-8;

    location / {
        index index.php;
    }

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        # 根据当前环境,选择合适的通讯方式
        # fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

配置时需要将网站根目录设置到public目录,配置保存后重启nginx。
Point the root path of the visit to public folder. Save and reload nginx.

温馨提示:推荐将访问根路径指向/path/to/phalapi/public。
Tips: It is recommended to point the root path of the visit to /path/to/phalapi/public.

数据库配置 / Database Configuration

如何使用的是MySQL数据库,参考修改./config/dbs.php数据库配置。
If you are using MySQL, please edit ./config/dbs.php.

return array(
    /**
     * DB数据库服务器集群 / database cluster
     */
    'servers' => array(
        'db_master' => array(                       // 服务器标记 / database identify
            'type'      => 'mysql',                 // 数据库类型,暂时只支持:mysql, sqlserver / database type
            'host'      => '127.0.0.1',             // 数据库域名 / database host
            'name'      => 'phalapi',               // 数据库名字 / database name
            'user'      => 'root',                  // 数据库用户名 / database user
            'password'  => '',	                    // 数据库密码 / database password
            'port'      => 3306,                    // 数据库端口 / database port
            'charset'   => 'UTF8',                  // 数据库字符集 / database charset
            'pdo_attr_string'   => false,           // 数据库查询结果统一使用字符串,true是,false否
            'driver_options' => array(              // PDO初始化时的连接选项配置
                // 若需要更多配置,请参考官方文档:https://www.php.net/manual/zh/pdo.constants.php
            ),
        ),
    ),

    // 更多代码省略……
);

最后,需要给runtime目录添加写入权限。更多安装说明请参考文档下载与安装
At last, add writeable permission to folder runtime. For more detail about installation, refer to Download and Installation.

使用 / Usage

调用接口 / API Request

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

For PhalApi, the default communicate protocol is HTTP/HTTPS. According to the specific implementation of the API service, we could use GET or POST to request. By default, you can specify the service parameter or s for short when requesting. The default API service is App.Site.Index.

对应执行的PHP代码在./src/app/Api/Site.php文件,源码片段如下:
The source PHP code of App.Site.Index API service is at ./src/app/Api/Site.php file.

<?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'],
        );
    }
}

接口请求后结果输出类似如下:
API result as below after requesting:

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

运行效果,截图如下:
Runtime Sreenshot:

_20190201151943

查看在线接口文档 / Visit Online API List Documents

PhalApi会根据你编写的接口的参数配置和代码注释,自动实时生成在线接口文档。在线接口文档链接为:
PhalApi will generate realtime online API documents automatically by PHP code and PHP comments. You can visit them by:

浏览效果类似如下:
Preview:

进入Portal运营平台 / Use Portal Platform

PhalApi采用了当前流行且优秀的layuimin开发全新的管理后台,专门提供给非技术的运营人员使用(技术人员也可使用)。安装Portal前请先配置好数据库连接。如果需要单独升级Portal,可进入应用市场免费下载到本地后安装升级。

PhalApi provides a new management system and we name it Portal.

翻译 / i18n

修改./public/init.php文件,可设置当前语言。
Edit ./public/init.php file to set current language.

// 翻译语言包设定-简体中文
\PhalApi\SL('zh_cn');

// Setting language to English
\PhalApi\SL('en');

一张图告诉你如何使用PhalApi 2.x / All in One Picture

phalapi-install

子项目 / Sub Projects

还有问题,怎么办?/ Any Question?

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

Welcome to report any issue here.
If you like PhalApi, welcome to give us a Star at Github.

开源许可协议 / Licence

Apache 2.0,Apache Licence是著名的非盈利开源组织Apache采用的协议。该协议和BSD类似,同样鼓励代码共享和尊重原作者的著作权,同样允许代码修改,再发布(作为开源或商业软件)。

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].