Symfony上的Imagick-尝试从全球名称空间加载class Imagick

发布于 2025-01-25 13:31:36 字数 3149 浏览 5 评论 0原文

我正在尝试在Symfony(Shopware)中使用Imagick。当我在控制器中实例化新的Imagick-Object通过写作

$image = new \Imagick();

将为我提供http响应:

"Attempted to load class \u0022Imagick\u0022 from the global namespace.\nDid you forget a \u0022use\u0022 statement?"

完整的http-response:

{"errors":[{"code":"0","status":"500","title":"Internal Server Error","detail":"Attempted to load class \u0022Imagick\u0022 from the global namespace.\nDid you forget a \u0022use\u0022 statement?","meta":{"trace":[{"file":"\/var\/www\/html\/vendor\/symfony\/http-kernel\/HttpKernel.php","line":156,"function":"createImage","class":"ImageGenerator\\Controller\\ImageController","type":"-\u003E"},{"file":"\/var\/www\/html\/vendor\/symfony\/http-kernel\/HttpKernel.php","line":78,"function":"handleRaw","class":"Symfony\\Component\\HttpKernel\\HttpKernel","type":"-\u003E"},{"file":"\/var\/www\/html\/vendor\/symfony\/http-kernel\/Kernel.php","line":199,"function":"handle","class":"Symfony\\Component\\HttpKernel\\HttpKernel","type":"-\u003E"},{"file":"\/var\/www\/html\/vendor\/symfony\/http-kernel\/HttpCache\/SubRequestHandler.php","line":85,"function":"handle","class":"Symfony\\Component\\HttpKernel\\Kernel","type":"-\u003E"},{"file":"\/var\/www\/html\/vendor\/symfony\/http-kernel\/HttpCache\/HttpCache.php","line":479,"function":"handle","class":"Symfony\\Component\\HttpKernel\\HttpCache\\SubRequestHandler","type":"::"},{"file":"\/var\/www\/html\/vendor\/symfony\/http-kernel\/HttpCache\/HttpCache.php","line":452,"function":"forward","class":"Symfony\\Component\\HttpKernel\\HttpCache\\HttpCache","type":"-\u003E"},{"file":"\/var\/www\/html\/vendor\/symfony\/http-kernel\/HttpCache\/HttpCache.php","line":346,"function":"fetch","class":"Symfony\\Component\\HttpKernel\\HttpCache\\HttpCache","type":"-\u003E"},{"file":"\/var\/www\/html\/vendor\/symfony\/http-kernel\/HttpCache\/HttpCache.php","line":224,"function":"lookup","class":"Symfony\\Component\\HttpKernel\\HttpCache\\HttpCache","type":"-\u003E"},{"file":"\/var\/www\/html\/vendor\/shopware\/core\/HttpKernel.php","line":178,"function":"handle","class":"Symfony\\Component\\HttpKernel\\HttpCache\\HttpCache","type":"-\u003E"},{"file":"\/var\/www\/html\/vendor\/shopware\/core\/HttpKernel.php","line":81,"function":"doHandle","class":"Shopware\\Core\\HttpKernel","type":"-\u003E"},{"file":"\/var\/www\/html\/public\/index.php","line":77,"function":"handle","class":"Shopware\\Core\\HttpKernel","type":"-\u003E"}],"file":"\/var\/www\/html\/custom\/plugins\/ImageGenerator\/src\/Controller\/ImageController.php","line":42}}]}

我将shopware用作docker容器(dockware / ubuntu),并已安装Imagick-Extension通过:

sudo apt install php7.4-imagick

然后启用/etc/php/7.4/fpm/php.ini中的扩展程序,通过添加

extension=imagick

尝试指定完全合格的路径

extension=/usr/lib/php/20190902/imagick.so

,然后重新启动Apache Server。

但是,当我运行该应用程序时,它给了我上述错误。

Dockware图像中安装了几个PHP版本 - 但是我通过显示PHPVersion()检查了使用的版本。因此,应安装在正确的版本上。不过,我还将其安装在所有其他版本的ShopWares依赖项上。

