Skip to content

Commit

Permalink
Fix error in command in symfony application
Browse files Browse the repository at this point in the history
  • Loading branch information
loicsapone committed Jan 14, 2024
1 parent 1385aec commit dee8fbc
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 25 deletions.
5 changes: 2 additions & 3 deletions Makefile
Expand Up @@ -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
Expand All @@ -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
21 changes: 0 additions & 21 deletions bin/dataimporter

This file was deleted.

2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -43,6 +43,6 @@
"psr-4": { "IQ2i\\DataImporter\\Tests\\": "tests" }
},
"bin": [
"bin/dataimporter"
"dataimporter"
]
}
49 changes: 49 additions & 0 deletions dataimporter
@@ -0,0 +1,49 @@
#!/usr/bin/env php
<?php

declare(strict_types=1);

error_reporting(E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED);
set_error_handler(static function ($severity, $message, $file, $line) {
if ($severity & error_reporting()) {
throw new ErrorException($message, 0, $severity, $file, $line);
}
});

// check environment requirements
(function () {
if (\PHP_VERSION_ID < 80100 || \PHP_VERSION_ID >= 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();
30 changes: 30 additions & 0 deletions src/Bundle/Console/Application.php
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

/*
* This file is part of the DataImporter package.
*
* (c) Loïc Sapone <loic@sapone.fr>
*
* 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);
}
}

0 comments on commit dee8fbc

Please sign in to comment.