Laravel Quick Start

This guide will show you how to integrate our Tml PHP library with a Laravel application.

Before Getting Started

Make sure you have a Translation Exchange account, and have created a project in your dashboard.

1. Install the SDK

To create a new Laravel project, run the following command:

$ laravel new YOUR_APPLICATION_NAME
$ cd YOUR_APPLICATION_NAME

Add TML library reference by editing composer.json file in the root of your new project:

"require": {
...
"translationexchange/tml": "*"
}

To install the library, run:

$ composer update

The TML helper methods need to be available globally in all controllers and views. To do that, we can require the TML initialization script in the application bootstrap. Open bootstrap/app.php and add the following line at the top of the file:

require __DIR__.'/../vendor/translationexchange/tml/src/init.php';

2. Configure the SDK

Now that the library is included we can create our middleware where we will initialize the application. Add a new Tml.php file under app/Http/Middleware/Tml.php and paste the following code: