knplabs / rad-auto-registration
Auto register some common services
Installs: 38 368
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 28
Forks: 3
Open Issues: 4
Requires
- php: ~7.0
- doctrine/dbal: ~2.2
- doctrine/inflector: ~1.0
- psr/log: ~1.0
- symfony/config: ~2.8||~3.0
- symfony/dependency-injection: ~2.8||~3.0
- symfony/framework-bundle: ~2.8||~3.0
- symfony/http-kernel: ~2.8||~3.0
- symfony/security-bundle: ~2.8||~3.0
- symfony/twig-bundle: ~2.8||~3.0
- twig/twig: ~1
Requires (Dev)
- bossa/phpspec2-expect: ~1.0.0
- knplabs/phpspec-welldone-extension: dev-master@dev
- pedrotroller/php-cs-custom-fixer: ~1.2.1
- phpspec/phpspec: ~2.4
README
Unfortunately we decided to not maintain this project anymore (see why). If you want to mark another package as a replacement for this one please send an email to hello@knplabs.com.
Rapid Application Development : Auto-Registration
Auto register some common services
Official maintainers:
Installation
composer require knplabs/rad-auto-registration:~2.0
class AppKernel { function registerBundles() { $bundles = array( //... new Knp\Rad\AutoRegistration\Bundle\AutoRegistrationBundle($this), // !! Do not forget to inject the kernel !! //... ); //... return $bundles; } }
Use
Doctrine repositories auto-registration
Just activate doctrine
(or doctrine_mongodb
ou doctrine_couchdb
depending on your needs) into your configuration.
knp_rad_auto_registration: enable: doctrine: ~ doctrine_mongodb: ~ doctrine_couchdb: ~
Now all repositories are auto-registred.
Entity | Repository |
---|---|
MyProjectBundle\Entity\User | my_project_bundle.entity.user_repository |
TheOtherBundle\Entity\Model\Address | the_other_bundle.model.user.address_repository |
MyProjectBunde\Document\User | my_project_bundle.document.user_repository |
Requirements
Your doctrine entity (or documents) should be stored under Entity
, Document
or Model
sub-namespace.
Constraint validators
Just activate constraint_validator
into your configuration.
knp_rad_auto_registration: enable: constraint_validator: ~
Now all custom constaint validators are auto-registered.
Requirements
Your constraint validators should be stored under Validation
or Validator
sub-namespace.
Form extensions
Just activate form_type_extension
into your configuration.
knp_rad_auto_registration: enable: form_type_extension: ~
Now all form type extensions are auto-registred.
Requirements
Your form type extensions should be stored under Form
sub-namespace.
Security voters
Just activate security_voter
into your configuration.
knp_rad_auto_registration: enable: security_voter: ~
Now all the voters are auto-registered.
Requirements
Your security voters should be stored under Security
sub-namespace.
Twig extensions
Just activate twig_extension
into your configuration.
knp_rad_auto_registration: enable: twig_extension: ~
Now all Twig extensions are auto-registered.
Requirements
Your Twig extensions should be stored under Twig
or Templating
sub-namespace.
Public/Private services
By default, all autoregistered services are marked as private
(public: false
). You can overide this behavior by setting the public
parameter to true
.
Example:
knp_rad_auto_registration: enable: doctrine: public: true doctrine_mongodb: public: false doctrine_couchdb: public: false
Restrictions
Autoloading
- Only services without constructor or without required parameters into the constructor will be auto-registred.
- If a service already exists, it will not be erased.
Bundle
You can apply auto-registration on only certains bundle. You just have to add a bundles
configuration:
knp_rad_auto_registration: enable: # ... bundles: [ App, ProductBundle ]
WARNING
All auto-registered services are set as private
, so it's impossible to get them by using $container->get('service_name')
. If needed, create the service definition by yourself.