2017 © Pedro Peláez
 

project php-transifex

transifex API client written 100% in PHP

image

cyberspectrum/php-transifex

transifex API client written 100% in PHP

  • Thursday, March 9, 2017
  • by xtra
  • Repository
  • 1 Watchers
  • 0 Stars
  • 31 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 7 % Grown

The README.md

Build Status Latest Version tagged Latest Version on Packagist Installations via composer per month, (*1)

Transifex client written in PHP.

This uses php-http base interfaces., (*2)

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., (*3)

You may also install any other adapter instead of php-http/guzzle7-adapter, just make sure one is installed., (*4)

Usage

We have two layers of API., (*5)

  1. Low level API in the namespace CyberSpectrum\PhpTransifex\ApiClient
  2. High level entity based API in the namespace CyberSpectrum\PhpTransifex\Model

1. Low level API.

Quick start - create an API client:, (*6)

$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());

The Versions

09/03 2017