willgarcia/silex-api-boilerplate

Silex应用程序,用于开始使用您的API。

0.1.0 2014-08-04 06:57 UTC

This package is not auto-updated.

Last update: 2024-09-24 07:57:42 UTC


README

Build Status Dependency Status

silex-api-boilerplate

在Silex应用程序中构建RESTful API的起点。

先决条件

  • PHP >=5.4
  • Grunt-cli >= 0.1.6

组件

本项目使用以下组件

API

提供的API作为一个示例,并支持HAL格式

API端点(见app/routing.php

/api                                # API entry point               ; secured route
/api/errors                         # API errors list               ; secured route
/api/errors/{code}                  # API error description         ; secured route
/api/customers                      # Customers list                ; secured route
/api/customers/{cid}                # Customer informations         ; secured route
/api/customers/{cid}/licenses       # Customer's licenses list      ; secured route
/api/customers/{cid}/licenses/{lid} # Customer license informations ; secured route

安装

$ composer create-project willgarcia/silex-api-boilerplate my-new-api -s dev
$ npm install
$ grunt

开发

仅用于开发目的,您可以通过启动PHP内置的web服务器来提供API服务

$ cp app/env_dev.php-dist app/env_dev.php
$ API_ENV=dev php -S 0.0.0.0:4000 web/index.php

请参阅https://php.ac.cn/manual/en/features.commandline.webserver.php

从这里,您可以访问此URL:https://:4000

测试

$ bin/behat tests/functional/features/

许可证

Silex-api-boilerplate采用MIT许可证发布。有关详细信息,请参阅捆绑的LICENSE文件。