The DependencyInjection component allows you to standardize and centralize the way objects are constructed in your application.

Overview
Comments
  • XmlDumper doesn't write factory-class attribute.

    XmlDumper doesn't write factory-class attribute.

    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.

    opened by kerdany 2
  • Allow get parameters by path, separated by colon

    Allow get parameters by path, separated by colon

    For example:

    app/config/parameters.yml

    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.

    opened by bocharsky-bw 2
  • Problem with unescaping class arguments

    Problem with unescaping class arguments

    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.

    opened by avorobiev 2
  • Optimization of resolveEnvPlaceholders

    Optimization of resolveEnvPlaceholders

    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.

    opened by sveneld 1
  • [DependencyInjection] Extend TaggedIterator and TaggedLocator Attributes with able to specify defaultIndexMethod for !tagged_iterator or ServiceLocator

    [DependencyInjection] Extend TaggedIterator and TaggedLocator Attributes with able to specify defaultIndexMethod for !tagged_iterator or ServiceLocator

    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:

    • \ Symfony \ Component \ DependencyInjection \ Attribute \ TaggedIterator
    • \ Symfony \ Component \ DependencyInjection \ Attribute \ TaggedLocator
    opened by fractalzombie 1
  • Update PhpDumper.php exception

    Update PhpDumper.php exception

    ParameterBagInterface has comment on get method: @throws ParameterNotFoundException if the parameter is not defined but InvalidArgumentException is thrown.

    opened by madkot 1
  • [DI] Add typehints to include() method signature

    [DI] Add typehints to include() method signature

    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====================
    
    opened by CoeusCC 1
  • Fixed Dumper for used container build time

    Fixed Dumper for used container build time

    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.

    opened by lpoczatek 1
  • Add gitattributes to exclude files and folders from exports

    Add gitattributes to exclude files and folders from exports

    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

    opened by pavlakis 1
  • Proposed feature: getServiceMock()

    Proposed feature: getServiceMock()

    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.

    opened by blockjon 1
  • Improved the ParameterBagInterface.

    Improved the ParameterBagInterface.

    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 | |

    opened by tomazahlin 1
