Install, Configure and Verify

Install

composer require sixth/codeigniter-sdk:dev-main@dev 

Configure

Configuration should happen on the main entry point of your application that is the index.php file in the public directory for Codeigniter4 projects and the equivalent for Laravel projects,

Code-igniter4

Configuration is done right after the application is initlized in the index.php file located in the public directory. Your index.php file should look somethins like this

<?php
use Sixth\CodeigniterSdk\Sixth;

/*
* Code igniter initilaztions ....
*/

/*
 * ---------------------------------------------------------------
 * GRAB OUR CODEIGNITER INSTANCE
 * ---------------------------------------------------------------
 *
 * The CodeIgniter class contains the core functionality to make
 * the application run, and does all the dirty work to get
 * the pieces all working together.
 */


$app = Config\Services::codeigniter();
$app->initialize();
$context = is_cli() ? 'php-cli' : 'web';
$app->setContext($context);

$sixth = new Sixth("apikey here");
$sixth->init();

/*
 *---------------------------------------------------------------
 * LAUNCH THE APPLICATION
 *---------------------------------------------------------------
 * Now that everything is set up, it's time to actually fire
 * up the engines and make this app do its thang.
 */

$app->run();

Laravel

<?php
// app/Http/Controllers/MyController.php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Sixth\Sixth; // Import the Sixth SDK class

class MyController extends Controller
{
    public function index()
    {
        // Initialize Sixth SDK with API key
        $apikey = 'api_key'; // Replace with your actual API key
        $sixth = new Sixth(['apikey' => $apikey]);

        // Initialize Laravel app, add routes, middleware, exception handlers etc
        
        // Call the init method with the Laravel app object
        $sixth->init(app());

        // Example:
        return view('welcome');
    }
}

Sixth dynamically auto-syncs with your codebase, meaning for every endpoint you add or remove from your codebase, sixth automatically detects every endpoint's lifecycle and updates your dashboard accordingly with the details that particular endpoint.

Verify

After configuring Sixth with your application, head over to your dashboard here, and click on rate limiting, if you have configured everything all your endpoint should be listed there. If not please send us an email at ope@trysixth.com

Last updated