承接 codingculture/request-resolver-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

codingculture/request-resolver-bundle

最新稳定版本:3.1.1

Composer 安装命令:

composer require codingculture/request-resolver-bundle

包简介

Joins the power of symfony OptionsResolver and Requests to create a clean API for your requests

README 文档

README

Build Status Codacy Badge Latest Stable Version Total Downloads

This Symfony bundle tries to make request assertion a little bit easier.

This bundle is still a work in progress.

PHP7.1+ only.

Usage

<?php

...

class SomeController extends Controller
{
    public function someAction()
    {
        $request = $this->get('codingculture.requestresolver.resolver')->resolve(new SomeRequest());
        
        $request->getId();
    }
}
<?php

...

final class SomeRequest implements ResolvableRequestInterface
{
    private $options = [];
    
    public function getId(): string
    {
        return $this->options['id'];
    }

    public function defineOptions(OptionsResolver $resolver): OptionsResolver
    {
        $resolver->setRequired('id')
    }
    
    public function setOptions(array $options)
    {
        $this->options = $options;
    }
    
    public function getContentType(): string
    {
        return RequestResolver::CONTENT_TYPE_ALLOW_ALL;
    }
}

If a user sent a bad request, an InvalidArgumentException (or an extension of it) will be thrown on resolve method.

Todo

  • Write better docs

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-01-24