Welcome Guest, Not a member yet? Register   Sign In
Error: Cannot redeclare… using Unzip-library

The following implemention of Unzip-library:

Class Unzip extends Controller {

function unzip() {
parent::controller() ;

function index() {

// Give it one parameter and it will extract to the same folder

// or specify a destination directory


produces an error that I can't understand:

Fatal error: Cannot redeclare class Unzip in /home/httpd/vhosts/avimonitoring.ch/httpdocs/ci/system/application/libraries/Unzip.php on line 22

What do I miss here? Thanks for your help.


All CI classes run in the same namespace. A controller, a model, a library, they're all classes. So you can't have a controller with the same name as a library (or a model).

Thanks! How could I miss this… Embarrassing!

hi, i just follow the usage of unzip library but nothing happens.

i pass a full path parameter like this:
$path = 'C:/Users/Jur/Xampp/xampp/htdocs/website/css/themes/default.zip'

// Give it one parameter and it will extract to the same folder

the library successfully loaded and the file_open can read my zip file.

is there something wrong with my path.? thanks

Probably. You must provide the base-path. It's possible that the base-path differs from the folder-path (I am not a Windows/XAMPP-user) or you may use backslahes instead of forwardslashes.

[eluser]Cristian Gilè[/eluser]
On Windows, both slash (/) and backslash (\) are used as directory separator character. In other environments, it is the forward slash (/).

Unzip class requires extension ZLib enabled. Have you enabled it?

Cristian Gilè

Hi Ornis and Cristian Gile, Thanks for your reply!

Through some trial and error, i discovered that theres nothing wrong in my path,my ZLib enabled, the unzip class is functioning well.

the problem is, I have a directory named 'default' on my target path so when the default.zip extracted, it will replace the default directory that existed. thats why I imagine theres nothing happen when i call the $this->unzip->extract($path);

Next time ill be more carefull.. haha, once again thank you very much! Smile

Theme © iAndrew 2016 - Forum software by © MyBB