首页
下载
文档
社区
视频
捐赠
源代码
赞助商
AOT 编译器
AI 助理
商业产品
PHP AOT 原生编译器
Swoole-Compiler 代码加密器
CRMEB 新零售社交电商系统
登录
注册
全部
提问
分享
讨论
建议
公告
开发框架
CodeGalaxy
发表新帖
runkit7_import 函数使用问题
### 问题描述 [root@VM_0_15_centos bbs.d2wd.com]# /usr/bin/php index.php [2020-09-04 16:50:00 $11090.0] WARNING swManager_check_exit_status: worker#1[pid=11094] abnormal exit, status=0, signal=11 A bug occurred in Swoole-v4.5.0, please report it. The Swoole developers probably don't know about it, and unless you report it, chances are it won't be fixed. You can read How to report a bug doc before submitting any bug reports: >> https://github.com/swoole/swoole-src/blob/master/.github/ISSUE.md Please do not send bug reports in the mailing list or personal letters. The issue page is also suitable to submit feature requests. ### 相关代码 ```php runkit7_import($controller_file, RUNKIT_IMPORT_CLASS_METHODS|RUNKIT_IMPORT_OVERRIDE);//覆盖导入类 $class_namespacename = "\\" . $module_name . "\\".controller."\\" . $class_name;//模块,控制器,类名称 $class_obj = new $class_namespacename(); if (method_exists($class_obj, $function_name)) { $http_data=$class_obj->$function_name(); } else { $http_data = "模块/控制器/方法->" . $module_name . '/' . $controller_name . '/' . $function_name . "不存在!"; } ``` ### 你期待的结果是什么?实际看到的错误信息又是什么? 使用这个函数为什么报错了
发布于6年前 · 1 次浏览 · 来自
提问
cpz2020
### 问题描述 [root@VM_0_15_centos bbs.d2wd.com]# /usr/bin/php index.php [2020-09-04 16:50:00 $11090.0] WARNING swManager_check_exit_status: worker#1[pid=11094] abnormal exit, status=0, signal=11 A bug occurred in Swoole-v4.5.0, please report it. The Swoole developers probably don't know about it, and unless you report it, chances are it won't be fixed. You can read How to report a bug doc before submitting any bug reports: >> https://github.com/swoole/swoole-src/blob/master/.github/ISSUE.md Please do not send bug reports in the mailing list or personal letters. The issue page is also suitable to submit feature requests. ### 相关代码 ```php runkit7_import($controller_file, RUNKIT_IMPORT_CLASS_METHODS|RUNKIT_IMPORT_OVERRIDE);//覆盖导入类 $class_namespacename = "\\" . $module_name . "\\".controller."\\" . $class_name;//模块,控制器,类名称 $class_obj = new $class_namespacename(); if (method_exists($class_obj, $function_name)) { $http_data=$class_obj->$function_name(); } else { $http_data = "模块/控制器/方法->" . $module_name . '/' . $controller_name . '/' . $function_name . "不存在!"; } ``` ### 你期待的结果是什么?实际看到的错误信息又是什么? 使用这个函数为什么报错了
赞
0
收藏
提问
分享
讨论
建议
公告
开发框架
CodeGalaxy
登录
后参与评论
评论
2020-09-05
鲁飞
你PHP73? ``` For all those things you.... probably shouldn't have been doing anyway.... but surely do! Supports PHP7.2, 7.2, 7.3, and (partially) 7.4! (function/method manipulation is recommended only for unit testing. Note that PHP 7.3+ has known crashes in runkit7_import() but all other functionality works.) ``` https://github.com/runkit7/runkit7 这个扩展已知73会crashes,Swoole只不过是拦截了会提示
赞
0
回复
2020-09-07
cpz2020
回复
鲁飞
号的 我换个版本
赞
0
回复
2020-09-08
cpz2020
[2020-09-07 17:00:54 $12262.0] WARNING check_worker_exit_status: worker#1[pid=12266] abnormal exit, status=0, signal=11 A bug occurred in Swoole-v4.5.3, please report it. The Swoole developers probably don't know about it, and unless you report it, chances are it won't be fixed. You can read How to report a bug doc before submitting any bug reports: >> https://github.com/swoole/swoole-src/blob/master/.github/ISSUE.md Please do not send bug reports in the mailing list or personal letters. The issue page is also suitable to submit feature requests. ^C [root@VM_0_15_centos bbs.d2wd.com]# php -v PHP 7.4.9 (cli) (built: Sep 7 2020 15:23:27) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies [root@VM_0_15_centos bbs.d2wd.com]# 还是不行 感觉这个扩展 不太好 ===================================================================== TIME END 2020-09-07 16:57:19 ===================================================================== TEST RESULT SUMMARY --------------------------------------------------------------------- Exts skipped : 0 Exts tested : 46 --------------------------------------------------------------------- Number of tests : 192 151 Tests skipped : 41 ( 21.4%) -------- Tests warned : 0 ( 0.0%) ( 0.0%) Tests failed : 1 ( 0.5%) ( 0.7%) Expected fail : 13 ( 6.8%) ( 8.6%) Tests passed : 137 ( 71.4%) ( 90.7%) --------------------------------------------------------------------- Time taken : 12 seconds ===================================================================== ===================================================================== EXPECTED FAILED TEST SUMMARY //测试输出 3个文件 [root@VM_0_15_centos bbs.d2wd.com]# vim test_file2.php [root@VM_0_15_centos bbs.d2wd.com]# vim test_file.php [root@VM_0_15_centos bbs.d2wd.com]# vim test_file2.php [root@VM_0_15_centos bbs.d2wd.com]# php test.php {"a11":"333"}{"a11":"3334444"}[root@VM_0_15_centos bbs.d2wd.com]# ```php test_file.php 文件1 namespace index\controller; class index{ public function index(){ return json_encode(array("a11"=>"333")); } } test_file2.php 文件2 namespace index\controller; class index{ public function index(){ return json_encode(array("a11"=>"3334444")); } } test.php //测试程序代码 require "test_file.php"; $index=new index\controller\index(); echo $index->index(); $controller_file= "test_file2.php"; runkit7_import($controller_file, RUNKIT_IMPORT_CLASS_METHODS|RUNKIT_IMPORT_OVERRIDE);//覆盖导入类ss $index=new index\controller\index(); echo $index->index(); //输出结果 {“a11”:”333”}{“a11”:”3334444”} //通过 ```
赞
0
回复
2020-09-08
鲁飞
回复
cpz2020
建议去该扩展issue提问。https://github.com/runkit7/runkit7
赞
0
回复
2020-09-10
cpz2020
回复
鲁飞
'''php Also, not sure if runkit is needed here. Does the name of the generated class have to be MyClass? Could it instead be MyClass_01234abcd? If so, then you could probably implement get_my_plugin('MyClass') : MyPluginInterface doing something like the pseudocode below (missing error handling): Check if modification date of file changed, return if it didn't. (Probably need to call clearstatcache($pathToFile) first) $source = file_get_contents('path/to/MyClass.php'); // or stream_get_include_path $hash = md5($source); $genClassName = 'MyClass_' . $hash; // use variable $origClassName instead if (class_exists($genClassName, false)) { return; } $source = preg_replace('/\bMyClass\b/i', $genClassName, $source); eval($source); return new $genClassName(args); 他提供了一个思路 我以前也想过 感觉这样 是一个不错的解决方案了 代价也不是很大 '''
赞
0
回复