Skip to content

Commit 69b3e63

Browse files
authored
Update dependency-injection.md
1 parent e3c8b1e commit 69b3e63

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

docs/book/v5/core-features/dependency-injection.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
# Dependency Injection
22

3-
Dependency injection is a design pattern used in software development to implement inversion of control or in simple
4-
terms is the act of providing dependencies for an object during instantiation.
3+
Dependency injection is a design pattern used in software development to implement inversion of control. In simpler
4+
terms, it's the act of providing dependencies for an object during instantiation.
55

6-
In PHP, dependency injection can be implemented in various ways, including through **constructor** injection, setter
7-
injection, and property injection.
6+
In PHP, dependency injection can be implemented in various ways, including through constructor injection, setter
7+
injection and property injection.
88

9-
DotKernel API, through it's [dot-dependency-injection](https://github.com/dotkernel/dot-dependency-injection) package
9+
DotKernel API, through its [dot-dependency-injection](https://github.com/dotkernel/dot-dependency-injection) package
1010
focuses only on constructor injection.
1111

1212
## Usage
1313

14-
**DotKernel API** comes out of the box with
14+
**DotKernel API** comes out of the box with the
1515
[dot-dependency-injection](https://github.com/dotkernel/dot-dependency-injection) package, which provides all we need for
16-
injecting dependencies in any object you want.
16+
injecting dependencies into any object you want.
1717

1818
`dot-dependency-injection` determines the dependencies by looking at the `#[Inject]` attribute, added to the constructor
1919
of a class. Dependencies are specified as separate parameters of the `#[Inject]` attribute.
2020

21-
For our example we will inject a `UserService` and `config` dependencies in a `UseHandler`.
21+
For our example we will inject `UserService` and `config` dependencies into a `UseHandler`.
2222

2323
```php
2424
use Dot\DependencyInjection\Attribute\Inject;
@@ -40,7 +40,7 @@ class UserHandler implements RequestHandlerInterface
4040
> If your class needs the value of a specific configuration key, you can specify the path using dot notation:
4141
> `config.example`
4242
43-
After, register the class in the `ConfigProvider`, under `factories`, using
43+
The next step is to register the class in the `ConfigProvider` under `factories` using
4444
`Dot\DependencyInjection\Factory\AttributedServiceFactory::class`
4545

4646
```php
@@ -54,8 +54,8 @@ public function getDependencies(): array
5454
}
5555
```
5656

57-
That's it. By registering this, when your object will be instantiated from the container, it will automatically have its
57+
That's it. When your object is instantiated from the container, it will automatically have its
5858
dependencies resolved.
5959

60-
> Dependencies injection applies to any object within DotKernel API. For example, you could inject dependencies in a
61-
> service, a handler and so on, just need to register it in the `ConfigProvider`
60+
> Dependencies injection is available to any object within DotKernel API. For example, you can inject dependencies in a
61+
> service, a handler and so on, simply by registering it in the `ConfigProvider`.

0 commit comments

Comments
 (0)