Download the PHP package gorilladash/laravel-website-sdk without Composer

On this page you can find all versions of the php package gorilladash/laravel-website-sdk. 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 laravel-website-sdk

GorillaDash Website SDK

Latest Version

A Laravel package that connects a client website to the GorillaDash website GraphQL API and serves its content through a stale-while-revalidate (SWR) cache — so server-rendered pages return instantly from cache while fresh data is fetched from the API in the background. The browser never waits on an API call.

Live demo: website-sdk-demo.gorilladash.com — a small Inertia + SSR site that lets you enter credentials, run any of the website GraphQL queries, and watch the cache behaviour (and timings) live.


Why

Client websites built on GorillaDash need to render marketing/content pages fast. Calling the GraphQL API on every request adds latency and a hard dependency on the API being up. This SDK puts a cache in front of the API with stale-while-revalidate semantics:

Cache state Behaviour
No cache Block, fetch from the API, store, return.
Younger than TTL (default 60s) Serve cached. No API call.
Older than TTL Serve cached instantly, and refresh from the API in the background (after the response is sent — no queue worker needed). The next request gets the newer data.

Stale data is retained well past the TTL so there is always something to serve, and background refreshes are guarded by a per-key lock to avoid stampedes.


Requirements

Installation

The service provider and the GorillaDash facade are auto-discovered.

The provider is built on spatie/laravel-package-tools: it extends PackageServiceProvider and wires everything declaratively in configurePackage() — the config file (published under the website-sdk-config tag) and the cache-clear webhook route (routes/web.php). Service bindings are registered in the packageRegistered() lifecycle hook.

Credentials

From the GorillaDash website API settings you get three values. Map them as follows — the public key is not used for GraphQL auth:

The SDK exchanges these for a bearer token at {base_uri}/oauth/token (OAuth2 client-credentials grant) and caches the token automatically.

Configuration

All options live in config/website-sdk.php and are env-driven:

Option Env var Default Description
base_uri GD_WEBSITE_BASE_URI https://api.gorilladash.com API base URL (token + GraphQL).
client_id GD_WEBSITE_CLIENT_ID — Passport OAuth client id (website "ID").
client_secret GD_WEBSITE_CLIENT_SECRET — Passport client secret ("API Access Token").
public_key GD_WEBSITE_PUBLIC_KEY — Website public key — authenticates the cache-clear webhook (not GraphQL).
cache_ttl GD_WEBSITE_CACHE_TTL 60 Freshness window (seconds).
cache_store GD_WEBSITE_CACHE_STORE app default Laravel cache store to use.
cache_prefix GD_WEBSITE_CACHE_PREFIX gd_website: Cache key prefix.
stale_retention_multiplier GD_WEBSITE_STALE_RETENTION 100 Stale data kept for cache_ttl × this (0 = forever).
max_stale_age GD_WEBSITE_MAX_STALE_AGE 86400 Hard ceiling on stale age (seconds); past it, block and refetch. 0 = disabled.
register_graphql_route GD_WEBSITE_GRAPHQL_ROUTE true Expose the POST GraphQL endpoint.
graphql_path GD_WEBSITE_GRAPHQL_PATH graphql Path for the GraphQL endpoint.
register_clear_cache_route GD_WEBSITE_CLEAR_CACHE_ROUTE true Register the cache-clear webhook.
clear_cache_path GD_WEBSITE_CLEAR_CACHE_PATH gorilla-dash/clear-cache Path for the cache-clear webhook.
token_skew GD_WEBSITE_TOKEN_SKEW 60 Re-exchange the token this many seconds early.
http_timeout GD_WEBSITE_HTTP_TIMEOUT 10 Per-request timeout (seconds).

Usage

Queries are built with mghoneimy/php-graphql-client (Packagist: gmostafa/php-graphql-client, a dependency of this package). graphql() takes a Query (or QueryBuilderInterface) object; graphqlWithMeta() additionally accepts a raw query string.

HTTP endpoints

The package registers two routes (both can be disabled or repathed via config — see the table above):

POST /graphql

A ready-to-use GraphQL endpoint that proxies a { query, variables } body through the SWR cache and returns the full envelope (data + cache metadata). Useful for client-side / SSR fetching without writing a controller:

Cache-clear webhook

GorillaDash calls this when content changes, to flush this site's cache. Point GorillaDash's "Cache Clear URL" at {your-site}/gorilla-dash/clear-cache?key={public_key}; a request whose key matches public_key flushes the cache (any other request gets a 404).

Error handling

Transport, auth and GraphQL errors throw GorillaDash\WebsiteSdk\Exceptions\GdRequestException:

Inertia SSR client sites

Fetch in the controller and pass the data as Inertia props — the cache keeps it fast and SSR renders it into the initial HTML:

Testing

Fake the HTTP layer with Laravel's Http::fake() — no real API calls:

Run the package test suite:

How it works

License

MIT — see LICENSE.


All versions of laravel-website-sdk with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
gmostafa/php-graphql-client Version ^1.14
illuminate/cache Version ^11.0 || ^12.0 || ^13.0
illuminate/contracts Version ^11.0 || ^12.0 || ^13.0
illuminate/http Version ^11.0 || ^12.0 || ^13.0
illuminate/support Version ^11.0 || ^12.0 || ^13.0
spatie/laravel-package-tools Version ^1.16
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 gorilladash/laravel-website-sdk contains the following files

Loading the files please wait ...