mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-28 02:55:34 +08:00
change autoload to hotload for phar hotload mode (build 442)
This commit is contained in:
@@ -28,7 +28,7 @@ use ZM\Exception\InitException;
|
||||
|
||||
class ConsoleApplication extends Application
|
||||
{
|
||||
public const VERSION_ID = 441;
|
||||
public const VERSION_ID = 442;
|
||||
|
||||
public const VERSION = '2.7.0-beta4';
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ use ZM\Utils\ZMUtil;
|
||||
*/
|
||||
class ModulePacker
|
||||
{
|
||||
public const ZM_MODULE_PACKER_VERSION = '1.0';
|
||||
public const ZM_MODULE_PACKER_VERSION = '1.1';
|
||||
|
||||
/** @var array */
|
||||
private $module = [];
|
||||
@@ -158,7 +158,7 @@ class ModulePacker
|
||||
}
|
||||
}
|
||||
foreach (($composer['autoload']['files'] ?? []) as $v) {
|
||||
if (strcmp($path, $v) === 0) {
|
||||
if (strpos($v, $path) === 0) {
|
||||
$item['files'][] = $v;
|
||||
}
|
||||
}
|
||||
@@ -202,7 +202,7 @@ class ModulePacker
|
||||
'module-packer-version' => self::ZM_MODULE_PACKER_VERSION,
|
||||
'module-root-path' => $this->getRelativePath($this->module['module-path']),
|
||||
'namespace' => $this->module['namespace'],
|
||||
'autoload-psr-4' => $this->generatePharAutoload(),
|
||||
'hotload-psr-4' => $this->generatePharAutoload(),
|
||||
'unpack' => [
|
||||
'composer-autoload-items' => $this->getComposerAutoloadItems(),
|
||||
'global-config-override' => $this->module['global-config-override'] ?? false,
|
||||
@@ -210,6 +210,9 @@ class ModulePacker
|
||||
'allow-hotload' => $this->module['allow-hotload'] ?? false,
|
||||
'pack-time' => time(),
|
||||
];
|
||||
if (isset($stub_values['unpack']['composer-autoload-items']['files'])) {
|
||||
$stub_values['hotload-files'] = $stub_values['unpack']['composer-autoload-items']['files'];
|
||||
}
|
||||
$this->phar->addFromString('zmplugin.json', json_encode($stub_values, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
|
||||
$this->module_config = $stub_values;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,10 @@ declare(strict_types=1);
|
||||
function loader__generated_id__()
|
||||
{
|
||||
$obj = json_decode(file_get_contents(__DIR__ . '/zmplugin.json'), true);
|
||||
foreach (($obj['autoload-psr-4'] ?? []) as $v) {
|
||||
foreach (($obj['hotload-psr-4'] ?? []) as $v) {
|
||||
require_once Phar::running() . '/' . $v;
|
||||
}
|
||||
foreach (($obj['hotload-files'] ?? []) as $v) {
|
||||
require_once Phar::running() . '/' . $v;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user