{"id":24844435,"url":"https://github.com/quranacademy/b2-php-sdk","last_synced_at":"2025-03-26T07:44:13.638Z","repository":{"id":62532292,"uuid":"187455130","full_name":"quranacademy/b2-php-sdk","owner":"quranacademy","description":"An SDK for working with B2 cloud storage","archived":false,"fork":false,"pushed_at":"2019-05-19T12:42:44.000Z","size":21,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-31T09:18:46.809Z","etag":null,"topics":["b2","backblaze"],"latest_commit_sha":null,"homepage":null,"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/quranacademy.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-19T09:04:18.000Z","updated_at":"2022-09-25T11:07:55.000Z","dependencies_parsed_at":"2022-11-02T14:33:08.265Z","dependency_job_id":null,"html_url":"https://github.com/quranacademy/b2-php-sdk","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quranacademy%2Fb2-php-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quranacademy%2Fb2-php-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quranacademy%2Fb2-php-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quranacademy%2Fb2-php-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/quranacademy","download_url":"https://codeload.github.com/quranacademy/b2-php-sdk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245614989,"owners_count":20644376,"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":["b2","backblaze"],"created_at":"2025-01-31T09:18:49.748Z","updated_at":"2025-03-26T07:44:13.609Z","avatar_url":"https://github.com/quranacademy.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Backblaze B2 SDK for PHP\n\n[![Build Status](https://img.shields.io/travis/quranacademy/b2-php-sdk.svg?style=flat-square)](https://travis-ci.org/quranacademy/b2-php-sdk)\n[![Total Downloads](https://img.shields.io/packagist/dt/quranacademy/b2-php-sdk.svg?style=flat-square)](https://packagist.org/packages/quranacademy/b2-php-sdk)\n[![Latest Version](https://img.shields.io/github/release/quranacademy/b2-php-sdk.svg?style=flat-square)](https://github.com/quranacademy/b2-php-sdk/releases)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)\n\n`b2-php-sdk` is a client library for working with Backblaze B2 storage service. It aims to make using the service as\neasy as possible by exposing a clear API and taking influence from other SDKs that you may be familiar with.\n\n**[Backblaze B2 documentation](https://www.backblaze.com/b2/docs/)**\n\n## Installation\n\nTo install Backblaze B2 SDK run the command:\n\n```bash\n$ composer require quranacademy/b2-php-sdk\n```\n\n## Usage\n\nMost methods of the SDK returns the body of the response from B2 API.\nCheck out [Backblaze B2 documentation](https://www.backblaze.com/b2/docs/) to see what fields will be returned.\n\n```php\nuse Backblaze\\B2Client;\nuse Backblaze\\HttpClient\\CurlHttpClient;\n\n$httpClient = new CurlHttpClient();\n\n$client = new B2Client($httpClient);\n\n$client-\u003eauthorize('accountId', 'applicationKey');\n\n// see \"b2_create_bucket\" operation in the docs\n$bucket = $client-\u003ecreateBucket([\n    'BucketName' =\u003e 'my-bucket',\n    'BucketType' =\u003e B2Client::BUCKET_TYPE_PRIVATE, // or BUCKET_TYPE_PUBLIC\n]);\n\n// change the bucket to public\n// see \"b2_update_bucket\"\n$updatedBucket = $client-\u003eupdateBucket([\n    'BucketId' =\u003e $bucket['bucketId'],\n    'BucketType' =\u003e B2Client::BUCKET_TYPE_PUBLIC,\n]);\n\n// retrieve a list of buckets on your account\n// see \"b2_list_buckets\"\n$buckets = $client-\u003elistBuckets();\n\n// delete a bucket\n// see \"b2_delete_bucket\"\n$client-\u003edeleteBucket([\n    'BucketId' =\u003e $bucket['bucketId'],\n]);\n\n// retrieve an array of file objects from a bucket\n// see \"b2_list_file_names\"\n$fileList = $client-\u003elistFiles([\n    'BucketId' =\u003e '4a48fe8875c6214145260818',\n]);\n\n$fileExistence = $client-\u003efileExists([\n    'BucketId' =\u003e '4a48fe8875c6214145260818',\n    'file' =\u003e 'path/to/file',\n]);\n\n// upload a file to a bucket\n// see \"b2_upload_file\"\n$file = $client-\u003eupload([\n    'BucketId' =\u003e '4a48fe8875c6214145260818',\n    'FileName' =\u003e 'path/to/upload/to',\n    'Body' =\u003e 'File content',\n\n    // the file content can also be provided via a resource\n    // 'Body' =\u003e fopen('/path/to/source/file', 'r'),\n\n    // or as the path to a source file\n    // 'SourceFile' =\u003e '/path/to/source/file',\n]);\n\n$fileId = '4_z942111fa0b943d89249a0815_f1001e9fa2c42d9a8_d20170119_m162445_c001_v0001032_t0057';\n\n// download a file from a bucket\n$client-\u003edownload([\n    'FileId' =\u003e $fileId,\n    'SaveAs' =\u003e '/path/to/save/location',\n]);\n\n// delete a file from a bucket\n// see \"b2_delete_file_version\"\n$fileDelete = $client-\u003edeleteFile([\n    'FileId' =\u003e $fileId,\n    'FileName' =\u003e '/path/to/file',\n]);\n```\n\n## Tests\n\nTests are run with PHPUnit. After installing PHPUnit via Composer:\n\n```bash\n$ vendor/bin/phpunit\n```\n\n## Contributors\n\nFeel free to contribute in any way you can whether that be reporting issues, making suggestions or sending PRs.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquranacademy%2Fb2-php-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquranacademy%2Fb2-php-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquranacademy%2Fb2-php-sdk/lists"}