add composer library mode

This commit is contained in:
crazywhalecc 2023-12-24 14:43:47 +08:00 committed by Jerry Ma
parent 6b8df97282
commit db7532cad3
2 changed files with 8 additions and 2 deletions

View File

@ -4,7 +4,13 @@
use SPC\ConsoleApplication;
use SPC\exception\ExceptionHandler;
require_once __DIR__ . '/../vendor/autoload.php';
if (file_exists(dirname(__DIR__) . '/vendor/autoload.php')) {
// Current: ./bin (git/project mode)
require_once dirname(__DIR__) . '/vendor/autoload.php';
} else {
// Current: ./vendor/crazywhalecc/static-php-cli/bin (composer library mode)
require_once dirname(__DIR__, 3) . '/autoload.php';
}
// 防止 Micro 打包状态下不支持中文的显示(虽然这个项目目前好像没输出过中文?)
if (PHP_OS_FAMILY === 'Windows' && Phar::running()) {

View File

@ -5,7 +5,7 @@ declare(strict_types=1);
use ZM\Logger\ConsoleLogger;
define('WORKING_DIR', getcwd());
const ROOT_DIR = __DIR__ . '/../..';
define('ROOT_DIR', dirname(__DIR__, 2));
// CLI start time
define('START_TIME', microtime(true));