Download the PHP package whilesmart/eloquent-entitlements without Composer

On this page you can find all versions of the php package whilesmart/eloquent-entitlements. 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 eloquent-entitlements

whilesmart/eloquent-entitlements

A provider-neutral entitlements layer for Laravel: feature flags, plan limits and metered usage, all scoped to a polymorphic owner (a workspace, organization, user) through whilesmart/eloquent-owner-access.

The package ships an allow-all default, so a self-host stays fully unlocked and free. A host that wants to charge rebinds one interface to enforce plans. No payment SDK is imported anywhere; billing is a seam the host fills.

Install

Routes register automatically under the api prefix with auth:sanctum. Set ENTITLEMENTS_REGISTER_ROUTES=false to mount them yourself.

The gating seam

Everything gates through one contract, Whilesmart\Entitlements\Contracts\Entitlements:

check() returns an AccessResult (allowed, feature, reason, limit) so a denial can say why, not just no. The reason is a stable code: no_owner, no_plan, feature_not_in_plan.

Gating a route

Gate a route or group on a feature with the feature middleware. A denied request gets a 402 carrying the feature and reason:

The middleware needs to know which model owns the entitlement. The default OwnerResolver uses the authenticated user; a host that gates by workspace or organization binds its own:

The default binding, AllowAllEntitlements, allows every feature, imposes no limit and never meters. To enforce plans, rebind it to PlanEntitlements in a service provider:

Owning model

Add the trait to whatever owns entitlements:

Model layer

PlanEntitlements resolves the four contract methods: overrides first, then whatever plan the bound PlanSource reports for the owner.

Where plans come from

PlanEntitlements holds the resolution rules (an override wins; a comp is unlimited; an absent meter allowance is unlimited) but not the storage. Finding the owner's plan is a second seam, Whilesmart\Entitlements\Contracts\PlanSource:

ResolvedPlan is a plain value object (features, limits, meters maps, read with data_get, so keys may nest). Return null when nothing entitles the owner, or ResolvedPlan::unlimited() for an entitling subscription with no plan behind it.

The default, EloquentPlanSource, reads the models above, and resolving the owner's subscription is its business rather than the caller's. So an app that models subscriptions differently, keeps plans in config, or asks a remote service, replaces only this and keeps the rules:

The models above are then just the default source's storage; a host that binds its own leaves those tables empty.

Metering

remaining and consume delegate to a UsageMeter the host binds. The default, NullUsageMeter, reports unlimited and records nothing, so the package never owns a usage table. Bind your own to count real usage:

Coupons

Redemption is rejected when the coupon is expired or has reached max_redemptions.

Billing

Whilesmart\Entitlements\Contracts\BillingProvider is the checkout seam. The default, NullBillingProvider, refuses checkout and no-ops the rest. A host binds a real adapter (Stripe, Paddle, etc.); the package stays provider-neutral and imports no payment SDK.

Endpoints

Method Path Purpose
GET /api/entitlements Owner's current snapshot (plan, features, limits)
POST /api/entitlements/redeem-coupon Redeem a coupon by code for the owner

Both are owner-scoped through owner-access: a caller can only read or redeem into an owner the bound authorizer permits.

Configuration

config/entitlements.php exposes register_routes, register_migrations, route_prefix, route_middleware, the five table names, and a models map so any model can be swapped for a host subclass.

An app that binds its own PlanSource (and does not use this package's plans, subscriptions or coupons) can set register_migrations to false to take the gating contract without the tables.


All versions of eloquent-entitlements with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
laravel/framework Version ^11.0|^12.0
whilesmart/eloquent-owner-access Version ^1.0
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 whilesmart/eloquent-entitlements contains the following files

Loading the files please wait ...