简体   繁体   中英

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

var_dump(class_exists('ZipArchive'));

if it returns true then you just add

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. To refer you have to add use ZipArchive before the new line

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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