fix: correct cli.php path for phar

This commit is contained in:
2025-12-23 20:04:39 +03:00
parent 185f3096e1
commit 57c8400904
7 changed files with 30 additions and 12 deletions

View File

@@ -79,7 +79,7 @@ class SettingsHandler
$data['forms'] = [];
// Add CRON system details (read-only)
$data['cron']['cli_path'] = dirname(DIR_SYSTEM) . '/cli.php';
$data['cron']['cli_path'] = BP_REAL_BASE_PATH . '/cli.php';
$data['cron']['last_run'] = $this->getLastCronRunDate();
$forms = $this->builder->newQuery()

View File

@@ -30,7 +30,7 @@ class ScheduleListCommand extends TeleCartCommand
$registry = new ScheduleJobRegistry($this->container);
// Load schedule config
$configFile = BP_BASE_PATH . '/configs/schedule.php';
$configFile = BP_PHAR_BASE_PATH . '/configs/schedule.php';
if (file_exists($configFile)) {
$scheduler = $registry; // Variable name used in config file
require $configFile;

View File

@@ -17,7 +17,12 @@ use Symfony\Component\HttpFoundation\Response;
// phpcs:disable PSR1.Files.SideEffects
if (! defined('BP_BASE_PATH')) {
$phar = Phar::running(false);
define('BP_BASE_PATH', $phar ? "phar://$phar" : dirname(__DIR__) . '/..');
$realBasePath = $phar ? dirname($phar) : dirname(__DIR__) . '/..';
$pharBasePath = $phar ? "phar://$phar" : $realBasePath;
define('BP_REAL_BASE_PATH', $realBasePath);
define('BP_PHAR_BASE_PATH', $pharBasePath);
define('BP_BASE_PATH', $pharBasePath);
}
// phpcs:enable PSR1.Files.SideEffects

View File

@@ -67,7 +67,7 @@ class SchedulerService
// Only load config file if registry was not injected (for production use)
if (! $this->registry) {
$configFile = BP_BASE_PATH . '/configs/schedule.php';
$configFile = BP_PHAR_BASE_PATH . '/configs/schedule.php';
if (file_exists($configFile)) {
require $configFile;
} else {

View File

@@ -3,7 +3,6 @@
use Openguru\OpenCartFramework\Application;
use Openguru\OpenCartFramework\Config\Settings;
use Openguru\OpenCartFramework\Support\Utils;
use Openguru\OpenCartFramework\TeleCartPulse\TeleCartPulseService;
if (! function_exists('table')) {
function db_table(string $name): string
@@ -34,28 +33,28 @@ if (! function_exists('column')) {
if (! function_exists('configs_path')) {
function configs_path(string $path = ''): string
{
return BP_BASE_PATH . '/configs/' . $path;
return BP_PHAR_BASE_PATH . '/configs/' . $path;
}
}
if (! function_exists('resources_path')) {
function resources_path(string $path = ''): string
{
return BP_BASE_PATH . '/resources/' . $path;
return BP_PHAR_BASE_PATH . '/resources/' . $path;
}
}
if (! function_exists('database_path')) {
function database_path(string $path = ''): string
{
return BP_BASE_PATH . '/database/' . $path;
return BP_PHAR_BASE_PATH . '/database/' . $path;
}
}
if (! function_exists('base_path')) {
function base_path(string $path = ''): string
{
return BP_BASE_PATH . '/' . $path;
return BP_PHAR_BASE_PATH . '/' . $path;
}
}
@@ -111,7 +110,7 @@ if (! function_exists('module_version')) {
return $version;
}
$versionFile = BP_BASE_PATH . '/version.txt';
$versionFile = BP_PHAR_BASE_PATH . '/version.txt';
if (is_readable($versionFile)) {
$raw = trim((string) file_get_contents($versionFile));
if ($raw !== '') {
@@ -119,7 +118,7 @@ if (! function_exists('module_version')) {
}
}
$composerFile = BP_BASE_PATH . '/composer.json';
$composerFile = BP_PHAR_BASE_PATH . '/composer.json';
if (is_readable($composerFile)) {
$composer = json_decode((string) file_get_contents($composerFile), true);
if (is_array($composer) && ! empty($composer['version'])) {

View File

@@ -9,4 +9,7 @@ parameters:
scanDirectories:
- stubs
inferPrivatePropertyTypeFromConstructor: true
inferPrivatePropertyTypeFromConstructor: true
bootstrapFiles:
- stubs/phpstan-bootstrap.php

View File

@@ -0,0 +1,11 @@
<?php
// phpstan-bootstrap.php
// Объявляем константы, чтобы PHPStan их видел
if (!defined('BP_REAL_BASE_PATH')) {
define('BP_REAL_BASE_PATH', dirname(__DIR__) . '/..');
}
if (!defined('BP_PHAR_BASE_PATH')) {
define('BP_PHAR_BASE_PATH', dirname(__DIR__) . '/..');
}