Installation Guide
Follow these 3 easy steps to install and set up Tuner in your Laravel project.
Requirements
- PHP ^8.0
- Laravel ^12.0
Step 1: Install via Composer and Publish config file
composer require rodrigogalura/tuner
php artisan vendor:publish --tag=tuner-config
This will create a file at config/tuner.php
Step 2: Setup
Use the Tunable trait:
...
class User extends Authenticatable
{
use \Tuner\Tunable;
# ⚠️ Do NOT define this:
// public function send() {}
}
⚠️ Important: Avoid Defining a send Method
The send() method is already defined in the Tunable trait. To avoid conflicts or unexpected behavior, do not override or define your own send() method in any model that uses this trait.
Then, register a route that returns your model using the send() method:
use Illuminate\Support\Facades\Route;
Route::get('/api/users', function () {
return \App\Models\User::send();
});
Step 3: Try It Out
Open your browser or an API client like Postman and try this example request:
Request
GET /api/users?columns=id,name&search[name]=Dr*
Response
[
{ "id": 1, "name": "Dr Foo", "email": ... },
{ "id": 2, "name": "Dr Bar", "email": ... },
{ "id": 3, "name": "Dr Baz", "email": ... }
]
Next Steps
Now that you’re up and running:
- Explore more features in the API Reference.
- Or modify the default settings in Configuration.