Download the PHP package gem-partij/gemboot-lara without Composer

On this page you can find all versions of the php package gem-partij/gemboot-lara. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package gemboot-lara

Gemboot Lara

Latest Stable Version Total Downloads tests License

Gemboot Lara is a Laravel package for API services that sit behind a central auth service.

After reading this page you will know what the package does, how a request flows through it, how to set it up, and where each piece lives in the code.

What it does

Imagine you run several Laravel API services. None of them stores users or passwords. A separate auth service does that: it issues tokens, and it knows each user's roles and permissions. Every API service has to do the same three things on every request:

  1. Check the bearer token with the auth service, and check the user's role or permission.
  2. Return JSON in one shape, so clients can parse every service the same way.
  3. Do the usual CRUD work (list with search and paging, show, store, update, delete).

Gemboot Lara gives you one convention for each:

Need What Gemboot gives you Main code
Token and permission checks Route middleware (TokenValidated, HasRole, HasPermissionTo) and an SSO guard, all backed by HTTP calls to your auth service src/Middleware/, src/Libraries/AuthLibrary.php, src/SSO/Auth/
One response shape Every response is { "status", "message", "data" }, and exceptions turn into the right HTTP status src/Traits/JSONResponses.php, src/Exceptions/
CRUD A Service-Model-View-Controller (SMVC) layer: base controller, base service, base model, and artisan generators src/Controllers/, src/Services/CoreService.php, src/Models/CoreModel.php

The token check is the core of the package. The other two are conventions built around it.

The response shape, by example

Without Gemboot, every controller repeats the same try/catch and JSON building:

With Gemboot, you write only the part that matters:

Both return the same JSON:

Any exception thrown inside the callback becomes an error response. Gemboot exceptions map to their status code, and Eloquent's ModelNotFoundException becomes a 404, a denial from Laravel's authorization ($this->authorize(), policies) a 403, and a failed $request->validate() a 400. Anything else becomes a 500 and goes through Laravel's report(), so it reaches your logs and any error tracker or log channel you've set up.

Documentation

Step-by-step guides with examples live in docs/:

Guide Covers
Installation Install, point Gemboot at your auth service, check it works
Responses The response format, helpers, and exceptions as error responses
Authentication Middleware, roles and permissions, the SSO guard, the auth service contract
Controllers Building a CRUD API, search, hooks, validation
Routes and query parameters Search, sorting, and paging from the client side
Caching Cached lists and records, cleared on changes, per user
Testing your API Test protected routes without a running auth service (GembootAuth::fake())
Request IDs Follow one user action through the logs of every service
File handler Reference

The rest of this README is an overview.

How a request flows

Quick start

1. Install

The service provider, facades, and class aliases register themselves through Laravel package discovery.

2. Publish the config and point it at your auth service

This creates config/gemboot.php. Then set at least this in .env:

Then check the setup:

It lists anything that's wrong (missing URL, unreachable auth service, TLS off, ...), each with a fix.

To check that the auth service also answers the way Gemboot expects, run php artisan gemboot:contract-test with a valid token.

3. Protect routes

Register the middleware aliases in bootstrap/app.php:

Then use them on routes:

TokenValidated calls the auth service's me endpoint and merges the result into the request as user_login, so $request->user_login holds the current user. Gemboot keeps that merged value out of the data store() and update() save. Cache keys keep it, so cached entries stay per user.

4. Generate the SMVC classes

This creates the model, a service, and a resource controller. The controller extends GembootResourceController, which already implements index, store, show, update, and destroy. See docs/COMMANDS.md for the separate gemboot:make-service and gemboot:make-controller commands.

index reads these query parameters:

Parameter Example Effect
search, search_field, search_mode ?search=ana&search_field=name LIKE search (ILIKE on PostgreSQL). Arrays search several fields. relation.column searches a related model.
search_exact ?search_exact=42&search_field=id Exact match instead of LIKE
order, atoz ?order=name&atoz=desc Sort. Arrays sort by several columns.
page_len ?page_len=50 Page size (default 30, at most gemboot.pagination.max_page_len, default 1000). all returns up to 1000 rows without paging.

Columns in the model's $hidden (passwords, tokens) can't be searched or sorted; naming one in search_field or order returns 400. A search without search_field skips them. An atoz other than asc or desc also returns 400.

Searching relations

?search=ana&search_field=author.name searches the author relation. The part before the dot must be a real relation on the model: a public method with no required parameters, not inherited from Eloquent or Gemboot, whose return type (if declared) is a Relation. Anything else gets a 400.

To allow only specific relations, list them on the model:

We recommend the list, and declaring relation return types (public function author(): BelongsTo), for any model exposed through index.

The auth service contract

Gemboot does not issue tokens. It forwards the client's bearer token to your auth service and trusts the answer. Your auth service must expose these endpoints under gemboot.auth.base_api:

