cyberspectrum/php-transifex

transifex API client written 100% in PHP

1.0.1 2018-09-29 15:10 UTC

This package is auto-updated.

Last update: 2020-03-09 23:59:11 UTC


README

Build Status Latest Version tagged Latest Version on Packagist Installations via composer per month

Transifex client written in PHP.

This uses php-http base interfaces.

Installation

$ php composer.phar require cyberspectrum/php-transifex php-http/guzzle6-adapter

Why php-http/guzzle6-adapter? We are decoupled form any HTTP messaging client with help by HTTPlug.

You may also install any other adapter instead of php-http/guzzle6-adapter, just make sure one is installed.

Usage

We have two layers of API.

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

1. Low level API.

Quick start - create an API client:

$client = new CyberSpectrum\PhpTransifex\Client();
$client->authenticate($token);
// Or:
// $client->authenticate($user, $password);

// Fetch a project:
$project = $client->projects()->show('some-project');

For details of the endpoints, refer to the doc comments in the classes.

2. High level API.

Create an API client:


$transifex = PhpTransifex::create($apiKey);
// Or:
// $transifex = PhpTransifex::create($user, $password);

Create a project:

$project = $transifex->createProject(
    '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->project('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());