blok/laravel-mock 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

blok/laravel-mock

Composer 安装命令:

composer require blok/laravel-mock

包简介

An easy mock api helper that simulate GET, PUT, DELETE, POST requests in a json folder

关键字:

README 文档

README

Scrutinizer Code Quality Packagist Packagist Packagist

A simple mock api helper that simulate GET, PUT, DELETE, POST requests and store it to a json folder.

Installation

Install via composer

composer require blok/laravel-mock

Register Service Provider

Note! This and next step are optional if you use laravel>=5.5 with package auto discovery feature.

Add service provider to config/app.php in providers section

Blok\Mock\ServiceProvider::class,

Register Facade

Register package facade in config/app.php in aliases section

Blok\Mock\Facades\Mock::class,

Publish Configuration File

php artisan vendor:publish --provider="Blok\Mock\ServiceProvider" --tag="config"

Usage

Folder mode

Let's say that you have this in your mock folder

storage/mock
|- users
|-- 1.json
|-- 2.json

If you make that requests :

GET /mock/users it will return :

[
  {
    "1" : {
      "id" : 1,
      "name" : "foo"
    }
  },
  {
    "2" : {
      "id" : 2,
      "name" : "bar"
    }
  }
]

GET /mock/users/1 will return :

{
      "id" : 1,
      "name" : "foo"
}

PUT /mock/users/1 will save your request into /mock/users/1.json

DELETE /mock/users/1 will delete your request in /mock/users/1.json

Factory mode

If you see the config/mock.php you will see a commented array in entrypoints.

If you uncommented that you will be able to call your factory for the model you want.

=> if enabled it will return mock data from your factories instead from json.

Test a FormRequest or mock a validation

You can easily test your FormRequest or Validation by adding in the entrypoint "$action$_validation" in your config file => it could receive an array or a FormRequest.

Force to json

By default, the config will only accept json request, but if you want for some reason disable or test a redirection instead. You can do it in your config file (at a global or in the method level of the controller).

Security

If you discover any security related issues, please email me instead of using the issue tracker.

Credits

This package is bootstrapped with the help of blok/laravel-package-generator.

统计信息

  • 总下载量: 1.13k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-08-15

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固