You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
echo $container->get("test3"); // Will echo @TestClass::_get()
10
+
$container->set("YourClass", \YourNamespace\To\YourClass::class); // Bind "YourClass" to container and dependency injector
11
+
$yourClass = $container->get("YourClass")->get(); // Will return "YourClass"
12
+
//$yourClass->yourClassMehthod();
19
13
```
14
+
If the constructor of "YourClass" contains unresolved class arguments, the dependency injector will attempt to automatically locate them for you. Read more under the headline **dependency injector**.
15
+
20
16
## Factory
21
17
Factories can be used to create new instances of objects, rather than instantiating them directly in your code.
22
18
```php
@@ -35,24 +31,24 @@ You can use the **Dependency injector** just like create any other container, as
35
31
Take a look at this example
36
32
37
33
```php
38
-
use MaplePHP\Container\tests\TestClasses\TestClass;
39
-
$container->set("uniqueKey", TestClass:class);
40
-
// $container->set("uniqueKey", '\MaplePHP\Container\tests\Controllers\TestController'); // Same as above
0 commit comments