Installation guide

));
$sessionHandler->garbageCollect();
You can also use the gc_operation_delay configuration option on the session handler to introduce delays in
between the Scan and BatchWriteItem operations that are performed by the garbage collection process. This
will increase the amount of time it takes the garbage collection to complete, but it can help you spread out the
requests made by the session handler in order to help you stay close to or within your provisioned throughput
capacity during garbage collection.
Best Practices
1. Create your sessions table in a region that is geographically closest to or in the same region as your
application servers. This will ensure the lowest latency between your application and DynamoDB database.
2. Choose the provisioned throughput capacity of your sessions table carefully, taking into account the expected
traffic to your application and the expected size of your sessions.
3. Monitor your consumed throughput through the AWS Management Console or with Amazon CloudWatch and
adjust your throughput settings as needed to meet the demands of your application.
4. Keep the size of your sessions small. Sessions that are less than 1KB will perform better and require less
provisioned throughput capacity.
5. Do not use session locking unless your application requires it.
6. Instead of using PHP's built-in session garbage collection triggers, schedule your garbage collection via a cron
job, or another scheduling mechanism, to run during off-peak hours. Use the gc_operation_delay option
to add delays in between the requests performed for the garbage collection process.
Amazon S3 Stream Wrapper
Introduction
The Amazon S3 stream wrapper allows you to store and retrieve data from Amazon S3 using built-in PHP functions
like file_get_contents, fopen, copy, rename, unlink, mkdir, rmdir, etc.
You need to register the Amazon S3 stream wrapper in order to use it:
// Register the stream wrapper from an S3Client object
$client->registerStreamWrapper();
This allows you to access buckets and objects stored in Amazon S3 using the s3:// protocol. The "s3" stream
wrapper accepts strings that contain a bucket name followed by a forward slash and an optional object key or prefix:
s3://<bucket>[/<key-or-prefix>].
Downloading data
You can grab the contents of an object using file_get_contents. Be careful with this function though; it loads
the entire contents of the object into memory.
// Download the body of the "key" object in the "bucket" bucket
$data = file_get_contents('s3://bucket/key');
Use fopen() when working with larger files or if you need to stream data from Amazon S3.
// Open a stream in read-only mode
if ($stream = fopen('s3://bucket/key', 'r')) {
// While the stream is still open
while (!feof($stream)) {
// Read 1024 bytes from the stream
echo fread($stream, 1024);
Amazon S3 Stream Wrapper
131