-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #119 from pamil/1.3-sf4-structure
Introduce Symfony 4 directory structure
- Loading branch information
Showing
81 changed files
with
803 additions
and
248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,8 @@ | ||
/bin/* | ||
!/bin/.gitkeep | ||
|
||
/vendor/ | ||
/node_modules/ | ||
/composer.lock | ||
|
||
/etc/build/* | ||
!/etc/build/.gitkeep | ||
!/etc/build/.gitignore | ||
|
||
/tests/Application/yarn.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# This file is a "template" of which env vars needs to be defined in your configuration or in an .env file | ||
# Set variables here that may be different on each deployment target of the app, e.g. development, staging, production. | ||
# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration | ||
|
||
###> symfony/framework-bundle ### | ||
APP_ENV=dev | ||
APP_DEBUG=1 | ||
APP_SECRET=EDITME | ||
###< symfony/framework-bundle ### | ||
|
||
###> doctrine/doctrine-bundle ### | ||
# Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url | ||
# For a sqlite database, use: "sqlite:///%kernel.project_dir%/var/data.db" | ||
# Set "serverVersion" to your server version to avoid edge-case exceptions and extra database calls | ||
DATABASE_URL=mysql://[email protected]/sylius_%kernel.environment%?serverVersion=5.5 | ||
###< doctrine/doctrine-bundle ### | ||
|
||
###> symfony/swiftmailer-bundle ### | ||
# For Gmail as a transport, use: "gmail://username:password@localhost" | ||
# For a generic SMTP server, use: "smtp://localhost:25?encryption=&auth_mode=" | ||
# Delivery is disabled by default via "null://localhost" | ||
MAILER_URL=smtp://localhost | ||
###< symfony/swiftmailer-bundle ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# This file is a "template" of which env vars needs to be defined in your configuration or in an .env file | ||
# Set variables here that may be different on each deployment target of the app, e.g. development, staging, production. | ||
# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration | ||
|
||
###> symfony/framework-bundle ### | ||
APP_ENV=prod | ||
APP_DEBUG=0 | ||
APP_SECRET=EDITME | ||
###< symfony/framework-bundle ### | ||
|
||
###> doctrine/doctrine-bundle ### | ||
# Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url | ||
# For a sqlite database, use: "sqlite:///%kernel.project_dir%/var/data.db" | ||
# Set "serverVersion" to your server version to avoid edge-case exceptions and extra database calls | ||
DATABASE_URL=mysql://[email protected]/sylius_%kernel.environment%?serverVersion=5.5 | ||
###< doctrine/doctrine-bundle ### | ||
|
||
###> symfony/swiftmailer-bundle ### | ||
# For Gmail as a transport, use: "gmail://username:password@localhost" | ||
# For a generic SMTP server, use: "smtp://localhost:25?encryption=&auth_mode=" | ||
# Delivery is disabled by default via "null://localhost" | ||
MAILER_URL=smtp://localhost | ||
###< symfony/swiftmailer-bundle ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# This file is a "template" of which env vars needs to be defined in your configuration or in an .env file | ||
# Set variables here that may be different on each deployment target of the app, e.g. development, staging, production. | ||
# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration | ||
|
||
###> symfony/framework-bundle ### | ||
APP_ENV=test | ||
APP_DEBUG=1 | ||
APP_SECRET=EDITME | ||
###< symfony/framework-bundle ### | ||
|
||
###> doctrine/doctrine-bundle ### | ||
# Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url | ||
# For a sqlite database, use: "sqlite:///%kernel.project_dir%/var/data.db" | ||
# Set "serverVersion" to your server version to avoid edge-case exceptions and extra database calls | ||
DATABASE_URL=mysql://[email protected]/sylius_%kernel.environment%?serverVersion=5.5 | ||
###< doctrine/doctrine-bundle ### | ||
|
||
###> symfony/swiftmailer-bundle ### | ||
# For Gmail as a transport, use: "gmail://username:password@localhost" | ||
# For a generic SMTP server, use: "smtp://localhost:25?encryption=&auth_mode=" | ||
# Delivery is disabled by default via "null://localhost" | ||
MAILER_URL=null://localhost | ||
###< symfony/swiftmailer-bundle ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,17 @@ | ||
/node_modules/ | ||
|
||
/var/* | ||
!/var/.gitkeep | ||
!/var/.gitignore | ||
|
||
/public/assets | ||
/public/bundles | ||
/public/css | ||
/public/js | ||
/public/media | ||
|
||
/vendor | ||
/node_modules | ||
|
||
/web/* | ||
!/web/assets/.gitkeep | ||
!/web/bundles/.gitkeep | ||
!/web/media/image/.gitkeep | ||
!/web/app.php | ||
!/web/app_dev.php | ||
!/web/app_test.php | ||
/.env | ||
/.env.prod | ||
/.env.staging | ||
/.env.test | ||
/.env.test_cached |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\Acme\SyliusExamplePlugin\Application; | ||
|
||
use ProxyManager\Proxy\VirtualProxyInterface; | ||
use PSS\SymfonyMockerContainer\DependencyInjection\MockerContainer; | ||
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; | ||
use Symfony\Component\Config\Loader\LoaderInterface; | ||
use Symfony\Component\Config\Resource\FileResource; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\ContainerInterface; | ||
use Symfony\Component\HttpKernel\Kernel as BaseKernel; | ||
use Symfony\Component\Routing\RouteCollectionBuilder; | ||
|
||
final class Kernel extends BaseKernel | ||
{ | ||
use MicroKernelTrait; | ||
|
||
private const CONFIG_EXTS = '.{php,xml,yaml,yml}'; | ||
|
||
private const IGNORED_SERVICES_DURING_CLEANUP = [ | ||
'kernel', | ||
'http_kernel', | ||
'liip_imagine.mime_type_guesser', | ||
'liip_imagine.extension_guesser', | ||
]; | ||
|
||
public function getCacheDir(): string | ||
{ | ||
return $this->getProjectDir() . '/var/cache/' . $this->environment; | ||
} | ||
|
||
public function getLogDir(): string | ||
{ | ||
return $this->getProjectDir() . '/var/log'; | ||
} | ||
|
||
public function registerBundles(): iterable | ||
{ | ||
$contents = require $this->getProjectDir() . '/config/bundles.php'; | ||
foreach ($contents as $class => $envs) { | ||
if (isset($envs['all']) || isset($envs[$this->environment])) { | ||
yield new $class(); | ||
} | ||
} | ||
} | ||
|
||
public function shutdown(): void | ||
{ | ||
if (!$this->isTestEnvironment()) { | ||
parent::shutdown(); | ||
|
||
return; | ||
} | ||
|
||
if (false === $this->booted) { | ||
return; | ||
} | ||
|
||
$container = $this->getContainer(); | ||
|
||
parent::shutdown(); | ||
|
||
$this->cleanupContainer($container); | ||
} | ||
|
||
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void | ||
{ | ||
$container->addResource(new FileResource($this->getProjectDir() . '/config/bundles.php')); | ||
$container->setParameter('container.dumper.inline_class_loader', true); | ||
$confDir = $this->getProjectDir() . '/config'; | ||
|
||
$loader->load($confDir . '/{packages}/*' . self::CONFIG_EXTS, 'glob'); | ||
$loader->load($confDir . '/{packages}/' . $this->environment . '/**/*' . self::CONFIG_EXTS, 'glob'); | ||
$loader->load($confDir . '/{services}' . self::CONFIG_EXTS, 'glob'); | ||
$loader->load($confDir . '/{services}_' . $this->environment . self::CONFIG_EXTS, 'glob'); | ||
} | ||
|
||
protected function configureRoutes(RouteCollectionBuilder $routes): void | ||
{ | ||
$confDir = $this->getProjectDir() . '/config'; | ||
|
||
$routes->import($confDir . '/{routes}/*' . self::CONFIG_EXTS, '/', 'glob'); | ||
$routes->import($confDir . '/{routes}/' . $this->environment . '/**/*' . self::CONFIG_EXTS, '/', 'glob'); | ||
$routes->import($confDir . '/{routes}' . self::CONFIG_EXTS, '/', 'glob'); | ||
} | ||
|
||
protected function getContainerBaseClass(): string | ||
{ | ||
if ($this->isTestEnvironment()) { | ||
return MockerContainer::class; | ||
} | ||
|
||
return parent::getContainerBaseClass(); | ||
} | ||
|
||
private function isTestEnvironment(): bool | ||
{ | ||
return 0 === strpos($this->getEnvironment(), 'test'); | ||
} | ||
|
||
/** | ||
* Remove all container references from all loaded services | ||
*/ | ||
private function cleanupContainer(ContainerInterface $container): void | ||
{ | ||
$containerReflection = new \ReflectionObject($container); | ||
$containerServicesPropertyReflection = $containerReflection->getProperty('services'); | ||
$containerServicesPropertyReflection->setAccessible(true); | ||
|
||
$services = $containerServicesPropertyReflection->getValue($container) ?: []; | ||
foreach ($services as $serviceId => $service) { | ||
if (null === $service) { | ||
continue; | ||
} | ||
|
||
if (in_array($serviceId, self::IGNORED_SERVICES_DURING_CLEANUP, true)) { | ||
continue; | ||
} | ||
|
||
$serviceReflection = new \ReflectionObject($service); | ||
|
||
if ($serviceReflection->implementsInterface(VirtualProxyInterface::class)) { | ||
continue; | ||
} | ||
|
||
$servicePropertiesReflections = $serviceReflection->getProperties(); | ||
$servicePropertiesDefaultValues = $serviceReflection->getDefaultProperties(); | ||
foreach ($servicePropertiesReflections as $servicePropertyReflection) { | ||
$defaultPropertyValue = null; | ||
if (isset($servicePropertiesDefaultValues[$servicePropertyReflection->getName()])) { | ||
$defaultPropertyValue = $servicePropertiesDefaultValues[$servicePropertyReflection->getName()]; | ||
} | ||
|
||
$servicePropertyReflection->setAccessible(true); | ||
$servicePropertyReflection->setValue($service, $defaultPropertyValue); | ||
} | ||
} | ||
|
||
$containerServicesPropertyReflection->setValue($container, null); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.