Download the PHP package kazistm/subscriptions without Composer

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

KaziSTM Subscriptions

Latest Version on Packagist Total Downloads License Laravel Compatibility

A flexible and extendable subscription and plan management system for Laravel applications, particularly suited for SaaS products. This package provides tools to manage recurring plans, features with usage limits, and subscription lifecycles.

This package is based on, and aims to enhance, the foundation laid by laravelcm/laravel-subscriptions.

Table of Contents

Key Features & Enhancements

Requirements

Installation

  1. Install the package via Composer:

  2. Run the installation command:

    This interactive command will:

    • Ask if you want to publish the configuration file (config/subscriptions.php). Defaults to yes.
    • Publish the necessary database migrations to your database/migrations folder (it checks for existing migrations with the same base name to avoid duplication).
    • Ask if you want to publish basic model stubs (Plan.php, Subscription.php, etc.) to your app/Models directory. This is optional and only needed if you plan to directly extend or override the package's models. Defaults to no.
    • Automatically run php artisan migrate to create the required database tables.

Configuration

The main configuration file is located at config/subscriptions.php after publishing.

Database Migrations

The subscriptions:install command handles publishing and running migrations. The following tables are created (using default names):

Core Concepts & Models

1. Subscribable Model

Your model that will have subscriptions (typically App\Models\User, but can be any model like App\Models\Company) needs to use the KaziSTM\Subscriptions\Traits\HasPlanSubscriptions trait.

2. Plan (KaziSTM\Subscriptions\Models\Plan)

Defines a subscription plan your users can subscribe to.

Attribute Type Description
name json Translatable display name
slug string Unique identifier
description json Translatable description
is_active boolean If plan is usable
price decimal Cost per interval
signup_fee decimal One-time fee
currency string e.g., "USD"
trial_period int Duration of trial
trial_interval string Unit: day, month, year (from Interval Enum)
invoice_period int Duration of billing cycle
invoice_interval string Unit: day, month, year (from Interval Enum)
grace_period int Duration of grace period
grace_interval string Unit: day, month, year (from Interval Enum)
sort_order int Ordering
deleted_at timestamp Soft deletes

Relationships

Scopes

Methods

Note: The Interval Enum (KaziSTM\Subscriptions\Enums\Interval) typically uses values like Interval::DAY->value ('day'), Interval::MONTH->value ('month'), Interval::YEAR->value ('year') when interacting with these fields programmatically, although the database stores the string values.

3. Limitation (KaziSTM\Subscriptions\Models\Limitation)

Defines a category or type of feature/limit (the "what").

Attributes

Attribute Type Description
title json Translatable display title (e.g., "User Seats")
slug string Unique identifier (e.g., "users", "projects")
description json Translatable description
type string Custom type field (optional)
sort_order int Ordering
deleted_at timestamp Soft deletes

Relationships

4. Feature (KaziSTM\Subscriptions\Models\Feature)

Links a Plan to a Limitation, defining the specific value/quota (the "how much").

Attributes

Attribute Type Description
plan_id foreignId Belongs to Plan
limitation_id foreignId Belongs to Limitation
value string Limit/value (e.g., "10", "500", "true"). Use strings for consistency.
resettable_period int How often usage resets (e.g., 1 for 1 month)
resettable_interval string Unit for reset (day, month, year). Use 0/null if usage never resets.
sort_order int Ordering
deleted_at timestamp Soft deletes

Relationships

Methods


5. Subscription (KaziSTM\Subscriptions\Models\Subscription)

Links a subscribable model to a Plan and tracks its lifecycle.

Attributes

Attribute Type Description
subscriber_id int ID of the subscribing model
subscriber_type string Class name of the subscribing model
plan_id foreignId The Plan being subscribed to
name json Translatable identifier (e.g., "main", "default")
slug string Unique slug for this subscription instance
trial_ends_at datetime When the trial period ends
starts_at datetime When the current billing period started
ends_at datetime When the current billing period ends
cancels_at datetime If scheduled, when cancellation takes effect
canceled_at datetime When the cancellation was requested/marked
deleted_at timestamp Soft deletes

Relationships

Methods

Scopes

6. Subscription Usage (KaziSTM\Subscriptions\Models\SubscriptionUsage)

Tracks consumption of specific, resettable features.

Attributes

Attribute Type Description
subscription_id foreignId The subscription instance
feature_id foreignId The specific feature being tracked
used int How much has been used in the current period
valid_until datetime When the current usage period ends and resets
deleted_at timestamp Soft deletes

Relationships

Scopes

Methods

Note on Slugs vs Names/Titles

Throughout the package, slug attributes (on Plan, Limitation, and Subscription) serve as unique, immutable identifiers intended for programmatic use. These are what you'll use in your code when:

For example:

Usage

Preparation

1. Add Trait

Ensure your subscribable model(s) (e.g., App\Models\User, App\Models\Company) use the KaziSTM\Subscriptions\Traits\HasPlanSubscriptions trait.

2. Create Plans, Limitations & Features

Define plans, limitations, and features in your database, typically using seeders.

Example Seeder Logic:

Managing Subscriptions

Managing Feature Usage

Interact with features using the slug of the Limitation model.

Middleware

Protect your application routes based on subscription status or included features. The middleware automatically attempts to detect the subscribable entity from Route Model Binding, Filament Tenancy, or the Authenticated User.

Registration (Laravel 11+)

Register the middleware aliases in your bootstrap/app.php file:

Registration (Pre-Laravel 11)

Register the middleware aliases in your app/Http/Kernel.php:

Usage in Routes

Check Active Subscription (subscription.active)

Verifies the relevant subscribable entity has an active subscription (not ended or canceled). Aborts with 403 (Forbidden) otherwise.

Check Plan Features (subscription.feature)

Verifies the relevant subscribable entity's active subscription plan includes all specified features (by Limitation slug). Aborts with 403 (Forbidden) otherwise. Implicitly checks for an active subscription first.

Subscribable Entity Detection

The middleware automatically attempts to determine the subscribable entity to check in the following order of precedence:

  1. Route Model Binding
    Looks for a route parameter that resolves to a model using the HasPlanSubscriptions trait.

  2. Filament Tenancy
    If filament/filament is installed, checks the current tenant model.

  3. Authenticated User
    Falls back to Auth::user() as a default.

Extending Models

If you need custom logic or relationships on the package's models:

  1. Run php artisan subscriptions:install.
  2. Answer "yes" when asked to Publish model stubs...?
  3. Edit the generated files in app/Models/ (e.g., app/Models/Plan.php). They extend the base package models using aliases.

  4. Update config/subscriptions.php to use your models:

Support & Issues

If you discover any security-related issues, please email [email address removed] instead of using the issue tracker.

All other issues, feature requests, or questions should be submitted via the GitHub Issues page.

License

This package is open-sourced software licensed under the MIT license.

Credits


All versions of subscriptions with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/console Version ^10.0|^11.0|^12.0
illuminate/container Version ^10.0|^11.0|^12.0
illuminate/database Version ^10.0|^11.0|^12.0
illuminate/support Version ^10.0|^11.0|^12.0
spatie/eloquent-sortable Version ^4.0
spatie/laravel-package-tools Version ^1.16
spatie/laravel-sluggable Version ^3.4
spatie/laravel-translatable Version ^6.5
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 kazistm/subscriptions contains the following files

Loading the files please wait ...