Download the PHP package lionsad/service_container without Composer
On this page you can find all versions of the php package lionsad/service_container. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download lionsad/service_container
More information about lionsad/service_container
Files in lionsad/service_container
Package service_container
Short Description Service Container based on CTools plugins with Symfony Integration
License GPL-2.0+
Homepage https://www.drupal.org/project/service_container
Informations about the package service_container
service_container
![Gitter](https://badges.gitter.im/Join Chat.svg)
Versions
Service Container is an API module based on ctools to enable a Drupal 7 quick and easy lightweight service container with 100% unit test coverage.
It is very similar in syntax to a Symfony container, but was written from scratch as a symfony dependency was not wanted - using some of Drupal 8 Core and Component directly. They will likely depend on a drupal8core project in the future - but for now the copy is fine.
This allows to use an extensible service container (like in Drupal 8) and write modules in Drupal 7 as if they were using Drupal 8.
The main benefit is being able to use unit testing but also to write Drupal 7 module with Drupal 8 style of coding in mind.
The module uses PHP Unit and travis.yml, but the tests and a composer.json are isolated in the tests/ directory, so no vendor or composer multi map is needed by default.
It was originally written for the render_cache module, but since then others have expressed interest in using it, so it was split it out and made a dependency of render_cache instead.
You need:
or any other PSR-4 autoloader.
Registering CTools plugins
By default the service_container supports CTools discovery, to register your plugins all you need to do is:
``
And you can then get a plugin via:
``
Because the plugin managers implement the whole discovery interface, you can get all definitions with ease.
``
Your plugin itself looks like:
cat modules/render_cache_block/src/RenderCache/Controller/block.inc
``
So you can use normal container parameter syntax.
Provides the following services:
- module handler ('module_handler') and module installer ('module_installer')
- service container ('service_container')
- database ('database')
- key value store ('keyvalue', 'keyvalue.database')
- variable, a wrapper for variable_get() / variable_set()
- A lock ('lock')
- A wrapper for url() / l() ('url_generator', 'link_generator')
- Flood, a wrapper for the flood mechanisms
- Messenger, a wrapper for displaying messages
- Drupal 7 Legacy, a wrapper for accessing the Drupal 7 legacy functions.
- More to come...
Testing
- service_container is tested via PHPUnit for code correctness. (run ./tests/run-tests.sh)
- service_container is tested via simpletest for integration with Drupal. (run ./tests/run-simpletests.sh)
- service_container is tested via PHPUnit for code coverage. (run ./tests/run-coverage.sh)
List of Drupal 8 core services that we've altered
See the file HACK.md for more details.