gem-partij / gemboot-lara
Gemboot Lara - Laravel package for supporting SMVC development method
Installs: 3 045
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 7
Requires
- php: ^8.2
- guzzlehttp/guzzle: ^7.2
- irazasyed/telegram-bot-sdk: ^3.13
- laravel-notification-channels/telegram: ^5.0
- laravel/framework: ^11.0
Requires (Dev)
- orchestra/testbench: ^9.0
- phpunit/phpunit: ^11.0.1
- dev-master
- 5.x-dev
- 5.3.1
- 5.3.0
- 5.2.0
- 5.1.1
- 5.1.0
- 5.0.1
- 5.0.0
- 4.x-dev
- 4.3.1
- 4.3.0
- 4.2.0
- 4.1.3
- 4.1.2
- 4.1.1
- 4.1.0
- 4.0.0
- 3.x-dev
- 3.4.5
- 3.4.4
- 3.4.3
- 3.4.2
- 3.4.1
- 3.4.0
- 3.3.0
- 3.2.0
- 3.1.5
- 3.1.4
- 3.1.3
- 3.1.2
- 3.1.1
- 3.1.0
- 3.0.5
- 3.0.4
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
- 2.x-dev
- 2.3.1
- 2.3.0
- 2.2.5
- 2.2.4
- 2.2.3
- 2.2.2
- 2.2.1
- 2.2.0
- 2.1.11
- 2.1.10
- 2.1.9
- 2.1.8
- 2.1.7
- 2.1.6
- 2.1.5
- 2.1.4
- 2.1.3
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 1.x-dev
- 1.0.19
- 1.0.18
- 1.0.17
- 1.0.16
- 1.0.15
- 1.0.14
- 1.0.13
- 1.0.12
- 1.0.11
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 0.5.x-dev
- 0.5.4
- 0.5.3
- 0.5.2
- 0.5.1
- 0.5.0
- dev-dependabot/composer/nesbot/carbon-3.8.4
- dev-dependabot/composer/league/commonmark-2.6.0
- dev-dependabot/composer/laravel/framework-11.31.0
- dev-dependabot/composer/symfony/process-7.1.7
- dev-dependabot/composer/symfony/http-foundation-7.1.7
This package is auto-updated.
Last update: 2025-02-19 08:06:16 UTC
README
Laravel package for supporting SMVC development method
What It Does
Before installing gemboot package:
use App\Models\User; class UserControllerApi extends Controller { // method to return all users public function index() { $status = 200; $message = 'Success!'; $data = []; try { // add user data to response $data = User::all(); } catch(\Exception $e) { // if catch error... // log error \Log::error($e->getMessage()); \Log::error($e->getTraceAsString()); // add error response $status = 500; $message = "Internal Server Error"; $data = [ 'error' => $e->getMessage(), ]; } // return response json return response()->json([ 'status' => $status, 'message' => $message, 'data' => $data, ], $status); } }
After installing gemboot package:
use GembootResponse; use App\Models\User; class UserControllerApi extends Controller { // method to return all users public function index() { return GembootResponse::responseSuccessOrException(function() { return User::all(); }); } }
will get the same response:
/* Success Response */ { "status": 200, "message": "Success!", "data": [ /* all user data... */ ] } /* Error Response */ { "status": 500, /* it could be 400 to 500 error status code */ "message": "Error!", "data": [ /* all error data... */ ] }
Documentation, Installation, and Usage Instructions
See the DOCUMENTATION for detailed installation and usage instructions.
Support Policy
Only the latest version will get new features.
Installation
Require the gem-partij/gemboot-lara
package in your composer.json
and update your dependencies:
composer require gem-partij/gemboot-lara
Optional: The service provider will automatically get registered. Or you may manually add the service provider in your config/app.php file:
'providers' => [ // ... \Gemboot\GembootServiceProvider::class, ];
Optional: The aliases will automatically get registered. Or you may manually add the gemboot aliases in your config/app.php file:
'aliases' => [ // ... 'GembootBadRequestException' => Gemboot\Exceptions\BadRequestException::class, 'GembootForbiddenException' => Gemboot\Exceptions\ForbiddenException::class, 'GembootNotFoundException' => Gemboot\Exceptions\NotFoundException::class, 'GembootServerErrorException' => Gemboot\Exceptions\ServerErrorException::class, 'GembootUnauthorizedException' => Gemboot\Exceptions\UnauthorizedException::class, 'GembootRequest' => Gemboot\Facades\GembootRequestFacade::class, 'GembootResponse' => Gemboot\Facades\GembootResponseFacade::class, 'GembootController' => Gemboot\Controllers\CoreRestController::class, 'GembootProxyController' => Gemboot\Controllers\CoreRestProxyController::class, 'GembootResourceController' => Gemboot\Controllers\CoreRestResourceController::class, 'GembootModel' => Gemboot\Models\CoreModel::class, 'GembootService' => Gemboot\Services\CoreService::class, ];
Gemboot Gateway (Additional Package)
Middleware
To use Gemboot Gateway for all your routes, add the CheckToken
middleware in the $middleware
property of app/Http/Kernel.php
class:
protected $middleware = [ // ... \Gemboot\Gateway\Middleware\CheckToken::class, ];
Configuration
The defaults are set in config/gemboot_gw.php
. Publish the config to copy the file to your own config:
php artisan vendor:publish --tag="gemboot-gateway"
Gemboot Auth (Additional Package)
Middleware
To use Gemboot Auth middleware for your routes, add the TokenValidated
, HasRole
, HasPermissionTo
middleware in the $routeMiddleware
property of app/Http/Kernel.php
class:
protected $routeMiddleware = [ // ... 'token-validated' => \Gemboot\Middleware\TokenValidated::class, 'role' => \Gemboot\Middleware\HasRole::class, 'permission' => \Gemboot\Middleware\HasPermissionTo::class, ];
Configuration
The defaults are set in config/gemboot_auth.php
. Publish the config to copy the file to your own config:
php artisan vendor:publish --tag="gemboot-auth"
Routes
add Gemboot AuthLibrary in your routes if you want to use it, example:
use Illuminate\Http\Request; use Gemboot\Libraries\AuthLibrary; Route::middleware('api')->prefix('auth')->group(function() { Route::post('login', function(Request $request) { return (new AuthLibrary)->login($request->npp, $request->password, true); }); Route::get('me', function() { return (new AuthLibrary)->me(true); }); Route::get('validate-token', function() { return (new AuthLibrary)->validateToken(true); }); Route::get('has-role', function(Request $request) { return (new AuthLibrary)->hasRole($request->role_name, true); }); Route::get('has-permission-to', function(Request $request) { return (new AuthLibrary)->hasPermissionTo($request->permission_name, true); }); Route::post('logout', function() { return (new AuthLibrary)->logout(true); }); });
Gemboot File Handler (Additional Package)
Configuration
The defaults are set in config/gemboot_file_handler.php
. Publish the config to copy the file to your own config:
php artisan vendor:publish --tag="gemboot-file-handler"
File Handler Usage
Now you can upload image or document using gemboot file handler.
use Illuminate\Http\Request; use Gemboot\FileHandler\FileHandler; class ExampleController extends Controller { public function uploadImage(Request $request) { $image = $request->file_image; $new_filename = "Gambar.jpeg"; $save_path = "/gambar/2020"; return (new FileHandler($image)) ->uploadImage($new_filename, $save_path) ->object(); } }
The uploadImage, uploadDocument method returns an instance of Illuminate\Http\Client\Response, which provides a variety of methods that may be used to inspect the response:
$response->body() : string; $response->json($key = null) : array|mixed; $response->object() : object; $response->collect($key = null) : Illuminate\Support\Collection; $response->status() : int; $response->ok() : bool; $response->successful() : bool; $response->redirect(): bool; $response->failed() : bool; $response->serverError() : bool; $response->clientError() : bool; $response->header($header) : string; $response->headers() : array;
more at: https://laravel.com/docs/9.x/http-client#making-requests
Testing
Run the tests with:
composer test
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security-related issues, please email anggerpputro@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.