PHP code example of tourze / symfony-dependency-service-loader

1. Go to this page and download the library: Download tourze/symfony-dependency-service-loader library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tourze / symfony-dependency-service-loader example snippets




namespace App\DependencyInjection;

use Tourze\SymfonyDependencyServiceLoader\AutoExtension;

final class MyBundleExtension extends AutoExtension
{
    /**
     * 返回配置文件目录路径
     */
    protected function getConfigDir(): string
    {
        return __DIR__ . '/../Resources/config';
    }
}



namespace App\DependencyInjection;

use Tourze\SymfonyDependencyServiceLoader\AppendDoctrineConnectionExtension;

class MyDoctrineBundleExtension extends AppendDoctrineConnectionExtension
{
    protected function getConfigDir(): string
    {
        return __DIR__ . '/../Resources/config';
    }

    /**
     * 返回 Doctrine 连接名称
     */
    protected function getDoctrineConnectionName(): string
    {
        return 'my_connection';
    }
}

MyBundle/
├── DependencyInjection/
│   └── MyBundleExtension.php
└── Resources/
    └── config/
        ├── services.yaml
        ├── services_dev.yaml
        └── services_test.yaml