GithubHelp home page GithubHelp logo

commonphp / di Goto Github PK

View Code? Open in Web Editor NEW
6.0 6.0 0.0 66 KB

Lightweight and easy-to-use dependency injection library for PHP to simplify object management and promote loose coupling.

License: Other

PHP 100.00%
commonphp dependency-injection design-patterns di di-container loose-coupling object-management object-oriented-programming php php8 service-container

di's People

Contributors

tlmcclatchey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

di's Issues

Move all service-related tasks to a standalone library

We are planning to better organize our codebase by creating clear separations of concern. As part of this, we intend to move all service-related tasks to a standalone library.

Current State:

Currently, service-related tasks such as managing service providers and service collections are spread across different parts of our codebase, including the Dependency Injector (DI). This mixing of responsibilities makes the code harder to understand and maintain.

Expected Changes:

Identify all service-related tasks currently present in the codebase.
Design and develop a new standalone Service Library to manage these tasks.
Refactor the existing code to delegate these tasks to the new Service Library.
Expected Benefits:

Clear separation of concerns, enhancing maintainability and understandability of the code.
Isolation of service-related tasks in a dedicated library will make it easier to extend and improve our service management functionality.
Future developers can easily locate and understand service-related tasks, speeding up the development process.

Enhance Type Hinting for Improved Autocompletion in IDEs

When using the instantiate method from the DependencyInjector class, the return object's class-specific methods are not readily available in the autocomplete suggestions of the IDE. This behavior may hinder the ease of use and speed of development for users of the library.

The goal of this issue is to improve type hinting in the instantiate method. By using PHPDoc annotations that employ templates, we can provide better support for autocomplete features in IDEs. This way, developers will have access to method suggestions based on the specific class being instantiated, leading to a faster and more accurate code writing experience.

Please note that this change will not affect the actual functionality of the instantiate method, but is intended to enhance the user experience for developers.

Implement Unit Tests

Implement unit tests to validate the functionality of the libraries and to prevent regressions.

Explore the need for ADRs

Explore the use of Architectural Decision Records (ADRs) in the project to document the rationale behind design decisions.

Remove service-related tasks from the DI

In an effort to clearly delineate the responsibilities of the Dependency Injector (DI) and the Service Container, this issue aims to refactor the DI to remove all service-related tasks. The goal is to ensure that the DI focuses on its core function: analyzing dependencies and injecting them as needed.

Current State:

The DI currently has responsibilities that overlap with what should be part of the Service Container, such as managing service providers and service collections. This blurs the boundaries of the DI's responsibility and potentially makes the code harder to maintain and understand.

Expected Changes:

Move the management of service providers to the Service Container. Any method related to service providers in the DI should be relocated and refactored as necessary.
The DI's ServiceCollection should be refactored into a more general ObjectPool or equivalent that only deals with objects, not services.
Expected Benefits:

Clear separation of concerns between the DI and Service Container, enhancing maintainability.
Improved understandability of the code, as each class has a well-defined role.
Paves the way for enhancing and expanding the capabilities of the Service Container.

Refactor 'Collections' Namespace to 'Support'

As part of an ongoing effort to make our codebase more understandable and accurate, we should refactor the CommonPHP\DependencyInjection\Collections namespace to CommonPHP\DependencyInjection\Support. This new naming more accurately represents the purpose of the classes within this namespace.

In the process, we should also move the InstantiationStack class to this newly named namespace.

Acceptance Criteria:
All references to classes in the CommonPHP\DependencyInjection\Collections namespace in the codebase should be updated to CommonPHP\DependencyInjection\Support
InstantiationStack should be moved to CommonPHP\DependencyInjection\Support\InstantiationStack, with all references updated accordingly.

PSR-11 Compliance

Evaluate the Service Container's compliance with the PSR-11 standard. Make necessary modifications to ensure it meets the standard.

Introduce 'delegate' method to ValueFinder or DependencyInjector

A recommendation was made to have a method available that allows a callback to be responsible for the creation of a specific class. This could technically be done by a service provider in the service-management library, however, that's better suited for a type of class (has interface, has attribute, etc) but is heavy impact performance-wise if it needs to iterate through multiple theoretical nested loops just to find the specific class name.

'delegate' would instruct the DI to use the provided callback for the instantiating of a class, which would pass class name, parameters and instance of the $DI as parameters

Create Contributing Guide

Create a CONTRIBUTING.md guide to help prospective contributors understand how they can help with the project.

Enhance Documentation

Improve code comments and README to provide more clarity on how to use the library. Consider adding guides, examples, and API documentation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.