cyberspectrum / php-transifex
transifex API client written 100% in PHP
Installs: 132
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:project
Requires
- php: ^8.1
- ext-json: *
- ext-mbstring: *
- jane-php/json-schema-runtime: ^7.5.0
- jane-php/open-api-runtime: ^7.5.0
- php-http/client-common: ^2.6.1
- php-http/discovery: ^1.15
- php-http/multipart-stream-builder: ^1.2.0
- php-http/promise: ^1.1.0
- psr/http-client: ^1.0
- psr/http-factory: ^1.0
- psr/http-message: ^1.1
- psr/log: ^3.0.0
- symfony/deprecation-contracts: ^3.2
- symfony/options-resolver: ^6.2
- symfony/serializer: ^6.2
- symfony/validator: ^6.2
Requires (Dev)
- http-interop/http-factory-guzzle: ^1.2.0
- php-http/guzzle7-adapter: ^1.0.0
- phpcq/runner-bootstrap: ^1.0@dev
Suggests
- php-http/buzz-adapter: For using buzz as transport
- php-http/guzzle7-adapter: For using guzzle as transport
- php-http/react-adapter: For using react as transport
This package is auto-updated.
Last update: 2024-10-16 16:31:41 UTC
README
Transifex client written in PHP.
This uses php-http
base interfaces.
Installation
$ 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.
Usage
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
1. Low level API.
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');
2. High level API.
Create an API client:
$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);
Fetch an organization:
$organization = $transifex->organizations()->getBySlug('organization');
Create a project:
$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();
Fetch a project:
$project = $transifex->organizations()->getBySlug('organization')->projects()->getBySlug('some-project');
Add a language
$project->languages()->add('de')->coordinators()->add('transifex-username'); $project->save(); // Show all language codes for the project. var_export($project->languages()->codes());