Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,28 @@
"ext-curl": "*",
"ext-json": "*",
"neuron-php/mvc": "0.9.*",
"neuron-php/routing": "0.8.*",
"neuron-php/data": "0.9.*",
"neuron-php/cli": "0.8.*",
"neuron-php/jobs": "0.2.*",
"neuron-php/orm": "0.1.*",
"neuron-php/dto": "0.0.*",
"phpmailer/phpmailer": "^6.9",
"cloudinary/cloudinary_php": "^2.0",
"php-di/php-di": "^7.1"
"php-di/php-di": "^7.1",
"symfony/yaml": "^6.4"
},
"require-dev": {
"phpunit/phpunit": "9.*",
"mikey179/vfsstream": "^1.6",
"neuron-php/scaffolding": "0.8.*",
"phpstan/phpstan": "^1.10",
"phpstan/extension-installer": "^1.3",
"infection/infection": "^0.32.0"
"infection/infection": "^0.32.0",
Comment thread
cursor[bot] marked this conversation as resolved.
"codeception/codeception": "^5.3",
"codeception/module-phpbrowser": "^3.0",
"codeception/module-asserts": "^3.2",
"codeception/module-db": "^3.2"
},
"autoload": {
"psr-4": {
Expand Down
28 changes: 27 additions & 1 deletion docs/DEPENDENCY_INJECTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,35 @@

The NeuronPHP framework includes a PSR-11 compatible dependency injection container for managing dependencies and promoting loose coupling.

## Service Configuration

**NEW:** Services are now configured via YAML files for better maintainability and separation of concerns.

See [Service Configuration Guide](SERVICE_CONFIGURATION.md) for complete documentation on YAML-based service configuration.

## Quick Start

### 1. Bootstrap the Container

In your application bootstrap (e.g., `public/index.php`):
The container is automatically bootstrapped in `src/Bootstrap.php`:

```php
<?php

use Neuron\Cms\Container\Container;

// Container automatically loads services from resources/config/services.yaml
$container = Container::build($settings, $environment);

// Container is automatically set on the application
$app->setContainer($container);
```

**That's it!** All services defined in `services.yaml` are available for injection.

### 2. Alternative: Manual Bootstrap (Legacy)

For backward compatibility, you can still use the service provider approach:

```php
<?php
Expand All @@ -25,6 +49,8 @@ $provider->register($container);
$app->setContainer($container);
```

**Note:** This approach is deprecated in favor of YAML configuration.

### 2. Use Dependency Injection in Controllers

**Before (Service Locator Anti-Pattern):**
Expand Down
Loading