{"id":15916882,"url":"https://github.com/utopia-php/storage","last_synced_at":"2025-05-16T12:06:14.283Z","repository":{"id":38455958,"uuid":"331454002","full_name":"utopia-php/storage","owner":"utopia-php","description":"Lite \u0026 fast micro PHP storage library that is **easy to use**.","archived":false,"fork":false,"pushed_at":"2025-03-06T09:48:18.000Z","size":38108,"stargazers_count":30,"open_issues_count":21,"forks_count":61,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-04-02T08:05:58.287Z","etag":null,"topics":["hacktoberfest","php"],"latest_commit_sha":null,"homepage":"https://appwrite.io","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/utopia-php.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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}},"created_at":"2021-01-20T22:53:55.000Z","updated_at":"2025-03-25T17:59:34.000Z","dependencies_parsed_at":"2024-01-12T03:36:49.908Z","dependency_job_id":"28c4922f-5339-47b2-bad1-867ab168e294","html_url":"https://github.com/utopia-php/storage","commit_stats":{"total_commits":372,"total_committers":30,"mean_commits":12.4,"dds":0.4946236559139785,"last_synced_commit":"fca59127b069b467266f7e173dae2679d4ec7e7b"},"previous_names":[],"tags_count":39,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utopia-php%2Fstorage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utopia-php%2Fstorage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utopia-php%2Fstorage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utopia-php%2Fstorage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/utopia-php","download_url":"https://codeload.github.com/utopia-php/storage/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248018032,"owners_count":21034045,"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","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":["hacktoberfest","php"],"created_at":"2024-10-06T18:06:12.396Z","updated_at":"2025-05-16T12:06:14.270Z","avatar_url":"https://github.com/utopia-php.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Utopia Storage\n\n[![Build Status](https://travis-ci.org/utopia-php/storage.svg?branch=master)](https://travis-ci.com/utopia-php/storage)\n![Total Downloads](https://img.shields.io/packagist/dt/utopia-php/storage.svg)\n[![Discord](https://img.shields.io/discord/564160730845151244?label=discord)](https://appwrite.io/discord)\n\nUtopia Storage is a simple and lightweight library for managing application storage across multiple adapters. This library is designed to be easy to learn and use, with a consistent API regardless of the storage provider. This library is maintained by the [Appwrite team](https://appwrite.io).\n\nThis library is part of the [Utopia Framework](https://github.com/utopia-php/framework) project.\n\n## Getting Started\n\nInstall using composer:\n```bash\ncomposer require utopia-php/storage\n```\n\n### Basic Usage\n\n```php\n\u003c?php\n\nrequire_once '../vendor/autoload.php';\n\nuse Utopia\\Storage\\Storage;\nuse Utopia\\Storage\\Device\\Local;\nuse Utopia\\Storage\\Device\\S3;\nuse Utopia\\Storage\\Device\\DOSpaces;\nuse Utopia\\Storage\\Device\\Backblaze;\nuse Utopia\\Storage\\Device\\Linode;\nuse Utopia\\Storage\\Device\\Wasabi;\n\n// Set up a storage device (only need to choose one)\nStorage::setDevice('files', new Local('/path/to/storage'));\n\n// Common operations with any device\n$device = Storage::getDevice('files');\n\n// Upload a file\n$device-\u003eupload('/local/path/to/file.png', 'destination/path/file.png');\n\n// Check if file exists\n$exists = $device-\u003eexists('destination/path/file.png');\n\n// Read file contents\n$contents = $device-\u003eread('destination/path/file.png');\n\n// Delete a file\n$device-\u003edelete('destination/path/file.png');\n```\n\n## Available Adapters\n\n### Local Storage\n\nUse the local filesystem for storing files.\n\n```php\nuse Utopia\\Storage\\Storage;\nuse Utopia\\Storage\\Device\\Local;\n\n// Initialize local storage\nStorage::setDevice('files', new Local('/path/to/storage'));\n```\n\n### AWS S3\n\nStore files in Amazon S3 or compatible services.\n\n```php\nuse Utopia\\Storage\\Storage;\nuse Utopia\\Storage\\Device\\S3;\n\n// Initialize S3 storage\nStorage::setDevice('files', new S3(\n    'root', // Root path in bucket\n    'YOUR_ACCESS_KEY',\n    'YOUR_SECRET_KEY',\n    'YOUR_BUCKET_NAME',\n    S3::US_EAST_1, // Region (default: us-east-1)\n    S3::ACL_PRIVATE // Access control (default: private)\n));\n\n// Available regions\n// S3::US_EAST_1, S3::US_EAST_2, S3::US_WEST_1, S3::US_WEST_2, S3::AP_SOUTH_1, \n// S3::AP_NORTHEAST_1, S3::AP_NORTHEAST_2, S3::AP_NORTHEAST_3, S3::AP_SOUTHEAST_1,\n// S3::AP_SOUTHEAST_2, S3::EU_CENTRAL_1, S3::EU_WEST_1, S3::EU_WEST_2, S3::EU_WEST_3,\n// And more - check the S3 class for all available regions\n\n// Available ACL options\n// S3::ACL_PRIVATE, S3::ACL_PUBLIC_READ, S3::ACL_PUBLIC_READ_WRITE, S3::ACL_AUTHENTICATED_READ\n```\n\n### DigitalOcean Spaces\n\nStore files in DigitalOcean Spaces.\n\n```php\nuse Utopia\\Storage\\Storage;\nuse Utopia\\Storage\\Device\\DOSpaces;\n\n// Initialize DO Spaces storage\nStorage::setDevice('files', new DOSpaces(\n    'root', // Root path in bucket\n    'YOUR_ACCESS_KEY',\n    'YOUR_SECRET_KEY',\n    'YOUR_BUCKET_NAME',\n    DOSpaces::NYC3, // Region (default: nyc3)\n    DOSpaces::ACL_PRIVATE // Access control (default: private)\n));\n\n// Available regions\n// DOSpaces::NYC3, DOSpaces::SGP1, DOSpaces::FRA1, DOSpaces::SFO2, DOSpaces::SFO3, DOSpaces::AMS3\n```\n\n### Backblaze B2\n\nStore files in Backblaze B2 Cloud Storage.\n\n```php\nuse Utopia\\Storage\\Storage;\nuse Utopia\\Storage\\Device\\Backblaze;\n\n// Initialize Backblaze storage\nStorage::setDevice('files', new Backblaze(\n    'root', // Root path in bucket\n    'YOUR_ACCESS_KEY',\n    'YOUR_SECRET_KEY',\n    'YOUR_BUCKET_NAME',\n    Backblaze::US_WEST_004, // Region (default: us-west-004)\n    Backblaze::ACL_PRIVATE // Access control (default: private)\n));\n\n// Available regions (clusters)\n// Backblaze::US_WEST_000, Backblaze::US_WEST_001, Backblaze::US_WEST_002, \n// Backblaze::US_WEST_004, Backblaze::EU_CENTRAL_003\n```\n\n### Linode Object Storage\n\nStore files in Linode Object Storage.\n\n```php\nuse Utopia\\Storage\\Storage;\nuse Utopia\\Storage\\Device\\Linode;\n\n// Initialize Linode storage\nStorage::setDevice('files', new Linode(\n    'root', // Root path in bucket\n    'YOUR_ACCESS_KEY',\n    'YOUR_SECRET_KEY',\n    'YOUR_BUCKET_NAME',\n    Linode::EU_CENTRAL_1, // Region (default: eu-central-1)\n    Linode::ACL_PRIVATE // Access control (default: private)\n));\n\n// Available regions\n// Linode::EU_CENTRAL_1, Linode::US_SOUTHEAST_1, Linode::US_EAST_1, Linode::AP_SOUTH_1\n```\n\n### Wasabi Cloud Storage\n\nStore files in Wasabi Cloud Storage.\n\n```php\nuse Utopia\\Storage\\Storage;\nuse Utopia\\Storage\\Device\\Wasabi;\n\n// Initialize Wasabi storage\nStorage::setDevice('files', new Wasabi(\n    'root', // Root path in bucket\n    'YOUR_ACCESS_KEY',\n    'YOUR_SECRET_KEY',\n    'YOUR_BUCKET_NAME',\n    Wasabi::EU_CENTRAL_1, // Region (default: eu-central-1)\n    Wasabi::ACL_PRIVATE // Access control (default: private)\n));\n\n// Available regions\n// Wasabi::US_EAST_1, Wasabi::US_EAST_2, Wasabi::US_WEST_1, Wasabi::US_CENTRAL_1,\n// Wasabi::EU_CENTRAL_1, Wasabi::EU_CENTRAL_2, Wasabi::EU_WEST_1, Wasabi::EU_WEST_2,\n// Wasabi::AP_NORTHEAST_1, Wasabi::AP_NORTHEAST_2\n```\n\n## Common Operations\n\nAll storage adapters provide a consistent API for working with files:\n\n```php\n// Get storage device\n$device = Storage::getDevice('files');\n\n// Upload a file\n$device-\u003eupload('/path/to/local/file.jpg', 'remote/path/file.jpg');\n\n// Check if file exists\n$exists = $device-\u003eexists('remote/path/file.jpg');\n\n// Get file size\n$size = $device-\u003egetFileSize('remote/path/file.jpg');\n\n// Get file MIME type\n$mime = $device-\u003egetFileMimeType('remote/path/file.jpg');\n\n// Get file MD5 hash\n$hash = $device-\u003egetFileHash('remote/path/file.jpg');\n\n// Read file contents\n$contents = $device-\u003eread('remote/path/file.jpg');\n\n// Read partial file contents\n$chunk = $device-\u003eread('remote/path/file.jpg', 0, 1024); // Read first 1KB\n\n// Multipart/chunked uploads\n$device-\u003eupload('/local/file.mp4', 'remote/video.mp4', 1, 3); // Part 1 of 3\n\n// Create directory\n$device-\u003ecreateDirectory('remote/new-directory');\n\n// List files in directory\n$files = $device-\u003elistFiles('remote/directory');\n\n// Delete file\n$device-\u003edelete('remote/path/file.jpg');\n\n// Delete directory\n$device-\u003edeleteDirectory('remote/directory');\n\n// Transfer files between storage devices\n$sourceDevice = Storage::getDevice('source');\n$targetDevice = Storage::getDevice('target');\n\n$sourceDevice-\u003etransfer('source/path.jpg', 'target/path.jpg', $targetDevice);\n```\n\n## Adding New Adapters\n\nFor information on adding new storage adapters, see the [Adding New Storage Adapter](https://github.com/utopia-php/storage/blob/master/docs/adding-new-storage-adapter.md) guide.\n\n## System Requirements\n\nUtopia Storage requires PHP 7.4 or later. We recommend using the latest PHP version whenever possible.\n\n## Contributing\n\nFor security issues, please email [security@appwrite.io](mailto:security@appwrite.io) instead of posting a public issue in GitHub.\n\nAll code contributions - including those of people having commit access - must go through a pull request and be approved by a core developer before being merged. This is to ensure a proper review of all the code.\n\nWe welcome you to contribute to the Utopia Storage library. For details on how to do this, please refer to our [Contributing Guide](https://github.com/utopia-php/storage/blob/master/CONTRIBUTING.md).\n\n## License\n\nThis library is available under the MIT License.\n\n## Copyright\n\n```\nCopyright (c) 2019-2025 Appwrite Team \u003cteam@appwrite.io\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Futopia-php%2Fstorage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Futopia-php%2Fstorage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Futopia-php%2Fstorage/lists"}