copperforest / snapshot
A composer plugin that let you choose differents code snapshots for differents users
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:composer-plugin
Requires
- php: >=5.3
- composer-plugin-api: 1.1
This package is auto-updated.
Last update: 2025-06-22 05:09:27 UTC
README
This composer plugin let you choose differents code snapshots for differents users.
implements the SessionInterface
The first step to use the snashots system is ensure that you SessionHandler class implements the interface copperforest\snapshot\authentication\SessionHandlerInterface. For this you must create the next five methods:
- getUserId(): must return the ID of the current user.
- setPreviousUserId( $id ): must store the parameter $id in session, for example:
$_SESSION[ 'PreviousUserId' ] = $id;
- getPreviousUserId(): return the value stored in the previous method, for example:
return $_SESSION[ 'PreviousUserId' ];
- setPreviousSnapshot( $snapshot ): must store the parameter $snapshot in session, for example:
$_SESSION[ 'PreviousSnapshot' ] = $snapshot;
- getPreviousSnapshot(): return the value stored in the previous method, for example:
return $_SESSION[ 'PreviousSnapshot' ];
new composer command
This plugin define a new composer comand: create-snapshot. You must run this command each time you update you code to create a new code snapshot.
php composer.phar create-snapshot
choose the snapshot
You must edit the file ./snapshots/snapshot.json and choose the :
{ "snapshot":{ "1": [ "default", "cli" ], "2":[ "122", "123" ] } }
warning
The SessionHandler class (and all the classes used in its __construct() method) allways loads from default snapshot because previously we don't know the user ID.