This uses php-http
base interfaces.
$ php composer.phar require cyberspectrum/php-transifex php-http/guzzle7-adapter
Why php-http/guzzle7-adapter
?
We are decoupled form any HTTP messaging client with help by HTTPlug.
You may also install any other adapter instead of php-http/guzzle7-adapter
, just make sure one is installed.
We have two layers of API.
- Low level API in the namespace
CyberSpectrum\PhpTransifex\ApiClient
- High level entity based API in the namespace
CyberSpectrum\PhpTransifex\Model
Quick start - create an API client:
$factory = new CyberSpectrum\PhpTransifex\ApiClient\ClientFactory(
$logger,
[new CyberSpectrum\PhpTransifex\ApiClient\Generated\Authentication\BearerAuthAuthentication($apiKey)]
);
$client = $factory->create($factory->createHttpClient());
// Fetch a project:
$project = $client->getProjectByProjectId('project-id');
$factory = new CyberSpectrum\PhpTransifex\ApiClient\ClientFactory(
$logger,
[new CyberSpectrum\PhpTransifex\ApiClient\Generated\Authentication\BearerAuthAuthentication($apiKey)]
);
$client = $factory->create($factory->createHttpClient());
$transifex = new CyberSpectrum\PhpTransifex\PhpTransifex($client);
$organization = $transifex->organizations()->getBySlug('organization');
$project = $organization->projects()->add(
'project-slug',
'My Project description',
'en', // source language code.
'https://example.org' // the repository URL for open source projects or false for private.
);
$project->save();
$project = $transifex->organizations()->getBySlug('organization')->projects()->getBySlug('some-project');
$project->languages()->add('de')->coordinators()->add('transifex-username');
$project->save();
// Show all language codes for the project.
var_export($project->languages()->codes());