API Customization Guide

1) Customize controllers

  • All default GP247 APIs allow overriding controllers without modifying core code.

Steps

  • Step 1: Create a controller under the app directory with the corresponding App\ namespace, and extend the original controller.
  • Step 2: Override methods from the original controller if you need to change behaviors.

Example

  • Goal: Customize the original controller GP247\Core\Api\Controllers\AdminController.php.
  • Action: Create app/GP247/Core/Api/Controllers/AdminController.php with namespace App\GP247\Core\Api\Controllers and extend from the original controller.
namespace App\GP247\Core\Api\Controllers;

use GP247\Core\Api\Controllers\AdminController as VendorAdminController;

class AdminController extends VendorAdminController
{
    public function __construct()
    {
        parent::__construct();
    }

    // Override original methods here to customize behavior
    // public function yourMethodName(Request $request)
    // {
    //     // Implement your custom logic
    // }
}

Notes:

  • Do not modify code under the vendor/ directory to stay safe during updates.
  • Ensure the App\... namespace matches your app/ directory structure.

2) Customize default API parameters

  • Most API settings in GP247 can be adjusted via environment variables in the .env file (no core changes required).
  • See the full list of configuration keys and default values at gp247-config.php.

Recommended process:

  • Step 1: Open .env and add/edit related variables (e.g., GP247_API_MODE=0 to disable APIs).
  • Step 2: Refresh application configuration:
php artisan config:clear
php artisan cache:clear
  • Step 3: Restart background workers (if any) such as queue/schedule so new configs take effect.

Notes:

  • On production, use php artisan config:cache after changes for better performance.
  • Never commit the .env file to your repository.