Method and path Used by Gemboot expects
POST login AuthLibrary::login() Body fields npp, password, hwid
GET me TokenValidated, AuthLibrary::me() HTTP 200 with the user. A data wrapper is unwrapped.
GET validate-token TokenValidated:client, AuthLibrary::validateToken() HTTP 200 if the token is valid
GET has-role?role_name=… HasRole, GembootPermission::hasRole() HTTP 200 with has_role
GET has-permission-to?permission_name=… HasPermissionTo, GembootPermission::hasPermissionTo() HTTP 200 with has_permission_to (and has_any_permission when several names are joined with \|)
POST logout AuthLibrary::logout() HTTP 200

Any status other than 200 counts as "no", and the middleware answers 401 or 403. When the auth service can't be reached or answers 5xx, the middleware answers 503 instead, so clients don't log users out during an outage.

The answers of me, validate-token, has-role, and has-permission-to can be cached per token with GEMBOOT_AUTH_CACHE_TTL (seconds, off by default). That saves one HTTP call per middleware per request. The trade-off: a token revoked at the auth service keeps working until its cache entries expire. AuthLibrary::logout() clears them for that token. Outages are never cached.

Alternative: the SSO guard

Instead of the middleware, you can use Laravel's own auth system through the gemboot-sso-token guard. It calls a "get current user" URL with the token and caches the user for gemboot.sso.cache_ttl seconds (default 300), keyed by a SHA-1 hash of the token.

Then auth:api on a route and auth()->user() work as usual. Set GEMBOOT_USER_SERVICE_URL (the guard calls {url}/user/me) or GEMBOOT_SSO_GET_USER_URL for the full URL. Both have _FALLBACK variants. The fallback is tried when the first service can't be reached or doesn't accept the token, so a rejected token is also sent to the fallback host. (9.0 will try the fallback only during outages.)

The user is cached per token, so a token revoked at the auth service keeps working until GEMBOOT_SSO_CACHE_TTL runs out. Clear it on logout:

Configuration

All settings live in one file, config/gemboot.php. Every value comes from an environment variable, so you can usually leave the file as published and only edit .env.

Key Env variable Purpose
auth.base_api GEMBOOT_AUTH_BASE_API Base URL of the auth service endpoints above
auth.cache_ttl GEMBOOT_AUTH_CACHE_TTL Seconds to cache auth service answers per token (default 0, off)
http.verify GEMBOOT_HTTP_VERIFY TLS certificate check for auth service calls: true (default), false, or a CA bundle path
http.timeout, http.connect_timeout GEMBOOT_HTTP_TIMEOUT, GEMBOOT_HTTP_CONNECT_TIMEOUT Seconds (defaults 30 and 10)
pagination.max_page_len GEMBOOT_MAX_PAGE_LEN Upper limit for ?page_len (default 1000, null for no limit)
sso.user_service_url, sso.get_user_url GEMBOOT_USER_SERVICE_URL, GEMBOOT_SSO_GET_USER_URL Used by the SSO guard
sso.fallback.* same names with _FALLBACK Second user service for the SSO guard
sso.cache_ttl GEMBOOT_SSO_CACHE_TTL Seconds to cache an SSO user (default 300)
file_handler.base_url GEMBOOT_FILE_HANDLER_BASE_URL File upload service used by FileHandler
notifications.telegram.token, .chat_id (deprecated) GEMBOOT_TELEGRAM_BOT_TOKEN, GEMBOOT_TELEGRAM_CHAT_ID Telegram alert on every unhandled 500. Off when the token is empty.
response.security_headers GEMBOOT_SECURITY_HEADERS Cache-Control: no-store and X-Content-Type-Options: nosniff on every response (default on)
response.send_header_error GEMBOOT_SEND_HEADER_ERROR Adds an x-gemboot-error-message header to error responses (default on)
response.compressed GEMBOOT_RESPONSE_COMPRESSED Deprecated, removed in 9.0. gzip through ob_gzhandler (default off; leave compression to the web server)

You don't have to publish the file: Gemboot merges its defaults, and a published file only needs the keys you change. A file published before a new top-level key was added still gets that key's default.

The publish tags gemboot-auth, gemboot-gateway, and gemboot-file-handler exist for backward compatibility. They publish the same config/gemboot.php.

Caching

CoreService can cache listAll() and findOrFail() results. Turn it on per service with setObserver(), and register the same observer on the model so writes clear the cache:

This needs a cache store with tag support: redis, memcached, or array. On file or database stores, Gemboot skips caching and reads from the database, because it could not clear stale entries there.

Cached results are per logged-in user. Services and controllers often scope queries to the current user (for example where('user_id', auth()->id())), so a shared cache entry could show one user another user's data. The cache key includes auth()->id() whenever someone is logged in through a Laravel guard. If a service's results are the same for everyone, share them across users by returning null:

GembootResourceController has the same cacheScope() method for its own index/show cache ($cache_seconds). That cache is also cleared by the caching observer on stores with tag support.

Facades and aliases

Everything below is registered automatically.

