zimbra-api / upload-api
PHP wrapper library around the Zimbra upload service
3.0.0
2024-04-25 08:49 UTC
Requires
- php: ^8.1
- psr-discovery/http-client-implementations: ^1.0
- psr-discovery/http-factory-implementations: ^1.0
- psr/log: ^3.0
Requires (Dev)
- fakerphp/faker: ^1.0
- nyholm/psr7: ^1.0
- php-http/mock-client: ^1.0
- phpstan/phpstan: ^1.0
- phpunit/phpunit: ^7.0 | ^8.0 | ^9.0
Suggests
- guzzlehttp/guzzle: Required if you like to use Guzzle PSR-18 HTTP Client & PSR-7 HTTP message factories
README
PHP wrapper library around the Zimbra upload service.
Requirement
- PHP 8.1.x or later,
- PSR Discovery library for searching installed http clients and http message factories,
- (optional) PHPUnit to run tests,
Installation
Via Composer
$ composer require zimbra-api/upload-api
or just add it to your composer.json
file directly.
{ "require": { "zimbra-api/upload-api": "*" } }
This package using PSR-17: HTTP Factories, PSR-18: HTTP Client for creating multipart stream & sending HTTP requests to Zimbra upload service. Make sure to install package(s) providing "http client implementation" & "http factory implementation". The recommended package is Guzzle which provide both PSR-17 & PSR-18.
$ composer require guzzlehttp/guzzle
Basic usage of zimbra
upload client
<?php require_once 'vendor/autoload.php'; use Zimbra\Upload\Client; use Zimbra\Upload\Request; $file = new \SplFileInfo($filePath); $request = new Request([$file], $requestId, $authToken); $client = new Client('https://zimbra.server/service/upload'); $attachments = $client->upload($request);
$authToken
is user authentication token, it can obtain from zimbra soap api.
<?php require_once 'vendor/autoload.php'; use Zimbra\Account\AccountApi; $api = new AccountApi('https://zimbra.server/service/soap'); $auth = $api->authByName('username', 'password'); $authToken = $auth->getAuthToken();
Licensing
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.