phprest / phprest-api-blueprint-sample-project
Phprest 示例项目。
dev-master
2015-11-22 16:20 UTC
Requires
- jsor/stack-jwt: 2.0.0
- namshi/jose: ~6.0
- phprest/phprest: dev-master
- phprest/phprest-service-orm: dev-master
- phprest/phprest-service-request-filter: dev-master
- phprest/phprest-service-validator: dev-master
This package is not auto-updated.
Last update: 2024-09-14 17:48:22 UTC
README
要求
- Composer
- Php 5.4 或最新版
- MySql 5.x
- NodeJS 用于 API 和文档测试
- Hercule 用于创建基于 API Blueprint 的文档
- Apiary client 用于创建基于 API Blueprint 的文档
- Dredd 用于测试基于 API Blueprint 的文档
安装
1. 创建项目
composer -sdev create-project phprest/phprest-api-blueprint-sample-project /path/to/your/project
2. 配置数据库设置
在 app/config/orm.php
中设置数据库凭据。
3. 创建数据库
create database tesselboard collate=utf8mb4_unicode_ci;
4. 数据库迁移
(从项目目录的根目录)
vendor/bin/phprest-service-orm migrations:migrate
5. 数据库固定数据
(从项目目录的根目录)
vendor/bin/phprest-service-orm fixtures:set
6. 存储目录
(从项目目录的根目录)
存储目录 (app/storage
) 必须可由 Web 服务器写入。
创建 API 文档
(从项目目录的根目录)
hercule blueprint/0.1/blueprint.md -o public/blueprint.md;
apiary preview --path=public/blueprint.md --output=public/api_documentation.html
测试 API 文档
vendor/bin/phprest-service-orm fixtures:set
dredd public/blueprint.md https:///
API 测试(规范测试)
(从项目目录的根目录)
cd specs
npm install
cd ..
vendor/bin/phprest-service-orm fixtures:set
specs/node_modules/jasmine-node/bin/jasmine-node --verbose specs/tests
列出您的路由
(从项目目录的根目录)
vendor/bin/phprest routes:get
您应该得到类似以下内容
Nginx 示例配置
server {
listen 80;
server_name localhost;
root /var/www/application/public;
index index.php;
location / {
try_files $uri $uri/ @rewrite;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location @rewrite {
rewrite ^ /index.php;
}
error_log /var/log/nginx/application_error.log;
}