saga / dic-module
This module provides the Dependency Injection Container integration in Drupal 7.
Installs: 13 761
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 5
Forks: 5
Open Issues: 2
Type:drupal-module
Requires
- symfony/config: 2.6.*
- symfony/dependency-injection: 2.6.*
- symfony/yaml: 2.6.*
Requires (Dev)
- phpunit/phpunit: 4.3.*
This package is not auto-updated.
Last update: 2024-12-21 17:12:11 UTC
README
Using this Drupal module, you can use the Symfony Dependency Injection Container in your Drupal 7 modules. This will help you writing custom Drupal modules in a more object-oriented, future-proof and maintainable way.
Composer is required in your project and this module expects a composer.json file in the root of your Drupal installation.
Installation and Configuration
- Make sure Composer is installed.
- Add a composer.json file to the root of your Drupal 7 installation with the following content:
{
"require": {
"php": ">=5.3.0",
"composer/installers": "~1.0",
"saga/dic-module": "~7.1"
},
"extra": {
"installer-paths": {
"sites/all/modules/vendor/{$name}": ["type:drupal-module"]
}
}
}
- In terminal, go to the root of your Drupal 7 sites (where the composer.json file lives) and execute "composer install".
- The DIC module will now be available in "sites/all/modules/vendor/dic" and is ready to be installed using the regular module installation procedure.
- Make sure that the "/vendor" and "sites/*/modules/vendor" folders are added to the .gitignore, you don't want these folders in your VCS.
Creating custom modules
If you want to create custom modules that use the DIC module, make sure that the classes in your module are autoloaded correctly. You can use several methods to do this:
- Using the Composer autoload functionality
- Using the xautoload Drupal module
- Using the registry_autoload Drupal module
Sponsors
This module is sponsored by Saga Consulting Group.
License
This module is licensed under GENERAL PUBLIC LICENSE Version 2, June 1991. See the bundled LICENSE file for details.