Alias Class Use it for
GembootResponse Gemboot\GembootResponse responseSuccess, responseSuccessOrException, responseNotFound, …
GembootAuth Gemboot\Libraries\AuthLibrary Calling the auth service directly
GembootPermission Gemboot\GembootPermission hasRole, hasPermissionTo, requirePermission inside code
GembootValidator Gemboot\GembootValidator makeAndThrow validates and throws GembootValidationFailException
GembootRequest Gemboot\GembootRequest getRequestToken() reads the bearer token from a request
GembootController, GembootResourceController, GembootProxyController Gemboot\Controllers\CoreRest*Controller Base controllers
GembootService Gemboot\Services\CoreService Base service
GembootModel Gemboot\Models\CoreModel Base model (adds search, searchExact scopes)

Exceptions, all thrown from inside responseSuccessOrException():

Alias Status
GembootBadRequestException, GembootValidationFailException 400
GembootUnauthorizedException 401
GembootForbiddenException 403
GembootNotFoundException 404
GembootMethodNotAllowedException 405
GembootConflictException 409
GembootUnprocessableEntityException 422
GembootTooManyRequestsException 429
GembootServerErrorException 500
GembootServiceUnavailableException 503
GembootHttpErrorException any status you pass

File handler

FileHandler uploads a file to a separate file service at gemboot.file_handler.base_url:

uploadImage() and uploadDocument() return an Illuminate\Http\Client\Response, so ->json(), ->status(), ->successful() and the rest of the Laravel HTTP client API are available.

Legacy: gateway middleware

Gemboot\Gateway\Middleware\CheckToken is deprecated since 8.0 and may be removed in a future major release. It checked every request against a gateway. Use the per-route middleware from the Quick start instead.

Support policy

Only the latest major version gets new features.

Package version Laravel PHP
0.5.x < 5.5
1.x ^5.5, ^6, ^7 7.2 to 8.0
2.x 8 7.3 to 8.1
3.x 9 8.0 to 8.2
4.x 10 8.1 to 8.3
5.x 11 8.2 to 8.3
6.x 11 ^8.2
7.x ^11, ^12 ^8.2
8.x (current) ^12, ^13 ^8.3

Upgrading from 8.13 to 8.14

Upgrading from 8.12 to 8.13

Upgrading from 8.11 to 8.12

Upgrading from 8.10 to 8.11

Upgrading from 8.9 to 8.10

Upgrading from 8.8 to 8.9

Upgrading from 8.7 to 8.8

Upgrading from 8.6 to 8.7

Upgrading from 8.5 to 8.6

See Authentication: protection against token floods.

Upgrading from 8.4 to 8.5

Upgrading from 8.3 to 8.4

Upgrading from 8.2 to 8.3

Upgrading from 8.1 to 8.2

No public signatures or config keys are removed. Check these changes:

Upgrading from 8.0 to 8.1

No public signatures or config keys are removed, and the response envelope is unchanged. Check these behavior changes:

Upgrading from 7.x to 8.x

There are no changes to public class or method signatures, the response envelope, config keys, or middleware aliases. What changed:

Behavior changes worth checking:

Full notes: v8.0.0 release.

Upgrading from 6.x to 7.x

7.0 was released without upgrade notes; these were written later. Response envelope, middleware aliases, and config keys didn't change. What can break code that uses Gemboot's classes directly:

Working on this package

This section is for contributors, including AI coding agents.

Project map

Rules that keep consumers safe

This is a published library used in production, so every public symbol is a contract.

  1. Backward compatibility. Class and method signatures, facade and class aliases, config keys, middleware aliases, and the response envelope don't change without a major version. State the SemVer impact (patch, minor, major) in every PR.
  2. The envelope { status, message, data } is fixed.
  3. Read settings with config(), never env(), outside config/ files. env() returns null after php artisan config:cache.
  4. No app-specific values. URLs, header formats, role names: all configurable.
  5. Explicit nullable types (?Type $x = null), required by PHP 8.4+.
  6. New public behavior needs a test and a README or docs/ update.
  7. Don't build on the deprecated CheckToken middleware.

Commands

Tests that call real external services are opt-in. For example, the Telegram test runs only with TEST_NOTIFICATION=true plus GEMBOOT_TELEGRAM_BOT_TOKEN and GEMBOOT_TELEGRAM_CHAT_ID set in the environment, and TEST_AUTH=true needs GEMBOOT_AUTH_BASE_API pointing at a real auth service. The repository only contains placeholder hosts. A docker-compose.yml with a PHP 8.4 container is included.

CI runs PHP 8.3, 8.4, and 8.5 against Laravel 12 and 13, plus a lowest-versions job. It fails if Composer installs a dev branch instead of a stable release.

Releasing

Versions come from Git tags. Packagist updates when a tag is pushed. Cut a SemVer tag, then publish a GitHub release whose notes explain the upgrade risk.

Contributing

See CONTRIBUTING.

Security

If you find a security issue, please email [email protected] instead of opening a public issue.

Credits

License

MIT. See LICENSE.md.


All versions of gemboot-lara with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
laravel/framework Version ^12.0|^13.0
guzzlehttp/guzzle Version ^7.15.2
laravel-notification-channels/telegram Version ^6.0|^7.0
irazasyed/telegram-bot-sdk Version ^3.15
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package gem-partij/gemboot-lara contains the following files

Loading the files please wait ...