2017 © Pedro Peláez
 

symfony-bundle accessible-bundle

A bundle to easily use Accessible in Symfony projects.

image

antares/accessible-bundle

A bundle to easily use Accessible in Symfony projects.

  • Wednesday, May 17, 2017
  • by antares993
  • Repository
  • 1 Watchers
  • 13 Stars
  • 1,879 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 9 % Grown

The README.md

AccessibleBundle

SensioLabsInsight Dependency Status Latest Stable Version License, (*1)

AccessibleBundle provides an Accessible integration for your Symfony projects. This will allow you to define your class behavior using powerful annotations., (*2)

Here is a (very) basic example:, (*3)

class Customer
{
  use AutomatedBehaviorTrait;

  /**
   * @Access({Access::GET, Access::SET})
   * @Assert\Email
   */
  private $email;
}


$bob = new Customer();

$bob->setEmail('bob@example.com');
$bob->getEmail(); // bob@example.com
$bob->setEmail('not an email address'); // throws an InvalidArgumentException

Here the library is used to generate getters and setters, but it can also be used to manage constructors, attributes initialization, collections and associations between classes!, (*4)

Suggestions and contributions are welcome!, (*5)

Documentation

This file contains everything you will need to use this bundle. For details on the use of the library, see the Accessible page., (*6)

Installation

First add the bundle in your Composer dependencies:, (*7)

composer require antares/accessible-bundle

Then, register the bundle in your kernel:, (*8)

// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...

        new Antares\Bundle\AccessibleBundle\AntaresAccessibleBundle()
    );
}

In order to be compatible with the PropertyAccess component you should also add the following lines in your configuration:, (*9)

# app/config/config.yml
framework:
  property_access:
    magic_call: true

Configuration

The configuration of this bundle is quite simple, take a look:, (*10)

# app/config/config.yml
antares_accessible:
    cache:
        enable: true # default: false
    constraints_validation:
        enable: false # default: true
        validate_initialize_values: true # default: %kernel.debug%

Note that you don't need to set the configuration as everything is already configured by default., (*11)

Here are the meanings of the configuration values: - cache.enable: Do you want a cache driver to be used? - constraints_validation.enable: Do you want your class setters to use constraints validation? - constraints_validation.validate_initialize_values: Do you want the @Initialize and @InitializeObject values to be validated?, (*12)

Use a custom cache driver

By default, instances of Doctrine\Common\Cache\PhpFileCache are used. If you have APC enabled, you should replace the cache driver. You can do it like this:, (*13)

# app/config/services.yml

parameters:
    antares_accessible.cache_driver.class: Doctrine\Common\Cache\ApcCache

services:
    antares_accessible.cache.driver:
        class: "%antares_accessible.cache_driver.class%"
    antares_accessible.annotations.cache_driver:
        class: "%antares_accessible.cache_driver.class%"
  • antares_accessible.cache.driver is the cache driver used by the library
  • antares_accessible.annotations.cache_driver is the cache driver used by the library's annotation reader

Use a custom annotations reader

You can use a custom annotations reader:, (*14)

# app/config/services.yml

services:
    antares_accessible.annotations.reader:
        class: Doctrine\Common\Annotations\AnnotationReader

Use a custom validator

You can also use a custom constraints validator, for example, if your project already uses the validator service, you can use it also with this library like this:, (*15)

# app/config/services.yml

services:
    antares_accessible.constraints_validation.validator: '@validator'

The Versions

17/05 2017

dev-master

9999999-dev https://github.com/antares993/AntaresAccessibleBundle

A bundle to easily use Accessible in Symfony projects.

  Sources   Download

MIT

The Requires

 

by Antarès Tupin

class getter setter annotation set properties get popo pojo accessible

27/04 2016

v1.2

1.2.0.0 https://github.com/antares993/AntaresAccessibleBundle

A bundle to easily use Accessible in Symfony projects.

  Sources   Download

MIT

The Requires

 

by Antarès Tupin

class getter setter annotation set properties get popo pojo accessible

09/02 2016

v1.1.1

1.1.1.0 https://github.com/antares993/AntaresAccessibleBundle

A bundle to easily use Accessible in Symfony projects.

  Sources   Download

MIT

The Requires

 

by Antarès Tupin

class getter setter annotation set properties get popo pojo accessible

22/11 2015

v1.1

1.1.0.0 https://github.com/antares993/AntaresAccessibleBundle

A bundle to easily use Accessible in Symfony projects.

  Sources   Download

MIT

The Requires

 

by Antarès Tupin

class getter setter annotation set properties get popo pojo accessible

16/11 2015

v1.0

1.0.0.0 https://github.com/antares993/AntaresAccessibleBundle

A bundle to easily use Accessible in Symfony projects.

  Sources   Download

MIT

The Requires

 

by Antarès Tupin

class getter setter annotation set properties get popo pojo accessible