Download the PHP package rokde/laravel-subscription-manager without Composer

On this page you can find all versions of the php package rokde/laravel-subscription-manager. 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-subscription-manager

The Subscription Manager for Laravel

Latest Version on Packagist run-tests Check & fix styling PHPLint Total Downloads

NOT READY TO USE IN PRODUCTION ENVIRONMENTS

OPEN TODOS


The Subscription Manager for Laravel should handle all subscription based stuff without handling any payment. In contrary to the well known payment handling packages like cashier or similar we do not support any payment handling. Just the plans with features, subscribing, starting with a trial and pro-rating or going on an grace period and so on.

For communicating the changes we threw a lot of events and have a toolkit on board including middlewares, blade conditions and other ask-for-feature acceptance services.

What it is not:

What it is:

What it is all about?

Glossary

Subscribable is an Entity which can subscribe to a set of features.

In the real world it would be a human, which pays money for getting access to something premium.

Subscription is the relation between a Subscribable and its limited access granted to a set of features.

In the real world it would be a contract with a time-limit and a recurrence definition, like a cellphone contract.

Feature is a name of a premium area or premium function not every user has access to.

In the real world you get an access key to a hidden level.

Plan is a virtual composition of a set of Features.

In the real world is a Plan the Package S, M or L with access to a few, more or all functions.

Definition

On the definition side you have Features - identified by a slug code. Features are there for control. Think of permissions or an access right for a secured part of your application. Features can be virtually grouped by a Plan - but do not have to.

Because we handle no prices, you do not have to have a plan or Feature bundle.

So each Feature can be part in no Plan, one Plan, more Plans or all Plans. A Plan can exist, multiple Plans can exists, but no Plan has to exist. Think of a role in terms of authorization.

Subscription

A Subscription is loosely coupled to a plan and has a not-linked list of subscribed features. So the loosely coupled Plan is more an informative data link. The list of feature slugs are the important information within the subscription.

A Subscription runs infinite (ends_at is null) or until the end date. Additionally you can set a trial period (trial_ends_at is not null) end the trial ends at the specified timestamp. Before that you are on a trial.

A Subscription Circle is a virtual object in terms of periods. So a Subscription period is 1 year by default. So each Subscription has a list of Circles, at least one. Each Circle has a maximum of a period length, can be shorter when subscription is cancelled instant.

Subscriptions with an infinite period have just on Circle and are not recurring.

Installation

You can install the package via composer:

You have to publish and run the migrations with:

You can publish the config file with:

You can configure the following parts (documentation is inside the shipped configuration file):

Usage

If your subsciption subscribables are your users, then you have to do the following:

1.) Add the Subscribable trait to your User model.

2.) Subscribe something

3.) Use one of the various checks.

See Checking chapter below.

4.) Ask any information on a subscription

A Subscription can have a relation to a plan. It should have a list of features - but an empty array is good too. You can get an array of Subscription Circles for a Subscription. Each Subscription Circle represents a period within the subscription.

Each Subscription Circle has a relation to the subscription, its own start and end date. You can get an interval and the indexed number (1-based) of a circle. It respects the end of a subscription in past or future. The last Subscription Circle on active Subscriptions will have the current timestamp within its borders. So you have to add Circles on your own, when you want to go into the future.

5.) Cancel a subscription

Subscriptions can be cancelled in a few ways, all provided in the \Rokde\SubscriptionManager\Models\Concerns\HandlesCancellation trait.

6.) Resume a cancelled subscription

Consuming Features

1.) Setting a quota on metered features by actions (or direct via Subscription Builder)

Checking

Checking with Middleware

We register a middleware subscribed as route middleware. You can change that by publishing config and modify the subscription-manager::middleware config key.

You can check route access by just looking if your subscribable has an active subscription by using the middleware like so:

If you want to be a bit more concrete, you can ask if your subscribable has an active subscription to a feature like so:

Checking on the Subscribable

Getting all subscribed features

You can retrieve an array of all subscribed features.

Retrieving a different Subscribable

By default a subscribable is always the Auth::user(). But you can change that behaviour by registering another closure in your AppServiceProvider.

Maybe you are using JetStream or another team-based subscription subscribable option then do it like so:

And now you can add the Subscribable trait to your Team model:

Now you can use one of the various checks.

Events

You can listen on various events during the subscription lifecycle.

The following events gets dispatched:

Insights

Customer Insights

You have to use the Rokde\SubscriptionManager\Insights\Customer.

You can get the following customer insights:

Usually rolling 30 days or monthly periods are used for checking the indicators.

Subscriptions Histogram

The historical data can be accessed with the Rokde\SubscriptionManager\Insights\SubscriptionHistory.

The default use case is to retrieve statistical data grouped by week for the last month.

Each grouped partition has the following data:

Testing

FAQ

Q Why don't you use any model-relation between a subscription and the feature models?

A The tables for plans and features are just for the selling side of a subscription. You can use this structure yourself by filling these tables with your set of packages and features. But you don't have to to subscribe a user to a set of features.

Your business model can by selling subscriptions on a team level, but you can offer a personal feature to each user, which a user can subscribe to - no matter what the team has features for. So you do not have to struggle if this feature will be already on a plan or in your selling page.

Example: you have an HR app and you can sell a company-wide subscription to give all employees access to your app, billed by the company. A team of users want to track their own private todo list. Now you can subscribe these users to a special feature - like unlocking a special menu item.

Q Why don't you handle prices on plans or features or subscriptions?

A Because it is hard having prices in a world-wide usable package. You have various prices (with tax, without tax, including fees, various currencies, exchange rates, ...).

Add fields to the shipped migrations (tables) and inherit from the package models to suit your needs for handling price and currency. Sometimes it is easier to display prices just on a marketing page in html, than to have time-related multi-currency prices with or without taxes displayed for personal users or business customers.

Maybe it is better to tell a few USP features on the marketing selling page, but to have atomic features to handle subscription access even for crud operations - like a permission-based app.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-subscription-manager with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/config Version ^10.19|^11.0
illuminate/console Version ^10.19|^11.0
illuminate/contracts Version ^10.19|^11.0
illuminate/database Version ^10.19|^11.0
illuminate/http Version ^10.19|^11.0
illuminate/routing Version ^10.19|^11.0
illuminate/support Version ^10.19|^11.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 rokde/laravel-subscription-manager contains the following files

Loading the files please wait ....