如果你们知道可能导致这个问题的原因,会很感激。我是网络开发的新手,所以请忍受我。提前致谢。

I'm trying to use Imagick in Symfony (Shopware). When I instantiate a new Imagick-object in a Controller by writing

$image = new \Imagick();

it will give me following http-Response:

"Attempted to load class \u0022Imagick\u0022 from the global namespace.\nDid you forget a \u0022use\u0022 statement?"

Full http-response:

{"errors":[{"code":"0","status":"500","title":"Internal Server Error","detail":"Attempted to load class \u0022Imagick\u0022 from the global namespace.\nDid you forget a \u0022use\u0022 statement?","meta":{"trace":[{"file":"\/var\/www\/html\/vendor\/symfony\/http-kernel\/HttpKernel.php","line":156,"function":"createImage","class":"ImageGenerator\\Controller\\ImageController","type":"-\u003E"},{"file":"\/var\/www\/html\/vendor\/symfony\/http-kernel\/HttpKernel.php","line":78,"function":"handleRaw","class":"Symfony\\Component\\HttpKernel\\HttpKernel","type":"-\u003E"},{"file":"\/var\/www\/html\/vendor\/symfony\/http-kernel\/Kernel.php","line":199,"function":"handle","class":"Symfony\\Component\\HttpKernel\\HttpKernel","type":"-\u003E"},{"file":"\/var\/www\/html\/vendor\/symfony\/http-kernel\/HttpCache\/SubRequestHandler.php","line":85,"function":"handle","class":"Symfony\\Component\\HttpKernel\\Kernel","type":"-\u003E"},{"file":"\/var\/www\/html\/vendor\/symfony\/http-kernel\/HttpCache\/HttpCache.php","line":479,"function":"handle","class":"Symfony\\Component\\HttpKernel\\HttpCache\\SubRequestHandler","type":"::"},{"file":"\/var\/www\/html\/vendor\/symfony\/http-kernel\/HttpCache\/HttpCache.php","line":452,"function":"forward","class":"Symfony\\Component\\HttpKernel\\HttpCache\\HttpCache","type":"-\u003E"},{"file":"\/var\/www\/html\/vendor\/symfony\/http-kernel\/HttpCache\/HttpCache.php","line":346,"function":"fetch","class":"Symfony\\Component\\HttpKernel\\HttpCache\\HttpCache","type":"-\u003E"},{"file":"\/var\/www\/html\/vendor\/symfony\/http-kernel\/HttpCache\/HttpCache.php","line":224,"function":"lookup","class":"Symfony\\Component\\HttpKernel\\HttpCache\\HttpCache","type":"-\u003E"},{"file":"\/var\/www\/html\/vendor\/shopware\/core\/HttpKernel.php","line":178,"function":"handle","class":"Symfony\\Component\\HttpKernel\\HttpCache\\HttpCache","type":"-\u003E"},{"file":"\/var\/www\/html\/vendor\/shopware\/core\/HttpKernel.php","line":81,"function":"doHandle","class":"Shopware\\Core\\HttpKernel","type":"-\u003E"},{"file":"\/var\/www\/html\/public\/index.php","line":77,"function":"handle","class":"Shopware\\Core\\HttpKernel","type":"-\u003E"}],"file":"\/var\/www\/html\/custom\/plugins\/ImageGenerator\/src\/Controller\/ImageController.php","line":42}}]}

I'm using Shopware as a Docker Container (dockware / Ubuntu) and have installed the Imagick-extension via:

sudo apt install php7.4-imagick

Then enabled the extension in /etc/php/7.4/fpm/php.ini by adding

extension=imagick

alternatively trying to specify the fully qualified path

extension=/usr/lib/php/20190902/imagick.so

Then I restarted the apache server.

But when I run the app, it gives me the aforementioned error.

There are several PHP versions installed in the dockware image - but I checked the used version by displaying phpversion(). So it should be installed on the correct version. I've also installed it on all the other versions of Shopwares dependencies though.

Would appreciate if you guys know what could cause this issue. I'm fairly new to web development, so please bear with me. Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文