Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

自定义ini #4

Open
ikilobyte opened this issue Oct 17, 2022 · 9 comments
Open

自定义ini #4

ikilobyte opened this issue Oct 17, 2022 · 9 comments

Comments

@ikilobyte
Copy link

根据文档给出的规则,自定义ini生成后,和micro,ini,phar一起合并后,无法正常运行
框架:hyperf 2.2
micro:8.0.23
错误信息

t���CH��H��u�)L��I�$�H�x�L������tX���
I���:L���I��H�������L���6�CH��(L��[]A\A]A^A_�H����t$
                                                    H�t$
                                                        �o���H���UH�H��@��H�@�H����L���H��]������ATI��H��H��uH��H�x�L�������H��H�t�EH�tL��H������H��L��A\�AVAUATI��USH��uH��H�x�L�������H��H���EH��H��������H9�wH�<��Y��I��E1��'�k��I�$B�43H�@�I����|���C�D�I��I9�u�L��L��L���c���L����E���xH��H��L����E��H��H���H��H��u�eJ��I�$�H�x�L�������V���FJ��I�$�H�x�L�������J���H���J��H���vJ��H�����C[L
Fatal error: Uncaught Error: Class "Hyperf\Framework\Event\BeforeWorkerStart" not found in phar:///app/server/vendor/hyperf/framework/src/Bootstrap/WorkerStartCallback.php:47
Stack trace:
#0 {main}
  thrown in phar:///app/server/vendor/hyperf/framework/src/Bootstrap/WorkerStartCallback.php on line 47
[2022-10-17 06:16:21 *431.1]	ERROR	php_swoole_server_rshutdown() (ERRNO 503): Fatal error: Uncaught Error: Class "Hyperf\Framework\Event\BeforeWorkerStart" not found in phar:///app/server/vendor/hyperf/framework/src/Bootstrap/WorkerStartCallback.php:47
Stack trace:
#0 {main}
@dixyes
Copy link
Collaborator

dixyes commented Oct 17, 2022

  1. 你的phar压缩过吗 已知压缩过的phar有点小毛病,需要构建时打patch:https://github.com/easysoft/phpmicro/blob/master/patches/phar.patch
  2. ini头啥样的,给个hexdump看看呗

@ikilobyte
Copy link
Author

<?php

$ini = "swoole.use_shortname='Off'";
$resource = fopen('include-ini', 'wb');
fwrite($resource, "\xfd\xf6\x69\xe6");
fwrite($resource, pack('N', strlen($ini)));
fwrite($resource, $ini);
fclose($resource);
# hexdump include-ini

0000000 f6fd e669 0000 1a00 7773 6f6f 656c 752e
0000010 6573 735f 6f68 7472 616e 656d 273d 664f
0000020 2766
0000022

@ikilobyte
Copy link
Author

我是用的 crazywhalecc/static-php-cl 构建好的micro
phar是 hyperf/phar 工具打包的,应该不存在压缩的情况

@dixyes
Copy link
Collaborator

dixyes commented Oct 17, 2022

看起来这个头没啥问题,phar是不是压缩过的我就不知道了,压缩过的phar应该只有乱码,没有这个报错

我调查一下,如果是micro的bug我修下,但如果是比较坏的情况,swoole对phar的支持有问题就比较麻烦(micro和swow对phar的支持有些魔法,不知道是不是兼容现在版本的swoole)

@ikilobyte
Copy link
Author

好的,感谢感谢

@ikilobyte
Copy link
Author

我测试了一下,自定义的ini可以被注入,从报错的信息来看好像是从phar中找不到某些类,Fatal error: Uncaught Error: Class,不知道是swoole的原因,还是phar的原因,还是hyperf的原因,,,

@ikilobyte
Copy link
Author

ikilobyte commented Oct 17, 2022

纯phar模式,php xxx.phar 可以正常运行
micro模式(未注入自定义ini),./xxx 无法运行,Fatal error: Uncaught Error: Class "Hyperf\Framework\Event\OnStart" not found in phar:///app/run/run/app/Command/Demo.php:42

@dbx192
Copy link

dbx192 commented Jan 12, 2024

@ikilobyte 你好,我的php项目已经打包成了phar文件,但是运行的时候需要php test.phar start这样起服务,我直接copy /b micro.sfx + test.phar test.exe,然后运行test.exe不行,需要怎么做才能把这个启动命令也打到二进制文件呢?我想要的结果是,直接运行test.exe就相当于执行php test.phar start这个命令。谢谢

@dixyes
Copy link
Collaborator

dixyes commented Jan 13, 2024

@ikilobyte 你好,我的php项目已经打包成了phar文件,但是运行的时候需要php test.phar start这样起服务,我直接copy /b micro.sfx + test.phar test.exe,然后运行test.exe不行,需要怎么做才能把这个启动命令也打到二进制文件呢?我想要的结果是,直接运行test.exe就相当于执行php test.phar start这个命令。谢谢

  1. 请单独开issue
  2. micro作为底层的东西,不应该提供这种功能 如果需要的话建议通过custom phat stub或框架设置来实现

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants