Download the PHP package zjkiza/tmp-storage-bundle without Composer
On this page you can find all versions of the php package zjkiza/tmp-storage-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download zjkiza/tmp-storage-bundle
More information about zjkiza/tmp-storage-bundle
Files in zjkiza/tmp-storage-bundle
Package tmp-storage-bundle
Short Description The bundle for temporary storage data which needs to be preserved between stateless requests.
License MIT
Informations about the package tmp-storage-bundle
TMP Storage Bundle
The TMP Storage Bundle is used to store temporary state between two stateless requests. Common use cases include:
- SSO Login: During single sign-on, user data can be temporarily stored as an object in TMP Storage. A generated ID links the data, ensuring sensitive user information is not exposed in the URL. The ID is verified upon login, and the stored object is retrieved to complete the process.
- Password Reset: User data can be saved as an object in TMP Storage, and a reset link is generated with a unique ID. When the user clicks the link, they are directed to a page where the ID is verified, and the stored object is retrieved to facilitate password reset.
- Unsubscribe Links: User information is stored temporarily in TMP Storage, and an unsubscribe link is generated with a unique ID. When the user clicks the link, they are directed to the unsubscribe page, where the ID is verified, and the object is retrieved to process the request.
This bundle allows you to securely store objects in a temporary storage database, retrievable using randomly generated keys.
About the Bundle
The bundle defines the interface Zjk\TmpStorage\Contract\TmpStorageInterface with the following methods:
-
public function storage(object $tmp, int $ttl = 604800): string
Stores an object in the database. The$ttlparameter specifies the object's time-to-live in seconds (default: one week). -
public function fetch(string $id, bool $remove = true): object
Retrieves an object from the database by its ID. The$removeparameter determines whether the object is deleted immediately after retrieval. Set$removetofalseto keep the object. -
public function remove(string $id): void
Removes an object from the database if$removewas previously set tofalse. public function clearGarbage(): void
Performs maintenance to remove invalid or expired records, ensuring database cleanliness.
Maintenance Command
A terminal command is available for manual or scheduled garbage collection. It invokes the clearGarbage method:
Installation
Add the bundle to your project using Composer:
Symfony integration
The bundle integrates seamlessly with Symfony, wiring up all necessary classes. Follow these steps to set it up:
-
Register the Bundle
- Configure the Bundle
By default, the bundle uses a database table named zjkiza_tmp_storage and the doctrine.dbal.default_connection. To customize these settings, create a zjkiza_tmp_storage.yaml configuration file in the config/packages directory with the following parameters:
Replace your_table_name with your desired table name and configure the database connection as needed.
- Generating the Required Table
To create the necessary table in the database, run the following command in your terminal:
This command instructs Doctrine to generate the table based on the bundle's configuration.
Working with the bundle
All versions of tmp-storage-bundle with dependencies
ext-json Version *
ramsey/uuid Version ^3.0|^4.0
doctrine/dbal Version ^2.0|^3.0|^4.0
doctrine/orm Version ^2.6|^3.0
doctrine/persistence Version ^1.0|^2.0|^3.0|^4.0
symfony/config Version ^6.0|^7.0|^8.0
symfony/console Version ^6.0|^7.0|^8.0
symfony/dependency-injection Version ^6.0|^7.0|^8.0
symfony/http-kernel Version ^6.0|^7.0|^8.0
symfony/http-foundation Version ^6.0|^7.0|^8.0
symfony/yaml Version ^6.0|^7.0|^8.0