Download the PHP package seanstewart/plan-config without Composer

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

Plan Config

This Laravel 5 package makes it easy to manage the rules/limits of your SaaS app subscription plans.

How to install

Require the package with composer

Laravel 5.5 uses Package Auto-Discovery and it is not necessary to manually add the ServiceProvider.

Laravel 5.5+:

If you don't use auto-discovery, add the ServiceProvider to the providers array in config/app.php

Include the facade (optional) in app/config/app.php.

Then you will need to generate your config by running the command

How to Use

Let's say your app has subscription plans that limit the number of widgets a user can add. You would have some sort of logic that checks the number of widgets a user is allowed to have in their account. With Plan Config you can do that by calling the helper function plan().

The plan() helper function knows what plan the current user is subscribed to and grabs the limits you defined in your plans.php config file. You can use the helper function anywhere in your application (views, controllers, models, middleware, etc.). Using the previous example, your plan config file would look like this:

If your user is subscribed to the silver plan, they could only add 10 widgets. You can even adapt it to use other attributes, like a title, description, or pricing for your plans.

Get a Plan's Config Without the User

In the case where a specific plan config is needed, you can pass in the plan's code as a string for the 2nd argument:

Configuring Your Plans

To configure your plans, open up app/plans.php and start adding your plan details. By default the package assumes that you're using laravel's built in Auth, and that the user's plan is stored in the User model. You can set the field used to determine the user's plan in the config...

To configure your plans, add your plan data in the 'plans' array.

If you have rules that apply to all plans, you can define a default or fallback plan. In the config file, set your fallback plan...

And then define the _default plan in your plans array.

In the above example, calling plan('limits.purple_widgets') will give you the value from the fallback plan.

Alternatively you can use the facade and call Plan::get('limits.purple_widgets')

Overrides

Plan config data can be overridden on the user level by setting an override attribute in the config.

In the above example, you would create the plan_overrides attribute on the user model. This field should be casted as an array and should include the list of keys and values that should be overridden for the given user.

Example

Plan Config with Overrides:

User Model plan_overrides attribute:

Would result in the following...

User's Plan Key Call Result Overridden?
silver limits.widgets plan('limits.widgets'); 10 No
silver limits.apples plan('limits.apples'); 50 Yes
silver limits.bananas plan('limits.bananas'); 100 Yes
silver limits.bananas plan('limits.bananas', 'silver') 20 No
bronze limits.bananas plan('limits.bananas', 'silver') 20 No
bronze limits.bananas plan('limits.bananas', $user) 100 Yes

If you want to return a user's entire plan config (along with overrides), you can pass in * as the first argument.

Why I created this

I've always found that managing subscriptions and plans for a SaaS app can be complicated. I felt like storing these values in a database isn't the best approach considering a lot of your values and limits will not change frequently. When building Election Runner, a web application that allows schools & organizations to run elections, we needed something to accomplish exactly this. Hopefully others will find this as useful as we do!


All versions of plan-config with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0
illuminate/support Version ~5.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 seanstewart/plan-config contains the following files

Loading the files please wait ....