Download the PHP package brain/context without Composer

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

Context

Context is package that aims to collect "context" to pass to templates based on a query object.

Best paired with a template engine. And maybe with Hierarchy.


PHP Quality Assurance codecov.io license release


Quick start

Let's assume a couple of classed designed to provide context for the homepage and the singular view, respectively:

Now we can make use of the Context class to generate the context for our templates:

Context class emit the action `"brain.context.providers" that can be used to add providers from different places:

Examples using Hierarchy

Here's an example of using context in combination with Brain Hierarchy to render mustache templates passing them context.

Above is all the necessary code to render *.mustache templates from a /templates subfolder in current theme (or parent theme, if any), according to WP template hierarchy, passing to templates context data that can be extended via ad-hoc "view context" classes which will implement Context\ProviderFactory interface.

Providers

Composite providers

The "Quick start" section above uses Context\Provider\ArrayMerge class to "merge" several providers.

Besides that class, there's also a Context\Provider\ArrayMergeRecursive "composite" provider.

Atomic providers

The "composite" providers merge multiple "atomic" providers that can be either custom (anything implementing Context\Provider) or one of the shipped provider classes:

Custom providers

The Context\Provider interface has a single method:

Which can be implemented to build custom providers. In the case the provider should not be used based on conditions, it can return null.

The given PSR-3 logger interface can be used to log errors and distinguish a provider that returns null due to errors form another that returns null because, for example, not targeting the current query.

Logger

All providers support a PSR-3 logger. Context class implements PSR-3 LoggerAwareInterface, so it is possible to call setLogger when instantiating it.

There's also a "brain.context.logger" action that passes a callback that can be used to set the logger:

Requirements

Context requires PHP 7.1+ and Composer to be installed.

Installation

Best served by Composer, available on Packagist with name brain/context.

License

Context is released under MIT.


All versions of context with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
psr/log Version ^1 || ^2 || ^3
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 brain/context contains the following files

Loading the files please wait ....