PHP code example of gem-partij / gemboot-lara

1. Go to this page and download the library: Download gem-partij/gemboot-lara library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

gem-partij / gemboot-lara example snippets


public function index()
{
    try {
        return response()->json(['status' => 200, 'message' => 'OK', 'data' => User::all()], 200);
    } catch (\Throwable $e) {
        \Log::error($e->getMessage());
        return response()->json(['status' => 500, 'message' => 'Internal Server Error', 'data' => ['error' => $e->getMessage()]], 500);
    }
}

use GembootResponse;

public function index()
{
    return GembootResponse::responseSuccessOrException(function () {
        return User::all();
    });
}

use Illuminate\Foundation\Configuration\Middleware;

->withMiddleware(function (Middleware $middleware) {
    $middleware->alias([
        'token-validated' => \Gemboot\Middleware\TokenValidated::class,
        'role'            => \Gemboot\Middleware\HasRole::class,
        'permission'      => \Gemboot\Middleware\HasPermissionTo::class,
    ]);
})

Route::middleware(['token-validated', 'permission:user.read'])->group(function () {
    Route::apiResource('users', UserController::class);
});

class Post extends GembootModel
{
    protected $searchableRelations = ['author', 'tags'];
}

// config/auth.php
'guards' => [
    'api' => ['driver' => 'gemboot-sso-token', 'provider' => 'gemboot-sso'],
],
'providers' => [
    'gemboot-sso' => ['driver' => 'gemboot-sso-provider'],
],

Auth::guard('api')->forgetCachedUser();

class UserCachingObserver extends \Gemboot\Observers\CoreEloquentCachingObserver
{
    protected $cacheTag = 'users'; // the model's table name
}

User::observe(UserCachingObserver::class);
$service = (new UserService)->setObserver(new UserCachingObserver);

class CountryService extends GembootService
{
    protected function cacheScope()
    {
        return null; // same list for every user
    }
}

use Gemboot\FileHandler\FileHandler;

public function uploadImage(Request $request)
{
    return (new FileHandler($request->file_image))
        ->uploadImage('photo.jpeg', '/images/2026')
        ->object();
}
sh
php artisan vendor:publish --tag=gemboot
sh
php artisan gemboot:doctor