Quickstart · PHP
Updated: September 7, 2026
Target: a PHP site serving translated pages, in under ten minutes.
The PHP library takes a different approach from the Dart and Node ones: instead of handing you keywords to render yourself, it translates the page and injects a language selector.
Before you start
- PHP 7.0 or newer
- Composer, recommended but not required
- An AZbox project with its Project ID and API key
1 · Create the project
In the dashboard: Create Project, set the source language and the targets you want the site available in.
2 · Install
composer require azbox/azbox-php
Without Composer, copy azbox.php and the lib directory into your project.
3 · Initialise
At the start of execution — usually index.php or app.php, before any output:
require __DIR__ . '/vendor/autoload.php';
\Azbox\AZ::Instance(array(
"api_key" => "YOUR API KEY",
"projectId" => "YOUR PROJECT ID",
"original_language" => "en",
"destination_languages" => "es,fr,de",
"buttonOptions" => array(
"fullname" => true,
"is_dropdown" => true,
"position" => "bottom-right",
),
));
4 · Check it works
Load the site. A language selector should appear in the corner you configured. Switching language translates the page.
5 · Sites in a subdirectory
If the site does not live at the domain root, set home_url so the library builds its links correctly. The example/ directory of the repository has a working case.
Keep the credentials out of the repository
"api_key" => getenv('AZBOX_API_KEY'),
"projectId" => getenv('AZBOX_PROJECT_ID'),
If something fails
- No selector appears — the initialisation is running after output has started. It has to come before anything is printed.
- Links break in a subdirectory — set
home_url.
Next
Start Global Growth Today
Upload your language files, get them translated, and keep every locale in sync as your product keeps changing.
Get Started - It's Free