AccessibleBundle provides an Accessible integration for your Symfony projects

Overview

AccessibleBundle

SensioLabsInsight Dependency Status Latest Stable Version License

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

Here is a (very) basic example:

class Customer
{
  use AutomatedBehaviorTrait;

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


$bob = new Customer();

$bob->setEmail('[email protected]');
$bob->getEmail(); // [email protected]
$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!

Suggestions and contributions are welcome!

Documentation

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

Installation

First add the bundle in your Composer dependencies:

composer require antares/accessible-bundle

Then, register the bundle in your kernel:

// 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:

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

Configuration

The configuration of this bundle is quite simple, take a look:

# 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.

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?

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:

# 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:

# 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:

# app/config/services.yml

services:
    antares_accessible.constraints_validation.validator: '@validator'
You might also like...
This component provides a collection of functions/classes using the symfony/intl package when the Intl extension is not installed.

Symfony Polyfill / Intl: ICU This package provides fallback implementations when the Intl extension is not installed. It is limited to the "en" locale

🕧 Provides an scheduler bundle for symfony framework.

🕧 PHP Scheduler Bundle Provides the integration of the PHP Scheduler library into Symfony Framework. Installation Run composer require flexic/schedul

This package provides a simple and intuitive way to work on the Youtube Data API. It provides fluent interface to Youtube features.

Laravel Youtube Client This package provides a simple and intuitive way to work on the Youtube Data API. It provides fluent interface to Youtube featu

Use Ray in any PHP script without requiring it in your projects.

Global Ray Use Ray in any PHP script without requiring it in your projects. Require this package globally with Composer: composer global require cuyz/

A package for adding more type safety to your PHP projects.
A package for adding more type safety to your PHP projects.

Table of Contents Overview Installation Usage Simple Checks Advanced Checks Custom Checks Skipping Checks Testing Security Contribution Credits Change

 A complete solution for group projects in organizations that lets you track your work in any scenario. Working in a team is a cumbersome task, ease it using our project management system.
A complete solution for group projects in organizations that lets you track your work in any scenario. Working in a team is a cumbersome task, ease it using our project management system.

SE-Project-Group24 What is Evolo? Evolo is Dashboard based Project Management System. A complete solution for group projects in organizations that let

A simple GitScrum plugin for Wordpress. You will be able to manage your projects without having to leave Wordpress.
A simple GitScrum plugin for Wordpress. You will be able to manage your projects without having to leave Wordpress.

GitScrum Plugin for Wordpress A simple GitScrum plugin for Wordpress. You will be able to manage your projects without having to leave Wordpress. GitS

🚦 Viewi PHP integration for your Leaf apps
🚦 Viewi PHP integration for your Leaf apps

Leaf Viewi Module This module allows you to quickly and easily integrate Viewi into your Leaf apps without any pain at all. Installation You can easil

Comments
  • Unrecognized option

    Unrecognized option "antares_accessible" under "framework" -symfony 2.2

    Boss thanks alot for the awesome bundle but am having configuration error "Unrecognized option "antares_accessible" under "framework" and am using symfony 3.2 framework: #esi: ~ translator: { fallbacks: ['%locale%', 'en'] } secret: '%secret%' router: resource: '%kernel.root_dir%/config/routing.yml' strict_requirements: ~ form: ~ csrf_protection: ~ validation: { enable_annotations: true } templating: engines: ['twig'] #assets_version: SomeVersionScheme default_locale: '%locale%' trusted_hosts: ~ trusted_proxies: ~ session: # handler_id set to null will use default session handler from php.ini handler_id: ~ fragments: ~ http_method_override: true assets: ~ property_access: magic_call: true antares_accessible: cache.enable: true # default: false constraints_validation.enable: false # default: true constraints_validation.validate_initialize_values: true # default: %kernel.debug%

    opened by 1988gadocansey 1
Releases(v1.2)
Owner
Antares Tupin
Antares Tupin
Integration with your Symfony app & Stimulus!

StimulusBundle: Symfony integration with Stimulus! This bundle adds integration between Symfony, Stimulus and Symfony UX: A) Twig stimulus_* functions

Symfony 12 Jun 12, 2023
Tabler.io bundle for Symfony - a backend/admin theme for easy integration

Tabler Bundle for Symfony This repository contains a Symfony bundle, integrating the fantastic Tabler.io HTML Template into your Symfony project. It s

Kevin Papst 22 Jan 2, 2023
Sanitize untrustworthy HTML user input (Symfony integration for https://github.com/tgalopin/html-sanitizer)

html-sanitizer is a library aiming at handling, cleaning and sanitizing HTML sent by external users (who you cannot trust), allowing you to store it and display it safely. It has sensible defaults to provide a great developer experience while still being entierely configurable.

Titouan Galopin 86 Oct 5, 2022
Simple php-imap integration for Symfony 2.8, 3.x and 4.x.

PHP-IMAP integration bundle Simple php-imap integration for Symfony 4.x, 5.x and 6.x. The version 1.5 and above are only compatible with Symfony 4+. P

null 52 Dec 20, 2022
MeteionBundle is the Symfony integration of the Meteion library.

MeteionBundle MeteionBundle is a Symfony integration of the Meteion library. Key features Auto-configuration Commands Services Entities Installation c

Hiero 1 May 3, 2022
Symfony Framework Integration for HTTPlug

HTTPlug Bundle Symfony integration for HTTPlug. Installation To install the bundle with Symfony Flex, use the recipe: $ composer require php-http/http

The PHP HTTP group 369 Jan 3, 2023
This package provides a set of factories to be used with containers using the PSR-11 standard for an easy Doctrine integration in a project

psr-container-doctrine: Doctrine Factories for PSR-11 Containers Doctrine factories for PSR-11 containers. This package provides a set of factories to

Roave, LLC 84 Dec 14, 2022
This composer plugin allows you to share your selected packages between your projects by creating symlinks

Composer - Shared Package Plugin This composer plugin allows you to share your selected packages between your projects by creating symlinks. All share

L'Etudiant 169 Sep 20, 2022
Simple Symfony API-Platform Template which you can use to start to develop with symfony and api-platform

symfony-api-platform-skeleton Simple Template for Symfony API You can fork it and change the git remote to your Repo git remote set-url <your-git-remo

null 1 Jan 23, 2022
Dockerise Symfony Application (Symfony 6 + Clean Architecture+ DDD+ CQRS + Docker + Xdebug + PHPUnit + Doctrine ORM + JWT Auth + Static analysis)

Symfony Dockerise Symfony Application Install Docker Install Docker Compose Docker PHP & Nginx Create Symfony Application Debugging Install Xdebug Con

null 48 Jan 5, 2023