PHP developers are able to take advantage of B2 Cloud Storage by leveraging the AWS SDK for PHP alongside the S3 Compatible API. Pre-Signed URLs generated with the PHP SDK are not currently compatible with B2 Cloud Storage. Below is an example of creating a bucket using the AWS SDK for PHP along with a profile named “b2” in the ~/.aws/credentials file.
// Include the SDK using the Composer autoloader
require '<path for>/vendor/autoload.php';
// Instantiate the S3 client using your B2profile
$s3Client = S3Client::factory(array(
'endpoint' => 'https://s3.us-west-002.backblazeb2.com',
'profile' => 'b2',
'region' => 'us-west-002',
'version' => 'latest',
//Sample to create a bucket
$s3Client->createBucket(array('Bucket' => '<bucket-name>'));
Please note that if you are using a bucket-restricted Application Key that it will require the List All Bucket Names permission to work successfully with the S3 Compatible API. If you did not select this when you created your Application Key you will need to create a new key with the required permission enabled.
The S3 Compatible API for Backblaze B2 Cloud Storage allows 1000’s of integrations to work with B2 natively. If you’re new to the S3 Compatible API, please see our Getting Started Guide. If you have any trouble using the AWS SDK for PHP with B2, please let us know by emailing us at firstname.lastname@example.org.
Articles in this section
- Object Lock FAQs
- Delivering Private Backblaze B2 Content Through Cloudflare CDN
- Bunny Integration Quick Start Guide
- Guide for using Fastly Compute @ Edge with Backblaze B2
- SSE Command Line and API Examples
- Does the B2 S3 Compatible API support Pre-Signed URLs?
- How to use Fastly CDN with B2
- Using the AWS SDK for Java (v2) with B2
- How to use the AWS SDK for Python with B2.
- Using the AWS SDK for PHP with Backblaze B2 Cloud Storage