Releases(v6.2.3)
  • v6.2.3(Dec 28, 2022)

    Changelog (https://github.com/symfony/dependency-injection/compare/v6.2.2...v6.2.3)

    • bug #48805 Fix resolving parameters when dumping lazy proxies (nicolas-grekas)
    • bug #48791 Fix deduplicating service instances in circular graphs (nicolas-grekas)
    Source code(tar.gz)
    Source code(zip)
  • v6.1.9(Dec 28, 2022)

    Changelog (https://github.com/symfony/dependency-injection/compare/v6.1.8...v6.1.9)

    • bug #48791 Fix deduplicating service instances in circular graphs (nicolas-grekas)
    • bug #48591 Shared private services becomes public after a public service is accessed (alexpott)
    • bug #48482 Revert "bug #48027 Don't autoconfigure tag when it's already set with attributes" (nicolas-grekas)
    Source code(tar.gz)
    Source code(zip)
  • v6.0.17(Dec 28, 2022)

    Changelog (https://github.com/symfony/dependency-injection/compare/v6.0.16...v6.0.17)

    • bug #48791 Fix deduplicating service instances in circular graphs (nicolas-grekas)
    • bug #48591 Shared private services becomes public after a public service is accessed (alexpott)
    • bug #48482 Revert "bug #48027 Don't autoconfigure tag when it's already set with attributes" (nicolas-grekas)
    Source code(tar.gz)
    Source code(zip)
  • v5.4.17(Dec 28, 2022)

    Changelog (https://github.com/symfony/dependency-injection/compare/v5.4.16...v5.4.17)

    • bug #48791 Fix deduplicating service instances in circular graphs (nicolas-grekas)
    • bug #48591 Shared private services becomes public after a public service is accessed (alexpott)
    • bug #48482 Revert "bug #48027 Don't autoconfigure tag when it's already set with attributes" (nicolas-grekas)
    Source code(tar.gz)
    Source code(zip)
  • v6.2.2(Dec 16, 2022)

    Changelog (https://github.com/symfony/dependency-injection/compare/v6.2.1...v6.2.2)

    • bug #48591 Shared private services becomes public after a public service is accessed (alexpott)
    • bug #48449 Fix bug when tag name is a text node (BrandonlinU)
    • bug #48522 Generate different classes for ghost objects and virtual proxies (nicolas-grekas)
    • bug #48482 Revert "bug #48027 Don't autoconfigure tag when it's already set with attributes" (nicolas-grekas)
    Source code(tar.gz)
    Source code(zip)
  • v6.2.1(Dec 6, 2022)

    Changelog (https://github.com/symfony/dependency-injection/compare/v6.2.0...v6.2.1)

    • bug #48502 Fix ContainerBuilder stats env usage with enum (alamirault)
    • bug #48483 Remove refs that point to container.excluded services when allowed (nicolas-grekas)
    • bug #48461 Fix possible memory-leak when using lazy-objects (nicolas-grekas)
    Source code(tar.gz)
    Source code(zip)
  • v6.2.0(Nov 30, 2022)

  • v6.1.8(Nov 28, 2022)

    Changelog (https://github.com/symfony/dependency-injection/compare/v6.1.7...v6.1.8)

    • bug #48224 Process bindings in ServiceLocatorTagPass (MatTheCat)
    • bug #48093 don't move locator tag for service subscriber (RobertMe)
    • bug #48027 Don't autoconfigure tag when it's already set with attributes (nicolas-grekas)
    Source code(tar.gz)
    Source code(zip)
  • v6.0.16(Nov 28, 2022)

    Changelog (https://github.com/symfony/dependency-injection/compare/v6.0.15...v6.0.16)

    • bug #48224 Process bindings in ServiceLocatorTagPass (MatTheCat)
    • bug #48093 don't move locator tag for service subscriber (RobertMe)
    • bug #48027 Don't autoconfigure tag when it's already set with attributes (nicolas-grekas)
    Source code(tar.gz)
    Source code(zip)
  • v5.4.16(Nov 28, 2022)

    Changelog (https://github.com/symfony/dependency-injection/compare/v5.4.15...v5.4.16)

    • bug #48224 Process bindings in ServiceLocatorTagPass (MatTheCat)
    • bug #48093 don't move locator tag for service subscriber (RobertMe)
    • bug #48027 Don't autoconfigure tag when it's already set with attributes (nicolas-grekas)
    Source code(tar.gz)
    Source code(zip)
  • v4.4.49(Nov 28, 2022)

    Changelog (https://github.com/symfony/dependency-injection/compare/v4.4.48...v4.4.49)

    • bug #48224 Process bindings in ServiceLocatorTagPass (MatTheCat)
    • bug #48093 don't move locator tag for service subscriber (RobertMe)
    Source code(tar.gz)
    Source code(zip)
  • v6.2.0-RC1(Nov 25, 2022)

    Changelog (https://github.com/symfony/dependency-injection/compare/v6.2.0-BETA3...v6.2.0-RC1)

    • bug #48224 Process bindings in ServiceLocatorTagPass (MatTheCat)
    Source code(tar.gz)
    Source code(zip)
  • v6.2.0-BETA3(Nov 19, 2022)

    Changelog (https://github.com/symfony/dependency-injection/compare/v6.2.0-BETA2...v6.2.0-BETA3)

    • bug #48093 don't move locator tag for service subscriber (RobertMe)
    • feature #48045 Allow enum as service parameter in php config files (alexndlm)
    • bug #48027 Don't autoconfigure tag when it's already set with attributes (nicolas-grekas)
    Source code(tar.gz)
    Source code(zip)
  • v6.2.0-BETA1(Oct 24, 2022)

    Changelog (https://github.com/symfony/dependency-injection/compare/v6.1.6...v6.2.0-BETA1)

    • feature #47364 Allow array attributes for service tags (aschempp)
    • feature #47906 Allow injecting the current env into php config closures (HypeMC)
    • feature #47902 Add support for tagged iterators/locators exclude option to xml and yaml (HypeMC)
    • feature #47801 Allow array for the value of Autowire attribute (willemverspyck)
    • feature #47730 Ban DateTime from the codebase (WebMamba)
    • feature #47683 Deprecate numeric parameter names (HeahDude)
    • feature #38996 Remove the default values from setters with a nullable parameter (derrabus, nicolas-grekas)
    • feature #47236 Generate lazy-loading virtual proxies for non-ghostable lazy services (nicolas-grekas)
    • feature #47367 Handle INI arrays (MatTheCat)
    • feature #47101 Allow service subscribers to return SubscribedService[] (kbond)
    • feature #47196 Allow extending #[When] attribute (ruudk)
    • feature #46821 Add resolve-env option to debug:config command (alexandre-daubois)
    • feature #46752 Use lazy-loading ghost object proxies out of the box (nicolas-grekas)
    • feature #46883 Add shuffle env processor (ostrolucky)
    • feature #46564 Add Enum Env Var Processor (jack-worman)
    • feature #46741 Allow using ghost objects for lazy loading services (nicolas-grekas)
    • feature #46614 Remove Debug component leftovers (chalasr)
    Source code(tar.gz)
    Source code(zip)
  • v6.1.5(Sep 30, 2022)

    Changelog (https://github.com/symfony/dependency-injection/compare/v6.1.4...v6.1.5)

    • bug #47635 EnvPlaceholderParameterBag::get() can't return UnitEnum (jack.shpartko)
    Source code(tar.gz)
    Source code(zip)
  • v6.0.13(Sep 30, 2022)

    Changelog (https://github.com/symfony/dependency-injection/compare/v6.0.12...v6.0.13)

    • bug #47635 EnvPlaceholderParameterBag::get() can't return UnitEnum (jack.shpartko)
    Source code(tar.gz)
    Source code(zip)
  • v5.4.13(Sep 30, 2022)

  • v6.1.3(Jul 29, 2022)

    Changelog (https://github.com/symfony/dependency-injection/compare/v6.1.2...v6.1.3)

    • bug #46973 Fail gracefully when attempting to autowire composite types (derrabus)
    • bug #46800 Spaces in system temp folder path cause deprecation errors in php 8 (demeritcowboy)
    Source code(tar.gz)
    Source code(zip)
  • v6.0.11(Jul 29, 2022)

    Changelog (https://github.com/symfony/dependency-injection/compare/v6.0.10...v6.0.11)

    • bug #46973 Fail gracefully when attempting to autowire composite types (derrabus)
    • bug #46800 Spaces in system temp folder path cause deprecation errors in php 8 (demeritcowboy)
    Source code(tar.gz)
    Source code(zip)
  • v5.4.11(Jul 29, 2022)

    Changelog (https://github.com/symfony/dependency-injection/compare/v5.4.10...v5.4.11)

    • bug #46973 Fail gracefully when attempting to autowire composite types (derrabus)
    • bug #46800 Spaces in system temp folder path cause deprecation errors in php 8 (demeritcowboy)
    Source code(tar.gz)
    Source code(zip)
  • v4.4.44(Jul 29, 2022)

    Changelog (https://github.com/symfony/dependency-injection/compare/v4.4.43...v4.4.44)

    • bug #46973 Fail gracefully when attempting to autowire composite types (derrabus)
    • bug #46800 Spaces in system temp folder path cause deprecation errors in php 8 (demeritcowboy)
    Source code(tar.gz)
    Source code(zip)
  • v6.1.2(Jun 26, 2022)

  • v6.0.10(Jun 26, 2022)

  • v5.4.10(Jun 26, 2022)

  • v4.4.43(Jun 26, 2022)

  • v6.1.0(May 27, 2022)

    Changelog (https://github.com/symfony/dependency-injection/compare/v6.1.0-RC1...v6.1.0)

    • bug #46448 Fix "proxy" tag: resolve its parameters and pass it to child definitions (nicolas-grekas)
    • bug #46427 fix wiring of annotations.cached_reader (nicolas-grekas)
    • bug #46425 Ignore unused bindings defined by attribute (nicolas-grekas)
    Source code(tar.gz)
    Source code(zip)
  • v6.0.9(May 27, 2022)

    Changelog (https://github.com/symfony/dependency-injection/compare/v6.0.8...v6.0.9)

    • bug #46448 Fix "proxy" tag: resolve its parameters and pass it to child definitions (nicolas-grekas)
    • bug #46427 fix wiring of annotations.cached_reader (nicolas-grekas)
    • bug #46425 Ignore unused bindings defined by attribute (nicolas-grekas)
    • bug #46276 Fix lazyness of AutowiringFailedException (nicolas-grekas)
    Source code(tar.gz)
    Source code(zip)
  • v5.4.9(May 27, 2022)

    Changelog (https://github.com/symfony/dependency-injection/compare/v5.4.8...v5.4.9)

    • bug #46448 Fix "proxy" tag: resolve its parameters and pass it to child definitions (nicolas-grekas)
    • bug #46427 fix wiring of annotations.cached_reader (nicolas-grekas)
    • bug #46425 Ignore unused bindings defined by attribute (nicolas-grekas)
    Source code(tar.gz)
    Source code(zip)
  • v4.4.42(May 27, 2022)

    Changelog (https://github.com/symfony/dependency-injection/compare/v4.4.41...v4.4.42)

    • bug #46448 Fix "proxy" tag: resolve its parameters and pass it to child definitions (nicolas-grekas)
    • bug #46427 fix wiring of annotations.cached_reader (nicolas-grekas)
    Source code(tar.gz)
    Source code(zip)
  • v6.1.0-RC1(May 14, 2022)

    Changelog (https://github.com/symfony/dependency-injection/compare/v6.1.0-BETA2...v6.1.0-RC1)

    • bug #46276 Fix lazyness of AutowiringFailedException (nicolas-grekas)
    • bug #46272 Fix resolving parameters found in #[Autowire] (nicolas-grekas)
    Source code(tar.gz)
    Source code(zip)
Configure your Nette application

Nette DI Configure your Nette application ?? Check out our documentation. ?? If you like Orisai, please make a donation. Thank you! namespace App; us

Orisai 4 Dec 14, 2022
💎 Flexible, compiled and full-featured Dependency Injection Container with perfectly usable autowiring and support for all new PHP 7 features.

Nette Dependency Injection (DI) Introduction Purpose of the Dependecy Injection (DI) is to free classes from the responsibility for obtaining objects

Nette Foundation 781 Dec 15, 2022
🚀 PHP Service Container with fast and cachable dependency injection.

ClanCats Container A PHP Service Container featuring a simple meta-language with fast and compilable dependency injection. Requires PHP >= 7.0 Pros: M

ClanCats 28 Apr 13, 2022
Twittee is the smallest, and still useful, Dependency Injection Container in PHP

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

null 133 Dec 5, 2022
This package aims to help you standardize all your API responses in a simple and structured way.

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

Kode Pandai 6 Dec 6, 2022
Collection of classes you can use to standardize data formats in your Laravel application.

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

Michael Rubel 88 Dec 23, 2022
YCOM Impersonate. Login as selected YCOM user 🧙‍♂️in frontend.

YCOM Impersonate Login as selected YCOM user in frontend. Features: Backend users with admin rights or YCOM[] rights, can be automatically logged in v

Friends Of REDAXO 17 Sep 12, 2022
PHP package to make your objects strict and throw exception when you try to access or set some undefined property in your objects.

?? 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

Zeeshan Ahmad 20 Dec 8, 2018
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.DeepEqual().

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

Joubert RedRat 4 Feb 12, 2022
Validate your input data in a simple way, an easy way and right way. no framework required. For simple or large. project.

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

Boss 4 Dec 17, 2022
:date: The VObject library for PHP allows you to easily parse and manipulate iCalendar and vCard objects

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

sabre.io 532 Dec 25, 2022
Creating data transfer objects with the power of php objects. No php attributes, no reflection api, and no other under the hook work.

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.

Mohammed Manssour 8 Jun 8, 2023
Generate Data Transfer Objects directly from JSON objects

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,

null 111 Jan 3, 2023
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.

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.

Cake Development Corporation 24 Sep 23, 2022
A powerful command line application framework for PHP. It's an extensible, flexible component, You can build your command-based application in seconds!

CLIFramework CLIFramework is a command-line application framework, for building flexiable, simple command-line applications. Commands and Subcommands

Yo-An Lin 428 Dec 13, 2022
A bunch of general-purpose value objects you can use in your Laravel application.

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

Michael Rubél 136 Jan 4, 2023
Talkino allows you to integrate multi social messengers and contact into your website and enable your users to contact you using multi social messengers' accounts.

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

Traxconn 2 Sep 21, 2022
This component, based on the Symfony serializer and async-aws, is a human-readable and quick abstraction to easily store serialized objects in DynamoDB 🚀.

DynamoDB Storable This component, based on the Symfony serializer and async-aws, is a human-readable and quick abstraction to easily store serialized

Matthieu W. 2 Jun 19, 2022
Allows generate class files parse from json and map json to php object, including multi-level and complex objects;

nixihz/php-object Allows generate class files parse from json and map json to php object, including multi-level and complex objects; Installation You

zhixin 2 Sep 9, 2022