Skip to content

Commit ed25f50

Browse files
author
symfony-flex-server[bot]
authored
Merge pull request #721
2 parents 9880918 + 8da7d03 commit ed25f50

File tree

6 files changed

+93
-4
lines changed

6 files changed

+93
-4
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
use App\Kernel;
4+
use Symfony\Bundle\FrameworkBundle\Routing\Loader\Configurator\RoutingConfigurator;
5+
6+
return static function (RoutingConfigurator $routes, Kernel $kernel): void {
7+
8+
// $routes->add('index', '/')
9+
// ->controller([App\Controller\DefaultController::class, 'index'])
10+
// ;
11+
12+
};
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
3+
use App\Kernel;
4+
use Symfony\Component\DependencyInjection\Loader\Configurator as di;
5+
6+
// This file is the entry point to configure your own services.
7+
// Files in the packages/ subdirectory configure your dependencies.
8+
9+
return static function (di\ContainerConfigurator $container, Kernel $kernel): void {
10+
11+
// Parameters are configuration that don't need to change depending on the machine where the app is deployed.
12+
// see https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
13+
$container->parameters()
14+
// ->set(...)
15+
;
16+
17+
$services = $container->services()
18+
->defaults()
19+
->autowire()
20+
->autoconfigure()
21+
;
22+
23+
// Makes classes in src/ available to be used as services
24+
$src = dirname(__DIR__).'/src';
25+
$services
26+
->load('App\\', $src)
27+
->exclude([
28+
$src.'/DependencyInjection',
29+
$src.'/Entity',
30+
$src.'/Migrations',
31+
$src.'/Tests',
32+
$src.'/Kernel.php',
33+
])
34+
;
35+
36+
// Controllers are imported separately to make sure services can be injected
37+
// as action arguments even if you don't extend any base controller class
38+
$services
39+
->load('App\\Controller\\', $src.'/Controller')
40+
->tag('controller.service_arguments')
41+
;
42+
43+
// Add more service definitions when explicit configuration is needed.
44+
// Please note that last definitions *replace* previous ones when using $services->set().
45+
// It is possible to alter a previously declared definition by using $services->get() instead.
46+
$services
47+
// ->set(App\MyService::class)
48+
// ->args([di\ref(App\AnotherService::class)])
49+
;
50+
51+
if ('test' === $kernel->getEnvironment()) {
52+
// When a test case needs access to a service, getting it via
53+
// a public alias with the "test." prefix is recommended.
54+
$services->public()
55+
// ->alias('test.App\MyService', App\MyService::class)
56+
;
57+
}
58+
59+
};

symfony/framework-bundle/5.1/config/services.yaml

Lines changed: 0 additions & 1 deletion
This file was deleted.

symfony/framework-bundle/5.1/src/Kernel.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,26 @@ protected function configureContainer(ContainerConfigurator $container): void
1515
{
1616
$container->import('../config/{packages}/*.yaml');
1717
$container->import('../config/{packages}/'.$this->environment.'/*.yaml');
18-
$container->import('../config/{services}.yaml');
19-
$container->import('../config/{services}_'.$this->environment.'.yaml');
18+
19+
if (file_exists(\dirname(__DIR__).'/config/services.yaml')) {
20+
$container->import('../config/{services}.yaml');
21+
$container->import('../config/{services}_'.$this->environment.'.yaml');
22+
} else {
23+
$path = \dirname(__DIR__).'/config/services.php';
24+
(require $path)($container->withPath($path), $this);
25+
}
2026
}
2127

2228
protected function configureRoutes(RoutingConfigurator $routes): void
2329
{
2430
$routes->import('../config/{routes}/'.$this->environment.'/*.yaml');
2531
$routes->import('../config/{routes}/*.yaml');
26-
$routes->import('../config/{routes}.yaml');
32+
33+
if (file_exists(\dirname(__DIR__).'/config/routes.yaml')) {
34+
$routes->import('../config/{routes}.yaml');
35+
} else {
36+
$path = \dirname(__DIR__).'/config/routes.php';
37+
(require $path)($routes->withPath($path), $this);
38+
}
2739
}
2840
}

symfony/routing/5.1/config/packages

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../4.2/config/packages/

symfony/routing/5.1/manifest.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"copy-from-recipe": {
3+
"config/": "%CONFIG_DIR%/"
4+
},
5+
"aliases": ["router"]
6+
}

0 commit comments

Comments
 (0)