delormejonathan/accessible-bundle
Composer 安装命令:
composer require delormejonathan/accessible-bundle
包简介
A bundle to easily use Accessible in Symfony projects.
README 文档
README
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('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!
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@Initializeand@InitializeObjectvalues 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.driveris the cache driver used by the libraryantares_accessible.annotations.cache_driveris 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'
delormejonathan/accessible-bundle 适用场景与选型建议
delormejonathan/accessible-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 57 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 05 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「annotation」 「set」 「class」 「properties」 「get」 「popo」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 delormejonathan/accessible-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 delormejonathan/accessible-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 delormejonathan/accessible-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Simple, immutable data structures
Collection of methods that I or you usually use.
A very simple yet useful helper class to handle PHP file uploads.
Symfony bundle to add arbitrary metadata to classes and their constants by annotation
Baum is an implementation of the Nested Set pattern for Eloquent models.
A useful set of HTML and Form macros with css and js made for bootstrap
统计信息
- 总下载量: 57
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-05-08