{"id":32691621,"url":"https://github.com/maxkhim/laravel-storage-dedupler","last_synced_at":"2026-03-01T18:31:25.082Z","repository":{"id":320594689,"uuid":"1077099088","full_name":"maxkhim/laravel-storage-dedupler","owner":"maxkhim","description":"Laravel Package Prevents File Duplication","archived":false,"fork":false,"pushed_at":"2025-11-14T16:08:05.000Z","size":342,"stargazers_count":35,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-14T18:19:17.180Z","etag":null,"topics":["deduplication","file-storage","laravel","laravel-package"],"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/maxkhim.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-15T19:19:32.000Z","updated_at":"2025-11-14T12:09:11.000Z","dependencies_parsed_at":"2025-10-24T18:29:57.122Z","dependency_job_id":null,"html_url":"https://github.com/maxkhim/laravel-storage-dedupler","commit_stats":null,"previous_names":["maxkhim/laravel-storage-dedupler"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/maxkhim/laravel-storage-dedupler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxkhim%2Flaravel-storage-dedupler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxkhim%2Flaravel-storage-dedupler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxkhim%2Flaravel-storage-dedupler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxkhim%2Flaravel-storage-dedupler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maxkhim","download_url":"https://codeload.github.com/maxkhim/laravel-storage-dedupler/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxkhim%2Flaravel-storage-dedupler/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29978475,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-01T16:35:47.903Z","status":"ssl_error","status_checked_at":"2026-03-01T16:35:44.899Z","response_time":124,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["deduplication","file-storage","laravel","laravel-package"],"created_at":"2025-11-01T15:01:25.878Z","updated_at":"2026-03-01T18:31:25.074Z","avatar_url":"https://github.com/maxkhim.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"# Dedupler - Laravel package prevent's file duplications\n\n[![Latest Version](https://img.shields.io/packagist/v/maxkhim/laravel-storage-dedupler.svg?style=flat\u0026label=Packagist\u0026logo=packagist\u0026logoColor=ffffff)](https://packagist.org/packages/maxkhim/laravel-storage-dedupler)\n[![Laravel](https://img.shields.io/badge/Laravel-10+-007ec6.svg?logo=laravel\u0026logoColor=ffffff)](https://laravel.com)\n[![License](https://img.shields.io/packagist/l/maxkhim/laravel-storage-dedupler.svg?color=007ec6\u0026label=License)](https://packagist.org/packages/maxkhim/laravel-storage-dedupler)\n\n### Stop storing duplicate files in your Laravel application.\n\nTired of seeing the same file stored multiple times? When users upload duplicates, your storage bloats, backups grow, and data consistency suffers.\n\n**Dedupler** is an elegant Laravel package that solves this once and for all. It automatically prevents file duplicates using SHA-1 hashing and provides a beautiful polymorphic API to manage your attachments.\n\n## ✨ Why Dedupler?\n\n- 🚫 **Zero Duplicates** - Automatic deduplication using SHA-1 hashing\n- 🔗 **Polymorphic Magic** - Attach files to any model with ease\n- 💾 **Storage Efficient** - Save significant disk space\n- 🎯 **Simple API** - Intuitive methods for attachment management\n- ⚡  **Laravel Native** - Seamlessly integrates with Laravel's ecosystem\n\n## 🚀 Quick Start\n\n### 1. Install via Composer\n```bash\ncomposer require maxkhim/laravel-storage-dedupler\n```\n\n####  (Optional) Analyse legacy storage directory \n\nFinds duplicate files by SHA1 hash in directory and subdirectories and calculate potential disk space savings\n\n```bash\nphp artisan dedupler:analyse-legacy /absolute/path/to/legacy/storage/directory\n```\n\n### 2. Init package\n\nThis command make all necessary migrations,\nand verifies application configuration (storage, models, etc.) to ensure the package is ready to use\n```bash\nphp artisan dedupler:install\n```\n\n## 🔧 How to use\n\n### 1. Use Facade Dedupler to Store Deduplicated files\n\n```php\n/** @var \\Illuminate\\Http\\UploadedFile $file */\n/** @var \\Maxkhim\\Dedupler\\Models\\UniqueFile $uniqueFile */\n$uniqueFile = Dedupler::storeFromUploadedFile($file);\n```\n\n```php\n/** @var string $absolutePathToFile */\n/** @var \\Maxkhim\\Dedupler\\Models\\UniqueFile $uniqueFile */\n$uniqueFile = Dedupler::storeFromPath($absolutePathToFile);\n```\n\n```php\n/** @var string $fileContent */\n/** @var \\Maxkhim\\Dedupler\\Models\\UniqueFile $uniqueFile */\n$uniqueFile = Dedupler::storeFromContent($content, 'direct_content_file.ext');\n```\n\n### 2. Add Trait to Your Model to keep deduplicated files attached to models\n\n```php\n\u003c?php\n\nnamespace App\\Models;\n\nuse Illuminate\\Database\\Eloquent\\Model;\nuse Maxkhim\\Dedupler\\Traits\\Deduplable;\n\nclass Post extends Model\n{\n    use Deduplable;\n}\n\n$post = new Post([...]);\n```\n\n```php\n/** @var \\Illuminate\\Http\\UploadedFile $file */\n/** @var \\Maxkhim\\Dedupler\\Models\\UniqueFile $uniqueFile */\n$uniqueFile = $post-\u003estoreUploadedFile($file);\n```\n\n```php\n/** @var \\Maxkhim\\Dedupler\\Models\\UniqueFile $uniqueFile */\n$uniqueFile = $post-\u003estoreLocalFile($absolutePathToFile);\n```\n\n```php\n/** @var \\Maxkhim\\Dedupler\\Models\\UniqueFile $uniqueFile */\n$uniqueFile = $post-\u003estoreContentFile($content, 'direct_content_file.ext');\n```\n\n### 3. Detach unique files from models\n\n```php\n$post-\u003edetachUniqueFile($sha1_hash)\n```\n\n## About Deduplication\n\nWhen you upload the same file multiple times:\n\n```php\n// First upload - file is stored\n$file1 = $post-\u003estoreUploadedFile($sameFile);\nOR\n$file1 = Dedupler::storeFromUploadedFile($sameFile);\n// Second upload - returns existing UniqueFile, no duplicate created\n$file2 = $post-\u003estoreUploadedFile($sameFile);\nOR\n$file1 = Dedupler::storeFromUploadedFile($sameFile);\n\n$file1-\u003eid === $file2-\u003eid; // true - same database record and same file in storage\n```\n\n## 🛣️ API Reference\n\n### Enable RESTapi endpoint to check file existence\n\n```dotenv\nDEDUPLER_REST_ENABLED=true\n```\n\n```http request\nGET http://localhost:8080/api/dedupler/v1/files/da39a3ee5e6b4b0d3255bfef95601890afd80709\n```\n\n```json\n{\n\t\"success\": true,\n\t\"data\": {\n\t\t\"hash\": \"da39a3ee5e6b4b0d3255bfef95601890afd80709\",\n\t\t\"sha1_hash\": \"da39a3ee5e6b4b0d3255bfef95601890afd80709\",\n\t\t\"md5_hash\": \"d41d8cd98f00b204e9800998ecf8427e\",\n\t\t\"exists\": false,\n\t\t\"filename\": \"da39a3ee5e6b4b0d3255bfef95601890afd80709.pdf\",\n\t\t\"path\": \"da\\/39\\/da39a3ee5e6b4b0d3255bfef95601890afd80709.pdf\",\n\t\t\"mime_type\": \"application\\/pdf\",\n\t\t\"size\": 102400,\n\t\t\"size_human\": \"100 KB\",\n\t\t\"disk\": \"deduplicated\",\n\t\t\"status\": \"completed\",\n\t\t\"created_at\": \"2025-10-22T18:40:41.000000Z\",\n\t\t\"updated_at\": \"2025-10-22T18:40:41.000000Z\",\n\t\t\"links_count\": 94\n\t}\n}\n```\n\n## License\n\nThe MIT License (MIT).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxkhim%2Flaravel-storage-dedupler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaxkhim%2Flaravel-storage-dedupler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxkhim%2Flaravel-storage-dedupler/lists"}