Asmir Mustafic
Berlin Symfony Meetup
July 2023
(and deleted 2M lines of code)
Project A
<?php
class RequestHandler
{
public function __construct(ContainerInterface $container, string $cacheDir)
{
$this->container = $container;
self::$staticContainer = $container;
}
public static function getContainer(): ContainerInterface
{
return self::$staticContainer;
}
public function getBootstrap(): YvesBootstrap
{
if ($this->bootstrap) return $this->bootstrap;
return $this->bootstrap = new YvesBootstrap();
}
public function getApplication(): Application
{
if ($this->app) return $this->app;
$this->app = $this->getBootstrap()->boot();
$this->app->boot();
return $this->app;
}
public function handle(Request $request): Response
{
return $this->getApplication()->handle($request->duplicate());
}
}
<?php
class SearchApiFactory extends AbstractFactory // Spryker app service
{
/**
* @return \Pyz\Client\SearchApi\Parts\PartsAutocompletionSearch
*/
public function createPartsAutocompleteSearch(): PartsAutocompletionSearch
{
return new PartsAutocompletionSearch(
SprykerFacade::getContainer()->get('guzzle_client'),
$this->getConfig()
);
}
}
<?php
class CategoryFinder // Symfony app service
{
public function __construct(SprykerFacade $spryker)
{
$sprkerFormFactory = $spryker->getApplication()->get('form.factory');
}
}
<?php
class ServiceControllerResolver extends AbstractControllerResolver
{
protected function getResolvedClassInstance()
{
$container = SprykerFacade::getContainer();
$resolvedClassName = $this->resolvedClassName();
if ($container->has($resolvedClassName)) {
return $container->get($resolvedClassName);
}
return parent::getResolvedClassInstance();
}
}
Symfony controller autowiring
services:
_defaults:
autowire: true
autoconfigure: true
public: false
Pyz\Yves\Customer\Controller\AddressBookController:
public: true
<?php
class AddressBookController extends AbstractCustomerController
{
public function __construct(
AddressRepository $addressRepository,
AccountRepository $accountRepository
) {
$this->addressRepository = $addressRepository;
$this->accountRepository = $accountRepository;
}
}
Symfony controller autowiring
Symfony workflow component
(delete leftovers)
start development
mvp release
introduction to symfony
introduction to wiliam
introduction to
xyla
removed zed
end of spryker
me