Download the PHP package mindplay/session without Composer

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

mindplay/session

This library implements a type-hinted container for session model objects.

This approach gives you type-hinted closures whenever you're working with session state of any sort, which is great for IDE support and code comprehension in general.

Build Status

Code Coverage

Scrutinizer Code Quality

Usage

Note that SessionService does not attempt to control the PHP session lifecycle - it only provides a type-safe means of storing serialized objects in session variables; you are still in charge of e.g. starting the session with session_start(), etc.

Setting up

Let's assume you have a session model like this one:

In a real project, you probably want to use a dependency injection container or some other means of centrally managing your SessionContainer instance.

At the end of your request cycle (centrally, e.g. after dispatching a controller, but before sending the response), you must call commit() to store the session data:

This ensures you don't have partial changes made to session variables in case of errors. If you don't care about transactional sessions and want changes committed automatically, you can register a shutdown function, for example:

Working with the session model container

In the following examples, for simplicty, we'll assume your session container is a global variable:

Note that, in a real project, you would probably want to type-hint e.g. controllers against the abstract SessionContainer interface, since calling e.g. commit() isn't relevant there.

To access/update a session model object, pass a type-hinted closure to the update() method:

The update() method will construct Cart for you - it's therefore important to note that session model classes must always have an empty constructor.

You can take values out of a container as well:

But do note that it's generally not very good practice to take session model objects out of the container, as this blurs the fact that you're making changes to session state - the call to update() clarifies what you're doing.

To remove a session model object:

If you have a reference to the session model object, remove() will also accept that.

Optional session models

If you don't know if a session model has been constructed yet, and you want to avoid creating an empty session model, you can use a default null parameter in the closure:

Multiple models in one call

If you need two (or more) session model objects at the same time, just ask for them:

Remove all session models

To remove all session models, call the clear() method.

Note that the session models are not removed from underlying storage until commit() is called.

Custom storage and testing

A MockSessionStorage implementation is included, useful for integration tests - you can provide this (or any SessionStorage implementation) at construction time, e.g.:

During integration tests, you can make assertions about the contents of the public MockSessionStorage::$data property, which contains the raw session model objects, indexed by class-name.


All versions of session with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.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 mindplay/session contains the following files

Loading the files please wait ....