https://github.com/open-southeners/carbone-sdk
Unofficial port of the Carbone API SDK to Saloon v3
https://github.com/open-southeners/carbone-sdk
api-sdk carbone document-generator framework-agnostic laravel-package php8
Last synced: about 1 year ago
JSON representation
Unofficial port of the Carbone API SDK to Saloon v3
- Host: GitHub
- URL: https://github.com/open-southeners/carbone-sdk
- Owner: open-southeners
- License: mit
- Created: 2023-12-26T18:43:11.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-03-07T11:58:09.000Z (over 1 year ago)
- Last Synced: 2025-03-27T02:21:33.516Z (about 1 year ago)
- Topics: api-sdk, carbone, document-generator, framework-agnostic, laravel-package, php8
- Language: PHP
- Homepage: https://carbone.io
- Size: 53.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
Carbone PHP [](https://www.php.net/supported-versions.php) [](https://codecov.io/gh/open-southeners/carbone-sdk) [](https://vscode.dev/github/open-southeners/carbone-sdk)
===
Unofficial port of the Carbone API SDK to Saloon v3
## Getting started
```
composer require open-southeners/carbone-sdk
```
### Laravel installation
To make this work within a Laravel app you just need to add the following at the very bottom of your `.env` file:
```ini
CARBONE_API_KEY='your-carbone-api-key'
```
To customise the API version and more you can simply add `carbone` array item to the _config/services.php_:
```php
[
'key' => env('CARBONE_API_KEY', ''),
'version' => '4',
],
];
```
### Usage
Within Laravel you've it injected into your application's container:
```php
$response = app('carbone')->template()->base64Upload($templateBase64);
if ($response->failed()) {
throw new \Exception('Template upload failed!');
}
// This is extracted from official Carbone SDK: https://carbone.io/api-reference.html#upload-a-template-carbone-cloud-sdk-php
$templateId = $response->getTemplateId();
```
### Any other framework (or not)
If you are using another framework (or just pure PHP), you can still use this as a standalone library:
```php
$carbone = new Carbone('your-carbone-api-key');
// Use this if you want to use a different API version: https://carbone.io/api-reference.html#api-version
// $carbone = new Carbone('your-carbone-api-key', '4');
$templateBase64 = base64_encode(file_get_contents('path_to_your_template_here'));
$response = $carbone->template()->base64Upload($templateBase64);
if ($response->failed()) {
throw new \Exception('Template upload failed!');
}
// This is extracted from official Carbone SDK: https://carbone.io/api-reference.html#upload-a-template-carbone-cloud-sdk-php
$templateId = $response->getTemplateId();
```
### Differences between official SDK and this
- Full Laravel support (optionally as this supports any framework or even raw PHP)
- Use of [Saloon v3](https://github.com/saloonphp/saloon/releases/tag/v3.0.0) not the v1 (which improves at everything typed for better IDE autocompletion support, etc)
- **Replaced the `template()->upload()` method with `template()->base64Upload()`** so the upload method can be used to send `multipart/form-data` POST request instead of a `application/json` with all the file contents base64 encoded
- Added `template()->exists()` to get if template with ID exists in Carbone (just a HEAD request so no content fetch at all)
- Added `status()->fetch()` to get status (not currently publicly documented, only on the OpenAPI, Postman, etc. [Can check them here](https://carbone.io/api-reference.html#api-integration))
[You can still check the official one here](https://github.com/carboneio/carbone-sdk-php).
## Partners
[](https://getskore.com)
## License
This package is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).