Download the PHP package honeystone/context without Composer

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

Application Context Manager for Laravel

Static Badge GitHub License Latest Version on Packagist Packagist Dependency Version Packagist Dependency Version Static Badge

We developed honeystone/context for managing the application context in multi-tenant applications. It provides a simple, fluent API for intializing, extending and switching contexts using 'context resolvers'. In addition, contexts are automagically available in queued jobs and can be used to scope Eloquent models.

This package was developed several years ago for our own multi-tenant applications. We've recently decided to release it in the hope it will be useful to the wider Laravel community. We're open to contributions, feedback and constructive criticism.

Getting started

Start by reading the short blog post that demonstrates how to use this package in multi-tenant application.

Support us

Support Us

We are committed to delivering high-quality open source packages maintained by the team at Honeystone. If you would like to support our efforts, simply use our packages, recommend them and contribute.

If you need any help with your project, or require any custom development, please get in touch.

Installation

Usage

A typical use-case would be to declare and initialize the context in your middleware. You can then access the context data like this:

Defining the context

Contexts need to be defined before they can be resolved:

These context definitions are 'required', so if they cannot be resolved a CouldNotResolveRequiredContextException will be thrown. For undefined contexts, a UndefinedContextException will be thrown.

You can also define 'accepted', but not 'required' contexts:

Or accept / require based on the existence of another context:

Initializing the context

To initialize the context, you'll need to provide a resolver:

Here's an example resolver class:

You can customize serialization logic like this:

You can validate the integrity of a resolved context like this:

You can also reinitialize or deinitialize the current context:

Extending the context

The current context can be extended using another resolver:

Temporarily switching the context

Using a closure:

Using the start and end methods:

Events and receivers

The Honeystone\Context\Events\ContextChanged event is dispatched whenever the context is changed.

You can also specify receivers to be notified when individual context values are set:

Here's an example receiver:

Scoping models using the context

You can use the current context to scope your Eloquent models.

Here's an example:

Known issues

Laravel's "context"

When this solution was created, Laravel context did not exist. The function name collision is unfortunate, but not really a problem. You'll just need to make sure you import the function.

Whilst the name will invite comparison, these packages are solving different problems. Laravel context is a generic global data store. This package is specifically for resolving context objects with more complex logic and using them to scope the application, for example in a multi-tenancy application.

Changelog

A list of changes can be found in the CHANGELOG.md file.

License

Honeystone Consulting Ltd


All versions of context with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
spatie/laravel-package-tools Version ^1.16.4
illuminate/contracts Version ^10.0|^11.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 honeystone/context contains the following files

Loading the files please wait ....