From dee8fbc2a36b307f8b04bb892fce24de3c0cf9ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Sapone?= Date: Sun, 14 Jan 2024 14:59:42 +0100 Subject: [PATCH] Fix error in command in symfony application --- Makefile | 5 ++- bin/dataimporter | 21 ------------- composer.json | 2 +- dataimporter | 49 ++++++++++++++++++++++++++++++ src/Bundle/Console/Application.php | 30 ++++++++++++++++++ 5 files changed, 82 insertions(+), 25 deletions(-) delete mode 100755 bin/dataimporter create mode 100755 dataimporter create mode 100644 src/Bundle/Console/Application.php diff --git a/Makefile b/Makefile index c3b10e2..f166baa 100644 --- a/Makefile +++ b/Makefile @@ -29,8 +29,8 @@ php: ## Connect to the PHP FPM container install: ## Install project @$(PHP_CONT) composer install -## —— Quality ✨ —————————————————————————————————————————————————————— -quality: static rector +## —— CI ✨ ———————————————————————————————————————————————————————————————————— +ci: static rector test static: ## Run static analysis tools $(PHP) -d memory_limit=-1 vendor/bin/phpstan analyse @@ -39,6 +39,5 @@ static: ## Run static analysis tools rector: ## Run rector $(PHP) -d memory_limit=-1 vendor/bin/rector -## —— Testing 🚣 ———————————————————————————————————————————————————————————————— test: ## Run tests $(PHP) vendor/bin/phpunit diff --git a/bin/dataimporter b/bin/dataimporter deleted file mode 100755 index 3551e77..0000000 --- a/bin/dataimporter +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env php -add($command); - -$application->setDefaultCommand($command->getName(), true); -$application->run(); diff --git a/composer.json b/composer.json index 8e6414e..f4ea55d 100644 --- a/composer.json +++ b/composer.json @@ -43,6 +43,6 @@ "psr-4": { "IQ2i\\DataImporter\\Tests\\": "tests" } }, "bin": [ - "bin/dataimporter" + "dataimporter" ] } diff --git a/dataimporter b/dataimporter new file mode 100755 index 0000000..e158651 --- /dev/null +++ b/dataimporter @@ -0,0 +1,49 @@ +#!/usr/bin/env php += 80400) { + fwrite(STDERR, "PHP needs to be a minimum version of PHP 7.4.0 and maximum version of PHP 8.3.*.\n"); + fwrite(STDERR, 'Current PHP version: '.PHP_VERSION.".\n"); + + exit(1); + } + + if (!ini_get('date.timezone')) { + ini_set('date.timezone', 'UTC'); + } +})(); + +// load dependencies +(function () { + $possibleFiles = [__DIR__.'/../../autoload.php', __DIR__.'/../autoload.php', __DIR__.'/vendor/autoload.php']; + $file = null; + foreach ($possibleFiles as $possibleFile) { + if (file_exists($possibleFile)) { + $file = $possibleFile; + + break; + } + } + + if (null === $file) { + throw new RuntimeException('Unable to locate autoload.php file.'); + } + + require_once $file; +})(); + +use IQ2i\DataImporter\Bundle\Console\Application; + +$application = new Application(); +$application->run(); diff --git a/src/Bundle/Console/Application.php b/src/Bundle/Console/Application.php new file mode 100644 index 0000000..72e5651 --- /dev/null +++ b/src/Bundle/Console/Application.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace IQ2i\DataImporter\Bundle\Console; + +use IQ2i\DataImporter\Command\GenerateDtoCommand; +use Symfony\Component\Console\Application as BaseApplication; + +class Application extends BaseApplication +{ + public function __construct() + { + parent::__construct('DataImporter'); + + $generateDtoCommand = new GenerateDtoCommand(); + + $this->add($generateDtoCommand); + $this->setDefaultCommand($generateDtoCommand->getName(), true); + } +}