找不到Symfony ZipArchive PHP扩展类 [英] Symfony ZipArchive PHP Extension Class Not Found

查看:130
本文介绍了找不到Symfony ZipArchive PHP扩展类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了这段代码

var_dump(class_exists('ZipArchive'));
$zip = new ZipArchive();

好吧,输出是这样的.

bool(true)
Fatal error: Class 'MyProject\ProjectBundle\Controller\ZipArchive' not found in \path\to\my\Controller.php on line 83

任何人都可以帮助我解决这个问题吗? 我已经安装了

Anyone can help me how to solve this? I have installed

php-pear
php5-dev
libcurl3-openssl-dev
libevent-dev
pecl-http
all i need have been installed
and i have put the extension to my php.ini then restart my apache

但是我仍然会收到该错误. 然后我尝试了

But i still get that error. Then I tried this

$z = new /ZipArchive();

来自此页面

然后我得到这个错误:

Parse error: syntax error, unexpected '/' in /path/to/my/symfonyController.php on line 83

推荐答案

安装完成后,使用此代码检查您的ZipArchive类是否存在

After installation is done and check your ZipArchive class is exist with this code

var_dump(class_exists('ZipArchive'));

如果返回true,则只需添加

use ZipArchive;

将其放在您的命名空间之后
然后输入这段代码

put it after your namespace
and then put this code

$zip = new ZipArchive();

要放在哪里.

这篇关于找不到Symfony ZipArchive PHP扩展类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