2017 © Pedro Peláez
 

library base-bundle

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

image

sidus/base-bundle

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

  • Wednesday, July 11, 2018
  • by VincentChalnot
  • Repository
  • 1 Watchers
  • 0 Stars
  • 754 Installations
  • PHP
  • 6 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 249 % Grown

The README.md

Sidus/BaseBundle Documentation

Service loading

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

<?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:, (*2)

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., (*3)

Param converter

Take a look at the AbstractParamConverter, declaring param converter is much more simple now, (*4)

Compiler passes

The GenericCompilerPass allows you to easily inject all services tagged with a specific tag into another service., (*5)

Utilities

DateTime parsing

DateTimeUtility::parse will allow you to parse date time from multiple formats easily., (*6)

Translation

Use the TranslatorUtility to iterate over various translation keys in order to return the first matching one., (*7)

Validator

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

<?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., (*9)

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

Serializer

See SidusBaseSerializerBundle for additional support., (*11)

The Versions

11/07 2018

dev-master

9999999-dev https://github.com/VincentChalnot/SidusBaseBundle

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

  Sources   Download

MIT

The Requires

  • php >=5.6

 

symfony base

11/07 2018

v1.0.4

1.0.4.0 https://github.com/VincentChalnot/SidusBaseBundle

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

  Sources   Download

MIT

The Requires

  • php >=5.6

 

symfony base

23/05 2018

v1.0.3

1.0.3.0 https://github.com/VincentChalnot/SidusBaseBundle

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

  Sources   Download

MIT

The Requires

  • php >=5.6

 

symfony base

18/05 2018

v1.0.2

1.0.2.0 https://github.com/VincentChalnot/SidusBaseBundle

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

  Sources   Download

MIT

The Requires

  • php >=5.6

 

symfony base

02/05 2018

v1.0.1

1.0.1.0 https://github.com/VincentChalnot/SidusBaseBundle

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

  Sources   Download

MIT

The Requires

  • php >=5.6

 

symfony base

09/04 2018

v1.0.0

1.0.0.0 https://github.com/VincentChalnot/SidusBaseBundle

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

  Sources   Download

MIT

The Requires

  • php >=5.6

 

symfony base