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
- Relinking MSP360 Backups After a Cloud to B2 Migration
- How to use Synology Hyper Backup with Backblaze B2 Cloud Storage and B2 Fireball Rapid Ingest
- Veeam Cloud Repository Recovery from Backblaze B2
- Configuring Filezilla Pro to use Backblaze B2 Cloud Storage
- Configuring QNAP HybridMount to use Backblaze B2 Cloud Storage
- How to use SimpleBackups with Backblaze B2 Cloud Storage
- How to transfer your photos and videos from Facebook to Backblaze B2
- Copying Active Backup data to Backblaze B2 with Hyper Backup
- Quickstart Guide using S5cmd with B2 Cloud Storage
- Using Arcserve UDP with B2 Cloud Storage