66 lines
2.1 KiB
PHP
66 lines
2.1 KiB
PHP
#!/usr/bin/env php
|
|
<?php
|
|
|
|
use PrestaShopBundle\Console\PrestaShopApplication;
|
|
use PrestaShop\PrestaShop\Core\Addon\Theme\Theme;
|
|
use Symfony\Component\Console\Exception\InvalidArgumentException;
|
|
use Symfony\Component\Console\Input\ArgvInput;
|
|
use Symfony\Component\Dotenv\Dotenv;
|
|
use Symfony\Component\ErrorHandler\Debug;
|
|
|
|
// if you don't want to setup permissions the proper way, just uncomment the following PHP line
|
|
// read https://symfony.com/doc/current/setup.html#checking-symfony-application-configuration-and-setup
|
|
// for more information
|
|
// umask(0000);
|
|
|
|
set_time_limit(0);
|
|
|
|
require_once __DIR__ . '/../autoload.php';
|
|
|
|
// Loads .env file from the root of project
|
|
$dotEnvFile = dirname(__FILE__, 2) . '/.env';
|
|
(new Dotenv())
|
|
// DO NOT use putEnv
|
|
->usePutenv(false)
|
|
->loadEnv($dotEnvFile)
|
|
;
|
|
|
|
try {
|
|
require_once __DIR__ . '/../config/config.inc.php';
|
|
} catch (PrestaShopException $e) {
|
|
// Prevent breaking all CLI command when the shop is not installed, define fallback values
|
|
if (!defined('__PS_BASE_URI__')) {
|
|
define('__PS_BASE_URI__', '/');
|
|
}
|
|
if (!defined('_THEME_NAME_')) {
|
|
define('_THEME_NAME_', Theme::getDefaultTheme());
|
|
}
|
|
if (!defined('_PARENT_THEME_NAME_')) {
|
|
define('_PARENT_THEME_NAME_', '');
|
|
}
|
|
|
|
// Define all the URI base constants
|
|
require_once __DIR__ . '/../config/defines_uri.inc.php';
|
|
}
|
|
|
|
$input = new ArgvInput();
|
|
$env = $input->getParameterOption(['--env', '-e'], getenv('SYMFONY_ENV') ?: 'dev');
|
|
$debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(['--no-debug', '']) && $env !== 'prod';
|
|
|
|
// Handle PrestaShop global option app-id, by default use the Admin kernel
|
|
$appId = $input->getParameterOption(['--app-id'], getenv('APP_ID') ?: 'admin');
|
|
$kernelClass = match ($appId) {
|
|
AdminKernel::APP_ID => AdminKernel::class,
|
|
FrontKernel::APP_ID => FrontKernel::class,
|
|
AdminAPIKernel::APP_ID => AdminAPIKernel::class,
|
|
default => throw new InvalidArgumentException('Unknown PrestaShop kernel matching the ID ' . $appId),
|
|
};
|
|
|
|
if ($debug) {
|
|
Debug::enable();
|
|
}
|
|
|
|
$kernel = new $kernelClass($env, $debug);
|
|
$application = new PrestaShopApplication($kernel);
|
|
$application->run($input);
|