DependencyInjection Component
The DependencyInjection component allows you to standardize and centralize the way objects are constructed in your application.
The DependencyInjection component allows you to standardize and centralize the way objects are constructed in your application.
Symfony\Component\DependencyInjection\Dumper\XmlDumper didn't write 'factory-class' XML attribute for definitions on which setFactoryClass() was set.
This caused the Container[Builder] to throw an exception when the relevant service is being requested/initiated after loading the dumped XML:
Uncaught Exception Symfony\Component\DependencyInjection\Exception\RuntimeException: "Cannot create service "xxx" from factory method without a factory service or factory class." at /<path>/<to>/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/ContainerBuilder.php
Fixed the problem, and updated relevant test fixture.
For example:
parameters: social: facebook: app_id: 1234567890
Now it's possible to get app_id like: $this->get('social:facebook:app_id');
The colon symbol ":" don't allowed for use in parameter name and it's the most appropriate symbol for separator. At last we get more conveniently for get nested arrays value.
I've got an error when I tried to use DI to initiate Monolog logger with next settings:
services:
logger_formatter:
class: \Monolog\Formatter\LineFormatter
arguments: [ "[%%datetime%%] %%channel%%.%%level_name%%: %%message%% %%context%%\n" ]
logger_handler:
class: \Monolog\Handler\StreamHandler
arguments:
- app.log
- <?php echo \Monolog\Logger::DEBUG, PHP_EOL; ?>
calls:
- [ setFormatter, [ @logger_formatter ]]
logger:
class: \Monolog\Logger
arguments: [ 'logger_name' ]
calls:
- [ pushHandler, [ @logger_handler ]]
If I set argument for service logger_formatter with single % (like "[%datetime%]…") then DI threw exception that it could not resolve reference because there was non-existent parameter "datetime". If I set argument with double % (like "[%%datetime%%]…") then DI transferred parameter to the LineFormatter object without unescaping, and LineFormatter did not work properly. The problem was in ContainerBuilder, because there was no unescaping class parameters.
I’ve fixed problem and added tests to cover such case.
When you have to much env variables and many services in your container, container compilаtion can take much time due to the function stripos which is called much time. Look at the bottom of picture https://i2.piccy.info/i9/cdc413af9aecce8f7ed5ca0fe69b6c7c/1640950765/149173/1453384/6833Screenshot_from_2021_12_31_13_38_20.png
It happens because function resolveEnvPlaceholders try to find env placeholders in any value, even when there is no possible env in string.
So i offer to check value on strings env_ or env( and if they are present than look for placeholders.
In my project it helps me to save 10 seconds in container building.
Q | A -- | -- Branch? | 6.0 Bug fix? | no New feature? | no Deprecations? | no License | MIT
Just extended two attributes that do not break compatibility, are optional and null. The feature only allows you to do almost the same as in YAML files, the configuration specifying defaultIndexMethod for:
ParameterBagInterface has comment on get method: @throws ParameterNotFoundException if the parameter is not defined but InvalidArgumentException is thrown.
Note: On the outside chance this can be a quick fix, I'm submitting this patch as-is. In the meantime I'll be reviewing the coding standards, testing procedures, and submission guidelines to work up a full-fledged PR.
Aligns method signature with BaseFileLoader which is the alias of the Symfony\Component\Config\Loader\FileLoader class.
I received the error below on a recent update to our Symfony packages:
===================BEGIN BACKTRACE===================
Declaration of
Symfony\Component\DependencyInjection\Loader\FileLoader::import($resource, $type = NULL, $ignoreErrors = false, $sourceResource = NULL, $exclude = NULL)
should be compatible with
Symfony\Component\Config\Loader\FileLoader::import($resource, ?string $type = NULL, bool $ignoreErrors = false, ?string $sourceResource = NULL, $exclude = NULL)
at ../vendor/symfony/dependency-injection/Loader/FileLoader.php 30:
../site.null/htdocs/index.php (7) calling require()
../bootstrap.php (41) calling {closure}()
../bootstrap.php (37) calling require_once()
../bootstrap/service_container.php (29) calling spl_autoload_call()
../vendor/composer/ClassLoader.php (322) calling Composer\Autoload\includeFile()
../vendor/composer/ClassLoader.php (444) calling include()
../vendor/symfony/dependency-injection/Loader/PhpFileLoader.php (24) calling spl_autoload_call()
../vendor/composer/ClassLoader.php (322) calling Composer\Autoload\includeFile()
../vendor/composer/ClassLoader.php (444) calling include()
====================END BACKTRACE====================
As described in https://symfony.com/blog/new-in-symfony-reproducible-builds Symfony should allow to create static compiled cache. In many cases it works. However it doesn`t work when we change global parameter. $files variable will change, the hash also will be different, so folder name (Container{hash}) will change as well.
This pull request should solve the problem.
Added .gitattributes
to exclude the Tests folder on export - e.g. when pulled in via composer.
I've also included the following files which are also not required:
.gitattributes
, .gitignore
, phpunit.xml.dist
I use this function ALL THE TIME in my unit tests.
In my project, I have a subclass of PHPUnit_Framework_TestCase where I have copied this function. This makes it incredibly easy to create mock objects from my services that are provided by the DI Container for unit testing.
$emailService = $this->getServiceMock('service.email', array('send'));
// Now we can make normal PHPUnit expectations....
$emailService->expects($this->once())->method('send'));
I'm not sure where in Symfony DI that this would go... perhaps a trait? I'm sure this would be something that many other devs find very useful.
The ParameterBagInterface was missing some @throws annotations, so the FrozenParameterBag class was a violation of Liskov subtitution principle. Also the ParameterBagInterface was missing the remove method.
| Q | A | | --- | --- | | Bug fix? | no | | New feature? | no | | BC breaks? | no | | Deprecations? | no | | Tests pass? | yes | | Fixed tickets | | | License | MIT | | Doc PR | |
Changelog (https://github.com/symfony/dependency-injection/compare/v6.2.2...v6.2.3)
Changelog (https://github.com/symfony/dependency-injection/compare/v6.1.8...v6.1.9)
Changelog (https://github.com/symfony/dependency-injection/compare/v6.0.16...v6.0.17)
Changelog (https://github.com/symfony/dependency-injection/compare/v5.4.16...v5.4.17)
Changelog (https://github.com/symfony/dependency-injection/compare/v6.2.1...v6.2.2)
Changelog (https://github.com/symfony/dependency-injection/compare/v6.2.0...v6.2.1)
ContainerBuilder
stats env usage with enum (alamirault)Changelog (https://github.com/symfony/dependency-injection/compare/v6.2.0-RC2...v6.2.0)
Changelog (https://github.com/symfony/dependency-injection/compare/v6.1.7...v6.1.8)
ServiceLocatorTagPass
(MatTheCat)Changelog (https://github.com/symfony/dependency-injection/compare/v6.0.15...v6.0.16)
ServiceLocatorTagPass
(MatTheCat)Changelog (https://github.com/symfony/dependency-injection/compare/v5.4.15...v5.4.16)
ServiceLocatorTagPass
(MatTheCat)Changelog (https://github.com/symfony/dependency-injection/compare/v4.4.48...v4.4.49)
ServiceLocatorTagPass
(MatTheCat)Changelog (https://github.com/symfony/dependency-injection/compare/v6.2.0-BETA3...v6.2.0-RC1)
ServiceLocatorTagPass
(MatTheCat)Changelog (https://github.com/symfony/dependency-injection/compare/v6.2.0-BETA2...v6.2.0-BETA3)
Changelog (https://github.com/symfony/dependency-injection/compare/v6.1.6...v6.2.0-BETA1)
SubscribedService[]
(kbond)#[When]
attribute (ruudk)resolve-env
option to debug:config command (alexandre-daubois)shuffle
env processor (ostrolucky)Changelog (https://github.com/symfony/dependency-injection/compare/v6.1.4...v6.1.5)
Changelog (https://github.com/symfony/dependency-injection/compare/v6.0.12...v6.0.13)
Changelog (https://github.com/symfony/dependency-injection/compare/v5.4.12...v5.4.13)
Changelog (https://github.com/symfony/dependency-injection/compare/v6.1.2...v6.1.3)
Changelog (https://github.com/symfony/dependency-injection/compare/v6.0.10...v6.0.11)
Changelog (https://github.com/symfony/dependency-injection/compare/v5.4.10...v5.4.11)
Changelog (https://github.com/symfony/dependency-injection/compare/v4.4.43...v4.4.44)
Changelog (https://github.com/symfony/dependency-injection/compare/v6.1.1...v6.1.2)
Changelog (https://github.com/symfony/dependency-injection/compare/v6.0.9...v6.0.10)
Changelog (https://github.com/symfony/dependency-injection/compare/v5.4.9...v5.4.10)
Changelog (https://github.com/symfony/dependency-injection/compare/v4.4.42...v4.4.43)
Changelog (https://github.com/symfony/dependency-injection/compare/v6.1.0-RC1...v6.1.0)
Changelog (https://github.com/symfony/dependency-injection/compare/v6.0.8...v6.0.9)
Changelog (https://github.com/symfony/dependency-injection/compare/v5.4.8...v5.4.9)
Changelog (https://github.com/symfony/dependency-injection/compare/v4.4.41...v4.4.42)
Changelog (https://github.com/symfony/dependency-injection/compare/v6.1.0-BETA2...v6.1.0-RC1)
Nette DI Configure your Nette application ?? Check out our documentation. ?? If you like Orisai, please make a donation. Thank you! namespace App; us
Nette Dependency Injection (DI) Introduction Purpose of the Dependecy Injection (DI) is to free classes from the responsibility for obtaining objects
ClanCats Container A PHP Service Container featuring a simple meta-language with fast and compilable dependency injection. Requires PHP >= 7.0 Pros: M
What is Twittee? Twittee is the smallest, and still useful, Dependency Injection Container in PHP; it is also probably one of the first public softwar
Laravel API Response This package aims to help you standardize all your API responses in a simple and structured way. By default, the stucture of the
Laravel Formatters This package is a collection of classes you can use to standardize data formats in your Laravel application. It uses the Service Co
YCOM Impersonate Login as selected YCOM user in frontend. Features: Backend users with admin rights or YCOM[] rights, can be automatically logged in v
?? Yell PHP package to make your objects strict and throw exception when you try to access or set some undefined property in your objects. Requirement
Deeper Deeper is a easy way to compare if 2 objects is equal based on values in these objects. This library is heavily inspired in Golang's reflect.De
Custom Logger This package allows you to send logs to files. based on monolog/monolog. You can use it during your development to make debugging easier
wepesi_validation this module will help to do your own input validation from http request POST or GET. INTEGRATION The integration is the simple thing
sabre/vobject The VObject library allows you to easily parse and manipulate iCalendar and vCard objects using PHP. The goal of the VObject library is
Super Simple DTO Creating data transfer objects with the power of php objects. No php attributes, no reflection api, and no other under the hook work.
Json 2 DTO Spatie's Data Transfer Object library is awesome, but typing out DTOs can quickly become a chore. Inspired by Json2Typescript style tools,
CakeDC Auth Objects is a refactor of the existing Auth objects present in the CakeDC Users Plugin, to let anyone else use them in their projects.
CLIFramework CLIFramework is a command-line application framework, for building flexiable, simple command-line applications. Commands and Subcommands
Laravel Value Objects A bunch of general-purpose value objects you can use in your Laravel application. The package requires PHP ^8.0 and Laravel ^9.7
Talkino Welcome to our GitHub Repository Talkino is a click to chat plugin to show your agents’ multiple social messengers, phone and emails on the ch
DynamoDB Storable This component, based on the Symfony serializer and async-aws, is a human-readable and quick abstraction to easily store serialized
nixihz/php-object Allows generate class files parse from json and map json to php object, including multi-level and complex objects; Installation You