phantom-d / shop-cart
简单购物车
v1.0
2016-02-29 13:03 UTC
Requires
- php: >=5.4.0
Requires (Dev)
This package is auto-updated.
Last update: 2024-09-09 18:12:54 UTC
README
作为独立REST API服务的在线商店购物车
安装
####要求
- Vagrant - 创建完整开发环境的工具。
- Virtualbox - 部署虚拟机的工具
####获取代码
#####Composer
执行命令 composer create-project --no-dev --prefer-dist phantom-d/shop-cart
#####GitHub
克隆仓库: git clone https://github.com/phantom-d/shop-cart.git
#####部署开发环境
- 进入项目目录:
cd shop-cart
- 启动开发环境:
vagrant up
注意:将安装操作系统 CentOS 7.2 和软件:NGINX、PHP 5.6、GIT、COMPOSER
注意:要访问网站,需要在
hosts
中添加以下条目:192.168.33.10 www.shop-cart.local shop-cart.local
####支持的命令
GET http://www.shop-cart.local/api/products/
- 获取商品列表GET http://www.shop-cart.local/api/cart/
- 获取当前购物车POST http://www.shop-cart.local/api/cart/
- 向购物车添加商品,接受参数
$_POST = [ 'product_id' => 1, // Тип `integer`, больше 0 'quantity' => 1, // Тип `integer`, в диапазоне от 1 до 10 ];
DELETE http://www.shop-cart.local/api/cart/1/
- 删除购物车中的1件商品OPTIONS http://www.shop-cart.local/api/cart/
- 获取购物车支持的所有HTTP方法列表OPTIONS http://www.shop-cart.local/api/products/
- 获取商品支持的所有HTTP方法列表
在当前任务中
- 所有数据都返回为
JSON
格式。 - 购物车的有效期为5分钟。
测试
使用 Codeception
框架进行测试
####配置
- 进入项目目录:
cd /var/www/shop-cart
- 更新composer包
composer update
- 进入测试目录:
cd /var/www/shop-cart/tests
- 运行测试
codeception run