Skip to content

Commit

Permalink
[TASK] Add symfony service dependency injection container (#378)
Browse files Browse the repository at this point in the history
* [TASK] Add symfony service container

* [TASK] Simplify command name configuration

* [TASK] Sort packages in composer.json

* Pass console parameters via config

Co-authored-by: Simon Schaufelberger <[email protected]>
  • Loading branch information
sabbelasichon and simonschaufi authored Apr 1, 2020
1 parent 878a18c commit 6f532c8
Show file tree
Hide file tree
Showing 44 changed files with 1,414 additions and 688 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ vendor/
sphpdox.phar
_Output/
Documentation/.doctrees
var/
1 change: 1 addition & 0 deletions .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ if (PHP_SAPI !== 'cli') {
// Define in which folders to search and which folders to exclude
// Exclude some directories that are excluded by Git anyways to speed up the sniffing
$finder = PhpCsFixer\Finder::create()
->exclude('var')
->exclude('.github')
->exclude('Configuration')
->exclude('Documentation')
Expand Down
31 changes: 31 additions & 0 deletions Resources/services.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
parameters:
name: 'TYPO3 Surf'
version: '3.0.0-alpha'

services:
_defaults:
autowire: true
autoconfigure: true
public: true
bind:
$name: '%name%'
$version: '%version%'
TYPO3\Surf\:
resource: '../src/*'
exclude: '../src/{Cli,Application,Exception,Domain/Model,DeprecationMessageFactory.php,Exception.php,functions.php}'
Symfony\Component\Console\Output\OutputInterface:
factory: ['@TYPO3\Surf\Cli\Symfony\ConsoleOutputFactory', 'createOutput']
Psr\Log\LoggerInterface:
factory: ['@TYPO3\Surf\Cli\Symfony\Logger\LoggerFactory', 'createLogger']
TYPO3\Surf\Integration\Factory:
arguments: ['@TYPO3\Surf\Domain\Filesystem\FilesystemInterface', '@Psr\Log\LoggerInterface']
TYPO3\Surf\Integration\FactoryInterface: '@TYPO3\Surf\Integration\Factory'
GuzzleHttp\Client: ~
GuzzleHttp\ClientInterface: '@GuzzleHttp\Client'
TYPO3\Surf\Cli\Symfony\Logger\ConsoleHandler: ~
TYPO3\Surf\Cli\Symfony\ConsoleApplication: ~
Symfony\Component\Console\Application: ~
TYPO3\Surf\Domain\Model\SimpleWorkflow:
shared: false
TYPO3\Surf\Cli\Symfony\ConsoleOutputFactory: ~
TYPO3\Surf\Cli\Symfony\Logger\LoggerFactory: ~
10 changes: 7 additions & 3 deletions bin/surf
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@

requireAutoloader();

$app = new \TYPO3\Surf\Cli\Symfony\ConsoleApplication('TYPO3 Surf', '3.0.0-alpha');
$app->setFactory(new \TYPO3\Surf\Integration\Factory());
$app->run();
$kernel = new \TYPO3\Surf\Cli\Symfony\ConsoleKernel('prod', false);
$kernel->boot();
/* @var \Symfony\Component\DependencyInjection\Container $container */
$container = $kernel->getContainer();

$application = $container->get(\TYPO3\Surf\Cli\Symfony\ConsoleApplication::class);
$application->run();

function requireAutoloader()
{
Expand Down
14 changes: 10 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,25 @@
"license": "GPL-3.0-or-later",
"require": {
"php": "^7.2",
"guzzlehttp/guzzle": "^6.0",
"monolog/monolog": "^1.17",
"neos/utility-files": "^3.0",
"padraic/phar-updater": "1.0.5",
"symfony/config": "^5.0",
"symfony/console": "^4.0",
"symfony/process": "^4.0",
"symfony/dependency-injection": "^5.0",
"symfony/http-kernel": "^4.0",
"symfony/options-resolver": "^4.0",
"guzzlehttp/guzzle": "^6.0",
"symfony/process": "^4.0",
"symfony/yaml": "^5.0",
"webmozart/assert": "^1.4"
},
"require-dev": {
"phpunit/phpunit": "^7.0",
"friendsofphp/php-cs-fixer": "^2.14",
"jangregor/phpstan-prophecy": "^0.6.2",
"phpstan/phpstan": "^0.12.14",
"phpstan/phpstan-webmozart-assert": "^0.12.2",
"jangregor/phpstan-prophecy": "^0.6.2"
"phpunit/phpunit": "^7.0"
},
"scripts": {
"release-phar": "bin/box build",
Expand Down Expand Up @@ -46,6 +50,8 @@
"bin/surf"
],
"config": {
"optimize-autoloader": true,
"sort-packages": true,
"platform": {
"php": "7.2.5"
}
Expand Down
Loading

0 comments on commit 6f532c8

Please sign in to comment.