{"id":29990623,"url":"https://github.com/imponeer/archive-download-builder","last_synced_at":"2026-01-20T16:44:58.892Z","repository":{"id":308059025,"uuid":"1031512192","full_name":"imponeer/archive-download-builder","owner":"imponeer","description":"A PHP library for building and downloading archive files (ZIP and TAR.GZ) with optional Flysystem support for various file sources","archived":false,"fork":false,"pushed_at":"2025-08-03T23:07:45.000Z","size":0,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-03T23:20:43.113Z","etag":null,"topics":["archive-builder","composer-library","psr-7","response-builder","response-tar","response-zip"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/imponeer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-03T22:33:56.000Z","updated_at":"2025-08-03T23:07:48.000Z","dependencies_parsed_at":"2025-08-03T23:21:04.611Z","dependency_job_id":null,"html_url":"https://github.com/imponeer/archive-download-builder","commit_stats":null,"previous_names":["imponeer/archive-download-builder"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/imponeer/archive-download-builder","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imponeer%2Farchive-download-builder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imponeer%2Farchive-download-builder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imponeer%2Farchive-download-builder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imponeer%2Farchive-download-builder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imponeer","download_url":"https://codeload.github.com/imponeer/archive-download-builder/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imponeer%2Farchive-download-builder/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268626724,"owners_count":24280584,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-03T02:00:12.545Z","response_time":2577,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["archive-builder","composer-library","psr-7","response-builder","response-tar","response-zip"],"created_at":"2025-08-04T23:43:24.348Z","updated_at":"2026-01-20T16:44:58.746Z","avatar_url":"https://github.com/imponeer.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Archive Download Builder\n\n[![PHP Version](https://img.shields.io/badge/php-%5E8.3-blue)](https://php.net)\n[![License](https://img.shields.io/badge/license-MIT-green)](LICENSE.md)\n[![Latest Release](https://img.shields.io/github/v/release/imponeer/archive-download-builder)](https://github.com/imponeer/archive-download-builder/releases)\n[![Downloads](https://img.shields.io/packagist/dt/imponeer/archive-download-builder)](https://packagist.org/packages/imponeer/archive-download-builder)\n\nA PHP library for building and downloading archive files (ZIP and TAR.GZ) with support for various file sources through the [Flysystem](https://flysystem.thephpleague.com/) abstraction layer.\n\nThis library is a modern rewrite of the [XOOPS](https://xoops.org/) downloader classes ([Downloader](https://github.com/XOOPS/XoopsCore25/blob/master/htdocs/class/downloader.php), [ZipDownloader](https://github.com/XOOPS/XoopsCore25/blob/master/htdocs/class/zipdownloader.php), [TarDownloader](https://github.com/XOOPS/XoopsCore25/blob/master/htdocs/class/tardownloader.php)) with MIT license compatibility and modern PHP coding standards.\n\n## Installation\n\nInstall via Composer:\n\n```bash\ncomposer require imponeer/archive-download-builder\n```\n\n## Examples\n\n### Simple ZIP Archive (using default filesystem)\n\n```php\n\u003c?php\n\nuse Imponeer\\ArchiveDownloadBuilder\\ZipDownloader;\n\n// Create ZIP downloader (uses entire filesystem as base when no filesystem is specified)\n$downloader = new ZipDownloader();\n\n// Add files from anywhere on the filesystem\n$downloader-\u003eaddFile('/path/to/document.pdf');\n$downloader-\u003eaddFile('/home/user/image.jpg', 'renamed-image.jpg');\n\n// Add file data directly\n$downloader-\u003eaddFileData('Hello World!', 'hello.txt');\n\n// Generate and download\n$downloader-\u003edownload('my-archive');\n```\n\n### ZIP Archive with Custom Filesystem\n\n```php\n\u003c?php\n\nuse Imponeer\\ArchiveDownloadBuilder\\ZipDownloader;\nuse League\\Flysystem\\Filesystem;\nuse League\\Flysystem\\Local\\LocalFilesystemAdapter;\n\n// Create filesystem adapter for a specific directory\n$filesystem = new Filesystem(new LocalFilesystemAdapter('/path/to/files'));\n\n// Create ZIP downloader with custom filesystem\n$downloader = new ZipDownloader(filesystem: $filesystem);\n\n// Add files to archive (paths are relative to the filesystem adapter)\n$downloader-\u003eaddFile('document.pdf');\n$downloader-\u003eaddFile('image.jpg', 'renamed-image.jpg');\n\n// Add file data directly\n$downloader-\u003eaddFileData('Hello World!', 'hello.txt');\n\n// Generate and download\n$downloader-\u003edownload('my-archive');\n```\n\n### Basic TAR.GZ Archive\n\n```php\n\u003c?php\n\nuse Imponeer\\ArchiveDownloadBuilder\\TarDownloader;\nuse League\\Flysystem\\Filesystem;\nuse League\\Flysystem\\Local\\LocalFilesystemAdapter;\n\n// Create filesystem adapter\n$filesystem = new Filesystem(new LocalFilesystemAdapter('/path/to/files'));\n\n// Create TAR downloader\n$downloader = new TarDownloader(filesystem: $filesystem);\n\n// Add files to archive\n$downloader-\u003eaddFile('config.json');\n$downloader-\u003eaddBinaryFile('data.bin', 'backup-data.bin');\n\n// Generate and download\n$downloader-\u003edownload('backup');\n```\n\n### Custom MIME Types and Extensions\n\n```php\n// Custom ZIP configuration\n$zipDownloader = new ZipDownloader(\n    ext: '.custom.zip',\n    mimetype: 'application/custom-zip',\n    filesystem: $filesystem\n);\n\n// Custom TAR configuration\n$tarDownloader = new TarDownloader(\n    ext: '.backup.tar.gz',\n    mimetype: 'application/x-compressed-tar',\n    filesystem: $filesystem,\n    tmpPath: '/custom/temp/path'\n);\n```\n\n### Working with Different Filesystems\n\n```php\nuse League\\Flysystem\\Filesystem;\nuse League\\Flysystem\\InMemory\\InMemoryFilesystemAdapter;\nuse League\\Flysystem\\Ftp\\FtpAdapter;\nuse League\\Flysystem\\AwsS3V3\\AwsS3V3Adapter;\n\n// In-memory filesystem\n$memoryFs = new Filesystem(new InMemoryFilesystemAdapter());\n$downloader = new ZipDownloader(filesystem: $memoryFs);\n\n// FTP filesystem\n$ftpFs = new Filesystem(new FtpAdapter($ftpConfig));\n$downloader = new ZipDownloader(filesystem: $ftpFs);\n\n// AWS S3 filesystem\n$s3Fs = new Filesystem(new AwsS3V3Adapter($s3Client, $bucket));\n$downloader = new ZipDownloader(filesystem: $s3Fs);\n```\n\n### PSR-7 Response Integration\n\n```php\n// Get PSR-7 response instead of direct download\n$response = $downloader-\u003etoResponse('archive-name');\n\n// Use with your favorite HTTP framework\n// Symfony\nreturn new Response($response-\u003egetBody(), $response-\u003egetStatusCode(), $response-\u003egetHeaders());\n\n// Laravel\nreturn response($response-\u003egetBody(), $response-\u003egetStatusCode(), $response-\u003egetHeaders());\n\n// Slim Framework\nreturn $response; // Direct usage\n```\n\n### Bulk File Operations\n\n```php\nuse League\\Flysystem\\FileAttributes;\n\n// Add all files from a directory\nforeach ($filesystem-\u003elistContents('/documents', true) as $item) {\n    if ($item instanceof FileAttributes) {\n        $downloader-\u003eaddFile($item-\u003epath());\n    }\n}\n\n// Add files with custom naming pattern\n$files = ['report1.pdf', 'report2.pdf', 'summary.doc'];\nforeach ($files as $index =\u003e $file) {\n    $downloader-\u003eaddFile($file, sprintf('report_%02d_%s', $index + 1, basename($file)));\n}\n```\n\n### Error Handling\n\n```php\nuse PhpZip\\Exception\\ZipException;\nuse League\\Flysystem\\FilesystemException;\n\ntry {\n    $downloader = new ZipDownloader(filesystem: $filesystem);\n    $downloader-\u003eaddFile('nonexistent-file.txt');\n    $downloader-\u003edownload('archive');\n} catch (FilesystemException $e) {\n    // Handle filesystem errors (file not found, permission issues, etc.)\n    echo \"Filesystem error: \" . $e-\u003egetMessage();\n} catch (ZipException $e) {\n    // Handle ZIP-specific errors\n    echo \"ZIP error: \" . $e-\u003egetMessage();\n}\n```\n\n## Documentation\n\nAPI documentation is automatically generated and available in the [project's wiki](https://github.com/imponeer/archive-download-builder/wiki). For more detailed information about the classes and methods, please refer to the project wiki.\n\n## Development\n\n### Running Tests\n\n```bash\ncomposer test\n```\n\n### Code Quality\n\n```bash\n# PHP CodeSniffer\ncomposer phpcs\n\n# Fix coding standards\ncomposer phpcbf\n\n# Static analysis\ncomposer phpstan\n```\n\n## Contributing\n\n1. Fork the repository\n2. Create a feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\nPlease ensure your code follows PSR-12 standards and includes appropriate tests.\n\n## Support\n\nFor issues and questions, please use the [GitHub Issues](https://github.com/imponeer/archive-download-builder/issues) page.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimponeer%2Farchive-download-builder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimponeer%2Farchive-download-builder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimponeer%2Farchive-download-builder/lists"}