简体   繁体   English

未找到Symfony ZipArchive PHP扩展类

[英]Symfony ZipArchive PHP Extension Class Not Found

I tried this code 我试过这段代码

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

well, the output is like this. 好吧,输出是这样的。

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();

from this page 从这个页面

and then i got this error : 然后我收到了这个错误:

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

After installation is done and check your ZipArchive class is exist with this code 安装完成后,使用此代码检查ZipArchive类是否存在

var_dump(class_exists('ZipArchive'));

if it returns true then you just add 如果它返回true那么你只需添加

use ZipArchive;

put it after your namespace 把它放在命名空间之后
and then put this code 然后把这段代码

$zip = new ZipArchive();

on where you are want to put. 在你想放的地方。

You need to refer to ziparchive and then use the call $Z. 你需要参考ziparchive,然后使用$ Z调用。 To refer you have to add use ZipArchive before the new line 要引用你必须在新行之前添加use ZipArchive

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM