Download the PHP package hamrocdn/sdk without Composer
On this page you can find all versions of the php package hamrocdn/sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package sdk
HamroCDN PHP SDK
Official PHP SDK for HamroCDN β a simple, typed, and framework-agnostic way to upload, fetch, and manage files from your HamroCDN account.
π¦ Installation
Install via Composer:
Requirements
- PHP 8.0+
- GuzzleHTTP 7.10+
Thatβs it.
No Laravel dependencies, no magic β just pure PHP.
βοΈ Configuration
You can pass your API key directly, or rely on environment/config values if available.
Alternatively, if your environment has them:
the SDK automatically detects and uses them.
β‘ Quick Start
Hereβs a quick example showing upload and fetch in action:
π Usage
This SDK make use of public API provided by HamroCDN. To get your API key, sign up at hamrocdn.com and navigate to Edit Profile page in your dashboard.
1. List Uploads
1.1 Paginated
The index() method returns paginated results.
You can provide pagination parameters such as page and per_page:
Returns an object containing
data(array ofUploadmodels) andmeta(pagination info).
Example of returned metadata:
1.2 All Uploads
To fetch all uploads without pagination, use the all() method:
Returns an array of
Uploadmodels.
2. Fetch a Single Upload
3. Upload a File
To delete the file after a certain time, use the
deleteAfterparameter (in seconds):This will set the
deleteAtproperty on the returnedUploadmodel.
4. Upload by Remote URL
Also supports the
deleteAfterparameter.
π§± Models
π HamroCDN\Models\Upload
| Property | Type | Description |
|---|---|---|
nanoId |
string |
Unique identifier of the upload |
user |
User or null |
Owner of the file (if authenticated) |
deleteAt |
Carbon or null |
Deletion timestamp if temporary |
original |
File |
File information (URL, size) |
Methods
getNanoId():stringgetUser():?UsergetDeleteAt():?CarbongetOriginal():FiletoArray():array
π€ HamroCDN\Models\User
| Property | Type | Description |
|---|---|---|
name |
string |
Name of the uploader |
email |
string |
Email of the uploader |
Methods
getName():stringgetEmail():stringtoArray():array
π§Ύ HamroCDN\Models\File
| Property | Type | Description |
|---|---|---|
url |
string |
Public CDN URL |
size |
int |
File size in bytes |
Methods
getUrl():stringgetSize():inttoArray():array
β‘ Error Handling
All SDK errors extend HamroCDN\Exceptions\HamroCDNException.
Example:
The SDK automatically wraps:
- Network issues (
GuzzleException) - Invalid JSON responses
- Missing API key or misconfiguration
π§ͺ Testing
This SDK is built with Pest and supports real API integration tests.
A dedicated testing environment is configured within the HamroCDN infrastructure, ensuring safe, production-like validations.
Run tests locally:
πͺ Framework Integrations
This SDK is framework-agnostic. If youβre using Laravel, check out the companion package:
π hamrocdn/laravel
It provides service providers, configuration publishing, and automatic Facade binding.
π§© Type Safety / Static Analysis
- Fully typed with PHPStan annotations
- 100% PHP 8.0+ compatible
- Pint with
laravelpreset for code style - Rector for automated refactoring
- SonarCloud integration for code quality
π License
This package is open-sourced software licensed under the MIT license.
π€ Contributing
Contributions are welcome! Please create a pull request or open an issue if you find any bugs or have feature requests.
β Support
If you find this package useful, please consider starring the repository on GitHub to show your support.