Download the PHP package cemerson/session without Composer

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

Session

You can use this library to help unit test applications that have a reliance on the session in some way.

Rationale

Unit tests are better when they are completely isolated from the environment in which they are run, and don't ever access parts of that environment such as databases, file system, network sockets or even the current time.

It is deliberately ultra-simple, with no frills, containing just enough to achieve the required results without any added complexity.

Installing

Session requires PHP 7. Install via composer:

composer require cemerson/session

Usage

Whenever you have a class that needs to access the session, don't use the $_SESSION global in PHP. Instead, hint for and inject the Session interface from this library, and use the methods on that to manipulate session data.

In production, you can set up your dependency injection container to inject the provided DefaultPHPSession class to manipulate the default PHP $_SESSION global.

<?php declare(strict_types = 1);

namespace MyVendor\MyApp;

use CEmerson\Session\Session;

class MyClass
{
    /** @var Session */
    private $session;

    public function __construct(Session $session)
    {
        $this->session = $session;
    }

    public function myMethodThatNeedsToAccessSessionData()
    {
        $someVar = $this->session->get('varname');

        /* ... */

        $this->session->set('varname', 'newvalue');
    }

    public function youCanAlsoUseArrayAccess()
    {
        $someVar = $this->session['varname'];

        /* ... */

        $this->session['varname'] = 'newvalue';
    }

    public function orEvenPropertyAccessMagicMethods()
    {
        $someVar = $this->session->varname;

        /* ... */

        $this->session->varname = 'newvalue';
    }
}

Alternatively, create your own implementation of the Session interface if you need some different functionality, or you want to create an adapter to a different session library instead. An Abstract class is provided that performs all the boilerplate code to implement the ArrayAccess and 'magic' property access methods, leaving you only needing to implement get, set, isset and unset.

During testing, you can create a mock of the Session interface to provide whatever session data you like using your favourite mocking framework, or even using your least favourite one.


All versions of session with dependencies

PHP Build Version
Package Version
Requires php Version ^7.0 | ^8.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 cemerson/session contains the following files

Loading the files please wait ....