diff --git a/hesabixCore/src/Command/TestEnvironmentCommand.php b/hesabixCore/src/Command/TestEnvironmentCommand.php
new file mode 100644
index 0000000..b963251
--- /dev/null
+++ b/hesabixCore/src/Command/TestEnvironmentCommand.php
@@ -0,0 +1,72 @@
+appDir = dirname(__DIR__, 2);
+ // مستقیماً از .env.local.php بخوان
+ $envConfig = file_exists($this->appDir . '/.env.local.php') ? require $this->appDir . '/.env.local.php' : [];
+ $this->env = $envConfig['APP_ENV'] ?? getenv('APP_ENV') ?: 'prod';
+ parent::__construct($name);
+ }
+
+ protected function execute(InputInterface $input, OutputInterface $output): int
+ {
+ $output->writeln("Detected environment: " . $this->env);
+
+ $composerCommand = ['composer', 'install', '--optimize-autoloader'];
+ if ($this->env !== 'dev') {
+ $composerCommand[] = '--no-dev';
+ $composerCommand[] = '--no-scripts';
+ }
+
+ $output->writeln("Running command: " . implode(' ', $composerCommand));
+
+ $process = new Process($composerCommand, $this->appDir);
+ $process->setTimeout(3600);
+ if ($output->isVerbose()) {
+ $process->mustRun(function ($type, $buffer) use ($output) {
+ $output->write($buffer);
+ });
+ } else {
+ $process->mustRun();
+ }
+
+ $output->writeln('Composer install completed successfully.');
+
+ // تست اجرای cache:clear برای اطمینان
+ $this->runProcess(['php', 'bin/console', 'cache:clear', "--env={$this->env}"], $output);
+
+ return Command::SUCCESS;
+ }
+
+ private function runProcess(array $command, OutputInterface $output): void
+ {
+ $process = new Process($command, $this->appDir);
+ $process->setTimeout(3600);
+ if ($output->isVerbose()) {
+ $process->mustRun(function ($type, $buffer) use ($output) {
+ $output->write($buffer);
+ });
+ } else {
+ $process->mustRun();
+ }
+ $output->writeln('' . implode(' ', $command) . ' completed successfully.');
+ }
+}
\ No newline at end of file
diff --git a/hesabixCore/src/Command/UpdateSoftwareCommand.php b/hesabixCore/src/Command/UpdateSoftwareCommand.php
index 5ff96ce..3ed3ddd 100644
--- a/hesabixCore/src/Command/UpdateSoftwareCommand.php
+++ b/hesabixCore/src/Command/UpdateSoftwareCommand.php
@@ -39,7 +39,9 @@ class UpdateSoftwareCommand extends Command
$this->archiveDir = $this->rootDir . '/hesabixArchive';
$this->backupDir = $this->rootDir . '/hesabixBackup';
$this->stateFile = $this->backupDir . '/' . Uuid::uuid4() . '/update_state.json';
- $this->env = getenv('APP_ENV') ?: 'prod';
+ $envConfig = file_exists($this->appDir . '/.env.local.php') ? require $this->appDir . '/.env.local.php' : [];
+ $this->env = $envConfig['APP_ENV'] ?? getenv('APP_ENV') ?: 'prod';
+ $this->logger->info("Environment detected: " . $this->env);
parent::__construct();
}
@@ -54,7 +56,7 @@ class UpdateSoftwareCommand extends Command
$uuid = Uuid::uuid4()->toString();
$this->logger->info("Starting software update with UUID: $uuid in {$this->env} mode");
- $this->writeOutput($output, "Starting software update (UUID: $uuid)...");
+ $this->writeOutput($output, "Starting software update (UUID: $uuid) in {$this->env} mode");
if ($this->isUpToDate()) {
$this->writeOutput($output, 'The software is already up to date with the remote repository.');
@@ -124,6 +126,7 @@ class UpdateSoftwareCommand extends Command
$composerCommand = ['composer', 'install', '--optimize-autoloader'];
if ($this->env !== 'dev') {
$composerCommand[] = '--no-dev';
+ $composerCommand[] = '--no-scripts';
}
$this->runProcess($composerCommand, $this->appDir, $output, 3);
$state['completedSteps'][] = 'composer_install';