承接 sidus/base-bundle 相关项目开发

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

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

sidus/base-bundle

最新稳定版本:v1.1.4

Composer 安装命令:

composer require sidus/base-bundle

包简介

Ease the declaration of routing and services for Symfony 3 & 4

README 文档

README

Service loading

If you simply inherit from the SidusBaseExtension, all the YAML files present in this directory will be loaded: ./Resources/config/services

<?php

namespace FooBarBundle\DependencyInjection;

use Sidus\BaseBundle\DependencyInjection\SidusBaseExtension;

class FooBarExtension extends SidusBaseExtension
{
}

Routing

Instead of using controllers, declare service for each action and then you just have to declare the routing like this:

FooBarBundle\Action\MyAction: # Route name must match service id
    path: /path/{parameter}

You don't need to declare the _controller part, it will be loaded with your route name.

Param converter

Take a look at the AbstractParamConverter, declaring param converter is much more simple now

Compiler passes

The GenericCompilerPass allows you to easily inject all services tagged with a specific tag into another service.

Utilities

DateTime parsing

DateTimeUtility::parse will allow you to parse date time from multiple formats easily.

Translation

Use the TranslatorUtility to iterate over various translation keys in order to return the first matching one.

Validator

You can use the BaseLoader class to load a sets of constraints from a PHP array with the same syntax than Yaml:

<?php
/** @var ValidatorInterface $validator */

use Sidus\BaseBundle\Validator\Mapping\Loader\BaseLoader;use Symfony\Component\Validator\Validator\ValidatorInterface;

$loader = new BaseLoader();

$constraints = $loader->loadCustomConstraints([
    ['Regex' => ['pattern' => '/^[a-z0-9]+(?:[-\_][a-z0-9]+)*$/']],
    ['NotNull' => null],
]);

foreach ($constraints as $constraint) {
    $violations = $validator->validate($data, $constraint);
    // Do stuff with the violations
}

Forms

The ChoiceTypeExtension allows choice form types to work with iterable objects. You don't need to do anything.

A new option is available for any form type: block_prefix allows you to directly choose a custom block prefix for form rendering.

Serializer

See SidusBaseSerializerBundle for additional support.

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-04-09