alchemy-fr / zippy Goto Github PK
View Code? Open in Web Editor NEWPHP zip/tar/bz2 archives (de)compression library with commandline or extensions
License: Other
PHP zip/tar/bz2 archives (de)compression library with commandline or extensions
License: Other
The following list of words have had soft reservations placed on them. Whilst they may still be used as class, interface, and trait names (as well as in namespaces), usage of them is highly discouraged since they may be used in future versions of PHP.
resource (as of PHP 7)
object (as of PHP 7)
mixed (as of PHP 7)
numeric (as of PHP 7)
http://php.net/manual/en/reserved.other-reserved-words.php
The doc says I can do this way:
<?php
$zippy = Zippy::load();
$zippy->create('archive.zip');
but this code throws an exception Unable to create archive
from Zippy.php at line 63
and previous exception NotSupportedException: Can not create empty zip archive
from ZipAdapter.php at line 51
Hi,
today I discover that, the:
Unable to create the inflator
exception is thrown when I use PHP in 5.4 version... with 5.3 all is fine
I can't make zippy use only the contents of a folder, it always requires at least one folder up.
For instance:
$source_dir = '/my/path/to/dir';
// Contains: file1, file2, dir1/
$zippy->create('myarchive.zip', $source_dir);
// will contain:
// my/path/to/dir/file1
// my/path/to/dir/file2
// my/path/to/dir/dir1/....
How can I have only
file1
file2
dir1/.... ?
Is there any way to create password protected archives (zip) with Zippy library?
alchemy/zippy 0.1.0 requires pimple/pimple ~1.0 -> no matching package found.
The pimple repo has had some work done recently. Looks like it's breaking your dependency.
Implements factory & strategy to get the best zip adapter according to the current platform and available adapter
$adapter = Zippy\Adapter\Factory::getAdapter('zip');
$adapter = Zippy\Adapter\Factory::getAdapter('tar');
This should not happen, as, by design, the adapter containers can instantiate any of these on demand.
We should test this by injecting the ExecutableFinder
try use this code ,but its show Unable to create archive
directory has 777 promission
use Alchemy\Zippy\Zippy;
$zippy = Zippy::load();
// creates an archive.zip that contains a directory "folder" that contains
// files contained in "/path/to/directory" recursively
$archive = $zippy->create('archive.zip', array(
'folder' => '/path/to/directory'
), recursive = true);
When i try to add a file to the root of the archive it works. But when i try to add a file to a folder inside the archive it fails.
$filePathArray["filename.jpg"] = "/some/path/to/filename.jpg"
OK
$filePathArray["folder/filename.jpg"] = "/some/path/to/filename.jpg"
FAIL
$archive = $zippy->create($zipFilePath, $filePathArray);
Hi,
I get an NoAdapterOnPlatformException
when I attempt to create a tar.gz archive, not sure what I'm missing:
$zippy = Zippy::load();
$zippy->create('test.tar.gz', 'testfiles/');
tar also fails, No adapter available for tar on this platform
$zippy = Zippy::load();
$zippy->create('test.tar', 'testfiles/');
Creating a zip archive does succeed, however.
Zippy 0.3.2 on Ubuntu 14.04.3 LTS
Trace:
Fatal error: Uncaught exception 'Alchemy\Zippy\Exception\NoAdapterOnPlatformException' with message 'No adapter available for tar.gz on this platform' in /var/www/zippy-test/vendor/alchemy/zippy/src/Zippy.php:160
Stack trace:
#0 /var/www/zippy-test/vendor/alchemy/zippy/src/Zippy.php(67): Alchemy\Zippy\Zippy->getAdapterFor('tar.gz')
#1 /var/www/zippy-test/web/index.php(18): Alchemy\Zippy\Zippy->create('test.tar.gz', 'testfiles/')
#2 {main}
Next exception 'Alchemy\Zippy\Exception\RuntimeException' with message 'Unable to create archive' in /var/www/zippy-test/vendor/alchemy/zippy/src/Zippy.php:70
Stack trace:
#0 /var/www/zippy-test/web/index.php(18): Alchemy\Zippy\Zippy->create('test.tar.gz', 'testfiles/')
#1 {main}
thrown in /var/www/zippy-test/vendor/alchemy/zippy/src/Zippy.php on line 70
Hi,
I'm trying to open this zip file;
https://github.com/GoktugOzturk/tet-boardsports/archive/master.zip
On my localhost (windows 10 & php 5.6 )
It works fine.
But on my staging server (Centos & PHP 7.0.6 )
Error occurs:
Argument 5 passed to Alchemy\Zippy\Archive\Member::__construct() must be an instance of DateTime, boolean given, called in /home/project/_shared/vendor/alchemy/zippy/src/Adapter/ZipAdapter.php on line 126
$zippy = \Alchemy\Zippy\Zippy::load();
$archive = $zippy->open($tmpFile);
$archive->extract($tmpThemeDir);
if (!file_exists($tmpThemeDir . "/theme/theme.json")) {
/** @var \Alchemy\Zippy\Archive\MemberInterface[] $zipContents */
$zipContents = $archive->getMembers();
foreach ($zipContents as $zipContent) {
if (substr($zipContent->getLocation(), -16) == "theme/theme.json") {
$tmpThemeDir .= DIRECTORY_SEPARATOR . str_replace("/theme/theme.json", "", $zipContent->getLocation());
}
}
}
It would be nice to have an option to blacklist specific files (e.g. .DS_Store) when adding paths to archive using Zippy::create() method.
Could you please add: .gitattributes
eg:
docs/ export-ignore
tests/ export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.travis.yml export-ignore
CHANGELOG.md export-ignore
README.md export-ignore
composer.lock export-ignore
phpunit-functional.xml.dist export-ignore
phpunit.xml.dist export-ignore
This means if "checking" out for production using composer the files listed here will be ignored and not included in the packages making the size ~130k instead of 17.2Mb
because including 17.2MB in our project is not an option.
-Thanks
Hi !
I'm starting using Zippy to handle zip files, thanks for the job by the way.
If I try to extract a file that already exists, it simply triggers an exception.
Is there any reason extraction of members doesn't have the overwrite option (-o) while the the doExtract does have it ?
I am trying to create a large zip/tar file over 4GB. I know zip file has 4GB limitation. So, I tried tar archive. When I create an archive I get following exception: "Unable to launch a new process."
When I dug deep, I found that your library is adding all files (over 6000+) in a single command line.. Here is the command line:
"D:\cmder\vendor\msysgit\bin\tar.EXE" "--no-recursion" "-c" "--bzip2" "--file=d:\myfile.tar.bz2" "--no-recursion" "long-file-name.jpg" "long-file-name.jpg" "long-file-name.jpg"
Is it possible to add files in chunks instead of all together?
I couldn't find anything in the documentation, is there any way to create an archive split in chunks via Zippy ?
We have a tarball which contains directories and files with accents. When we extract it on windows XP/Vista/Seven, those accents aren't correctly kept.
My code:
git clone [email protected]:MyKiwi/zippy-bug.git
cd zippy-bug
composer install
php test.php
implements a way to handle file mode permissions when creating an archive
Compopser creates an empty src folder. I deleted the files from the cache and again I had the same problem. Is it me?
I tried using Zippy on laravel 4.2 but all i get is an error saying "Unable to create the inflator" can you help?
zip was successfully created,
but triggers error when unable to clean tmp files in IIS 8 Windows Server 2012 r2 (permission denied?)
should there be a fallback when the temp folder is undeleteable?
or, is it better to add an option whether to 'delete the temp on demand' or 'just leave OS do their stuff' ?
thank you
Stacktrace:
IOException in Filesystem.php line 169:
Fa
OException in Filesystem.php line 169:
Failed to remove directory "C:\Windows\TEMP/zippy_56d7a6f724d9f".
in Filesystem.php line 169
at Filesystem->remove('C:\Windows\TEMP/zippy_56d7a6f724d9f') in ResourceManager.php line 89
at ResourceManager->cleanup(object(ResourceCollection)) in ZipExtensionAdapter.php line 290
at ZipExtensionAdapter->addEntries(object(ZipArchiveResource), array('folder' => '../storage/app/cakil/report_delegasi_1456973558/'), true) in ZipExtensionAdapter.php line 207
at ZipExtensionAdapter->doCreate('C:\inetpub\wwwroot\portal-spd-ditpsmk\public\uploads\reports\forms\single/report_1_11.zip', array('folder' => '../storage/app/cakil/report_delegasi_1456973558/'), true) in AbstractAdapter.php line 58
at AbstractAdapter->create('uploads/reports/forms/single/report_1_11.zip', array('folder' => '../storage/app/cakil/report_delegasi_1456973558/'), true) in Zippy.php line 68
at Zippy->create('uploads/reports/forms/single/report_1_11.zip', array('folder' => '../storage/app/cakil/report_delegasi_1456973558/'), true) in FormsReportSingleController.php line 768
at FormsReportSingleController->_generateReportType1(object(CompetitionForms), object(CompetitionFormsResponses)) in FormsReportSingleController.php line 132
at FormsReportSingleController->getReportSingle(object(Request), '1', '11')
at call_user_func_array(array(object(FormsReportSingleController), 'getReportSingle'), array(object(Request), 'id' => '1', 'user_id' => '11')) in Controller.php line 78
at Controller->callAction('getReportSingle', array(object(Request), 'id' => '1', 'user_id' => '11')) in ControllerDispatcher.php line 146
at ControllerDispatcher->call(object(FormsReportSingleController), object(Route), 'getReportSingle') in ControllerDispatcher.php line 94
at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 96
at ControllerDispatcher->callWithinStack(object(FormsReportSingleController), object(Route), object(Request), 'getReportSingle') in ControllerDispatcher.php line 54
at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\Backend\FormsReportSingleController', 'getReportSingle') in Route.php line 174
at Route->runController(object(Request)) in Route.php line 140
at Route->run(object(Request)) in Router.php line 724
at Router->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Authenticate.php line 28
at Authenticate->handle(object(Request), object(Closure))
at call_user_func_array(array(object(Authenticate), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 64
at VerifyCsrfToken->handle(object(Request), object(Closure))
at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 62
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Router.php line 726
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 699
at Router->dispatchToRoute(object(Request)) in Router.php line 675
at Router->dispatch(object(Request)) in Kernel.php line 246
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 44
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Kernel.php line 132
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 99
at Kernel->hane(object(Request)) in index.php line 54
It would be great to detect this extension format as well.
.tar.gz == .tgz
.tar.bz2 == .tbz2 == .tb2
I'm using zippy in a symfony project, and I really like it.
But it really bloats the required dependencies, it installs pimple and guzzle, although I'm neither using pimple for configuration, nor guzzle for the teleport-stuff.
I'd love to see smaller packages for zippy, with the main archive functionality in zippy, and for example zippy-teleport-guzzle as an addon for the guzzle-teleporter, and maybe zippy-pimple for the driver configuration.
I didn't read into the teleporter-stuff very deeply, maybe even a package zippy-teleporter could be created, where the teleporter classes maintained? Don't know if the teleporter classes are used for regular archive handling...
I could provide a zippy-bundle for symfony integration, if someone is interested in this.
All my files in the directory is utf8 encode, after zipped all filenames are converted to LATIN characters.
Greeting from Cambodia.
If you don't have mbstring installed, you'll get this error:
Fatal error: Call to undefined function Alchemy\Zippy\mb_strtolower() in .../vendor/alchemy/zippy/src/Zippy.php on line 196
it would be great if version 0.2.0 could be released
Hi,
I experienced below issue while istalling, Kindly help to fix and install. Thank you.
E:\xampp\htdocs\vijay\service\new\my-platform2-project>composer install
Installing alchemy/zippy (dev-master 624e5d4)
Downloading: 100%
[UnexpectedValueException]
'E:\xampp\htdocs\vijay\service\new\my-platform2-project\vendor/alchemy/zipp
y/1089a8524e8e796241e8d00d36e46b2f' is not a zip archive.
Hi,
Here is the error when I use "tar" :
Unable to execute the following command '/usr/bin/bsdtar' '--create' '-' '--files-from /dev/null' '> /Users/vince/work/web/ps/designerbox/modules/invoices/invoices.tar' {output: bsdtar: Option --files-from /dev/null is not supported Usage: List: bsdtar -tf Extract: bsdtar -xf Create: bsdtar -cf [filenames...] Help: bsdtar --help }
I'm working on Mac with Mavericks (10.9), it looks like he doesnt like the "--files-from /dev/null" command
I tried using Zippy on laravel 4 but all i get is an error saying "Unable to create archive" can you help?
PHP basename function is not safe in UTF-8 system, If the filename starts with an utf8 character, this character will be cut off. Example:
echo basename('Ängelholm');
// print 'ngelholm'
Might be worth define a _basename function and all basename function change to _basename.
In recent versions of tar, the combo of "--overwrite" "--overwrite-dir" is now an error.
[ERROR] Unable to execute the following command '/bin/tar' '--extract' '--file=/tmp/payment.tar.gz' '--overwrite-dir' '--overwrite' '--gzip' '--directory' '[OMITTED]' {output: /bin/tar:
'--overwrite' cannot be used with '--overwrite-dir'
Try '/bin/tar --help' or '/bin/tar --usage' for more information.
}
Is output from drupal console, using the alchemy/zippy module inside its phar file.
Compressed tar archive cannot be updated.
You must Uncompress -> Update -> Decompress
It should write data as long as it fetches it, see https://github.com/alchemy-fr/Zippy/blob/master/src/Alchemy/Zippy/Resource/Teleporter/GuzzleTeleporter.php
Composer as better support, see https://github.com/composer/composer/blob/master/src/Composer/Util/RemoteFilesystem.php#L93
on AdapterInterface listMembers function documented as @return array
it is correct but @return MemberInterface[]
would support better code completion.
Trying to get iterator for zip archive and it fails at ZipAdapter:120 when creating new member because $member[mtime] is not \DateTime
member = Array
(
[location] => Invoice INVD063737 DD 19AUG16 RM10,567.82 - GO TRAVEL UN LIMITED.pdf
[size] => 53273
[mtime] => false
[is_dir] => false
)
Error:
Exception 'TypeError' with message 'Argument 5 passed to Alchemy\Zippy\Archive\Member::__construct() must be an instance of DateTime, boolean given, called in /private/var/www/jr_ota/vendor/alchemy/zippy/src/Adapter/ZipAdapter.php on line 126'
in /private/var/www/jr_ota/vendor/alchemy/zippy/src/Archive/Member.php:74
Stack trace:
#0 /private/var/www/jr_ota/vendor/alchemy/zippy/src/Adapter/ZipAdapter.php(126): Alchemy\Zippy\Archive\Member->__construct(Object(Alchemy\Zippy\Adapter\Resource\FileResource), Object(Alchemy\Zippy\Adapter\ZipAdapter), 'Invoice INVD063...', '53273', false, false)
#1 /private/var/www/jr_ota/vendor/alchemy/zippy/src/Adapter/AbstractAdapter.php(68): Alchemy\Zippy\Adapter\ZipAdapter->doListMembers(Object(Alchemy\Zippy\Adapter\Resource\FileResource))
// 785 2012-10-24 10:39 file
Class ZipOutputParser, line 53
\DateTime::createFromFormat("Y-m-d H:i", $chunks[2]);
I am trying to get the archive members, and see this error.
When I tracked the error, I noticed the command "unzip -l" returned the different date time format.
Centos: 10-23-2015 20:56
Mac 10.11: 10-23-15 20:56
How can I fix it or change it?
Thanks a lot.
It's been almost a year with no tag. I'm took over project where dev dependency is used, which is really bad idea, that might cause breaking thing per commit.
Could you please tag new version?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.