CodeIgniter Forums
Error: Cannot redeclare… using Unzip-library - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Error: Cannot redeclare… using Unzip-library (/thread-37082.html)



Error: Cannot redeclare… using Unzip-library - El Forum - 12-27-2010

[eluser]Ornis[/eluser]
The following implemention of Unzip-library:

<?php
Class Unzip extends Controller {

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


function index() {
$this->load->library('Unzip');

// Give it one parameter and it will extract to the same folder
$this->unzip->extract('./img_maptiles/17.zip');

// or specify a destination directory
$this->unzip->extract('./img_maptiles/mydest/');

}
}

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.

Martin


Error: Cannot redeclare… using Unzip-library - El Forum - 12-27-2010

[eluser]WanWizard[/eluser]
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).


Error: Cannot redeclare… using Unzip-library - El Forum - 12-27-2010

[eluser]Ornis[/eluser]
Thanks! How could I miss this… Embarrassing!


Error: Cannot redeclare… using Unzip-library - El Forum - 01-03-2011

[eluser]jur[/eluser]
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
$this->unzip->extract($path);

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

is there something wrong with my path.? thanks


Error: Cannot redeclare… using Unzip-library - El Forum - 01-08-2011

[eluser]Ornis[/eluser]
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.


Error: Cannot redeclare… using Unzip-library - El Forum - 01-08-2011

[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è


Error: Cannot redeclare… using Unzip-library - El Forum - 01-09-2011

[eluser]jur[/eluser]
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