![](/img/trans.png)
[英]PHP framework AMPHP/THREAD used with SYMFONY - Where does it have to be installed?
[英]Using Amphp with a framework such as Magento
我正在尝试在自定义模块中将 Amphp Parallel 函数与 Magento 框架一起使用。
try {
$response = wait(parallelMap($items, function ($item) use ($arg1){
$this->getCustomItems( $item, $arg1);
}));
} catch (MultiReasonException $exception) {
foreach ($exception->getReasons() as $reason) {
var_dump($reason->getMessage());
}
}
运行上述代码时我遇到的问题是
Uncaught RuntimeException in worker with message "ObjectManager isn't initialized" and code "0"; use Amp\Parallel\Worker\TaskFailureException::getOriginalTrace() for the stack trace in the worker
Magento 框架是使用 composer 自动加载的。 所以我不知道为什么它不能初始化对象管理器。
Magento 的依赖是通过 autoload 自动加载的,但是当它没有被 Magento 内核初始化时是没有用的,你需要创建一个单独的 Magento API,并通过你的 vendor 中编写的回调方法(使用 CURL 请求)请求该 API /autloload.php,这是您可以使用 amphp 的方式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.