1. Go to this page and download the library: Download lokalise/php-lokalise-api library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
lokalise / php-lokalise-api example snippets
$client = new \Lokalise\LokaliseApiClient($apiToken);
/** @var \Lokalise\LokaliseApiResponse $response */
$response = $client->languages->listSystem();
$response->
headers // Associative array of Lokalise headers received
getContent() // Return response data as associative array
__toArray() // getContent() alias. Return response data as associative array
__toString() // Return JSON encoded response data
getTotalCount() // Return total count of filtered items in List methods
getPageCount() // Return count of pages in List methods (based on limit parameter)
getPaginationLimit() // Return pagination limit used in the request
getPaginationPage() // Return current page of the request
getNextCursor() // Return next cursor for cursor based pagination
hasNextCursor() // Return true if next cursor is present for cursor based pagination
\Lokalise\Utils::
base64FileEncode($filePath) // Get base64 encoded contents with leading mime type
\Lokalise\Exceptions\LokaliseApiException // Exception throws when Lokalise API can't be reached using Guzzle
\Lokalise\Exceptions\LokaliseResponseException // Exception throws when Lokalise API responded with a single error
$client = new \Lokalise\LokaliseApiClient($apiToken);
try {
$language = $client->languages->retrieve($projectId, $languageId)->getContent();
} catch (\Lokalise\Exceptions\LokaliseApiException $e) {
// try again later or break
} catch (\Lokalise\Exceptions\LokaliseResponseException $e) {
// Request cannot be completed. More details in {$e->getCode()} and {$e->getMessage()}
// break
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.