Skip to content

Commit 2f17d1e

Browse files
authored
Merge pull request #116 from Jurj-Bogdan/remove-laminas-db
Remove Laminas\Db Session Save Handler Support
2 parents 53fdfcc + b517bec commit 2f17d1e

19 files changed

+75
-1228
lines changed

Diff for: .github/workflows/continuous-integration.yml

-40
Original file line numberDiff line numberDiff line change
@@ -21,35 +21,6 @@ jobs:
2121
name: QA Checks
2222
needs: [matrix]
2323
runs-on: ${{ matrix.operatingSystem }}
24-
services:
25-
mysql:
26-
image: mysql:8
27-
env:
28-
MYSQL_ROOT_PASSWORD: 'password'
29-
MYSQL_ROOT_HOST: '%'
30-
MYSQL_USER: 'gha'
31-
MYSQL_PASSWORD: 'password'
32-
MYSQL_DATABASE: 'laminas_session'
33-
options: >-
34-
--health-cmd="mysqladmin ping"
35-
--health-interval 10s
36-
--health-timeout 5s
37-
--health-retries 3
38-
ports:
39-
- 3306
40-
postgres:
41-
image: postgres
42-
env:
43-
POSTGRES_USER: 'gha'
44-
POSTGRES_PASSWORD: 'password'
45-
POSTGRES_DB: 'laminas_session'
46-
options: >-
47-
--health-cmd pg_isready
48-
--health-interval 10s
49-
--health-timeout 5s
50-
--health-retries 3
51-
ports:
52-
- 5432
5324
strategy:
5425
fail-fast: false
5526
matrix: ${{ fromJSON(needs.matrix.outputs.matrix) }}
@@ -58,14 +29,3 @@ jobs:
5829
uses: laminas/laminas-continuous-integration-action@v1
5930
with:
6031
job: ${{ matrix.job }}
61-
env:
62-
TESTS_LAMINAS_SESSION_ADAPTER_DRIVER_MYSQL: true
63-
TESTS_LAMINAS_SESSION_ADAPTER_DRIVER_MYSQL_HOSTNAME: mysql
64-
TESTS_LAMINAS_SESSION_ADAPTER_DRIVER_MYSQL_USERNAME: gha
65-
TESTS_LAMINAS_SESSION_ADAPTER_DRIVER_MYSQL_PASSWORD: password
66-
TESTS_LAMINAS_SESSION_ADAPTER_DRIVER_MYSQL_DATABASE: laminas_session
67-
TESTS_LAMINAS_SESSION_ADAPTER_DRIVER_PGSQL: true
68-
TESTS_LAMINAS_SESSION_ADAPTER_DRIVER_PGSQL_HOSTNAME: postgres
69-
TESTS_LAMINAS_SESSION_ADAPTER_DRIVER_PGSQL_USERNAME: gha
70-
TESTS_LAMINAS_SESSION_ADAPTER_DRIVER_PGSQL_PASSWORD: password
71-
TESTS_LAMINAS_SESSION_ADAPTER_DRIVER_PGSQL_DATABASE: laminas_session

Diff for: .laminas-ci.json

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
{
22
"extensions": [
3-
"mysql",
4-
"pgsql",
53
"xdebug"
64
],
75
"ignore_php_platform_requirements": {

Diff for: composer.json

-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
"laminas/laminas-cache": "^3.12.2",
4343
"laminas/laminas-cache-storage-adapter-memory": "^2.3",
4444
"laminas/laminas-coding-standard": "~3.0.1",
45-
"laminas/laminas-db": "^2.20.0",
4645
"laminas/laminas-http": "^2.20",
4746
"laminas/laminas-validator": "^2.64.1",
4847
"phpunit/phpunit": "^10.5.38",
@@ -51,7 +50,6 @@
5150
},
5251
"suggest": {
5352
"laminas/laminas-cache": "Laminas\\Cache component",
54-
"laminas/laminas-db": "Laminas\\Db component",
5553
"laminas/laminas-http": "Laminas\\Http component",
5654
"laminas/laminas-servicemanager": "Laminas\\ServiceManager component",
5755
"laminas/laminas-validator": "Laminas\\Validator component"

Diff for: composer.lock

+17-88
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: docs/book/v2/migration/preparing-for-v3.md

+13
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,19 @@ This document is intended to help you prepare for these changes.
55

66
## Removed Features
77

8+
### `laminas/laminas-db` Removal
9+
10+
Starting from version 3.0 the `laminas/laminas-db` dependency will be removed.
11+
The following classes are based on this package and have been marked as `deprecated` in the current version:
12+
13+
- `Laminas\Session\SaveHandler\DbTableGateway`
14+
- `Laminas\Session\SaveHandler\DbTableGatewayOptions`
15+
16+
Version 3.0 will remove these classes without replacement - any custom code based on them will require you to implement
17+
replacements yourself by creating a class that implements `Laminas\Session\SaveHandler\SaveHandlerInterface`
18+
as per [the custom save handler documentation](../save-handler.md),
19+
with an `options` class for it if the save handler is configurable.
20+
821
### `MongoDB` Removal
922

1023
`Laminas\Session\SaveHandler\MongoDB` and its options class `Laminas\Session\SaveHandler\MongoDBOptions`

Diff for: docs/book/v2/save-handler.md

+26
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,32 @@ $manager = new SessionManager();
7272
$manager->setSaveHandler($saveHandler);
7373
```
7474

75+
## MongoDB
76+
77+
`Laminas\Session\SaveHandler\MongoDB` allows you to provide a MongoDB collection to
78+
be utilized as a session save handler. You provide the options in the
79+
`Laminas\Session\SaveHandler\MongoDBOptions` class. You must install the
80+
[mongodb PHP extensions](http://php.net/mongodb) and the
81+
[MongoDB PHP library](https://github.com/mongodb/mongo-php-library).
82+
83+
### Basic Usage
84+
85+
```php
86+
use MongoDB\Client;
87+
use Laminas\Session\SaveHandler\MongoDB;
88+
use Laminas\Session\SaveHandler\MongoDBOptions;
89+
use Laminas\Session\SessionManager;
90+
91+
$mongoClient = new Client();
92+
$options = new MongoDBOptions([
93+
'database' => 'myapp',
94+
'collection' => 'sessions',
95+
]);
96+
$saveHandler = new MongoDB($mongoClient, $options);
97+
$manager = new SessionManager();
98+
$manager->setSaveHandler($saveHandler);
99+
```
100+
75101
## Custom Save Handlers
76102

77103
There may be cases where you want to create a save handler. Creating a custom

Diff for: docs/book/v3/migration/v2-to-v3.md

+16
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,22 @@ This document details those changes, and provides suggestions on how to update y
55

66
## Removed Features
77

8+
### `laminas/laminas-db` Removal
9+
10+
Starting from version 3.0 the `laminas/laminas-db` dependency has been removed.
11+
In consequence the following classes, based on this package, have also been removed:
12+
13+
- `Laminas\Session\SaveHandler\DbTableGateway`
14+
- `Laminas\Session\SaveHandler\DbTableGatewayOptions`
15+
16+
Any custom code based on them will require you to implement
17+
replacements yourself by creating classes that implement `Laminas\Session\SaveHandler\SaveHandlerInterface`
18+
as per [the custom save handler documentation](../save-handler.md),
19+
with `options` classes for them if the save handlers are configurable.
20+
21+
Alternatively, [axleus/laminas-db](https://github.com/axleus/laminas-db) is an up to date,
22+
actively maintained fork of `laminas/laminas-db` which plans to adopt the save handler.
23+
824
### `MongoDB` Removal
925

1026
MongoDB support has been completely removed in version 3.0, notably the following classes no longer exist:

Diff for: docs/book/v3/save-handler.md

-37
Original file line numberDiff line numberDiff line change
@@ -35,43 +35,6 @@ $manager = new SessionManager();
3535
$manager->setSaveHandler($saveHandler);
3636
```
3737

38-
## DbTableGateway
39-
40-
`Laminas\Session\SaveHandler\DbTableGateway` allows you to utilize
41-
`Laminas\Db\TableGateway\TableGatewayInterface` implementations as a session save
42-
handler. Setup of a `DbTableGateway` save handler requires an instance of
43-
`Laminas\Db\TableGateway\TableGatewayInterface` and an instance of
44-
`Laminas\Session\SaveHandler\DbTableGatewayOptions`. In the most basic setup, a
45-
`TableGateway` object and using the defaults of the `DbTableGatewayOptions` will
46-
provide you with what you need.
47-
48-
### Creating the database table
49-
50-
```sql
51-
CREATE TABLE `session` (
52-
`id` char(32),
53-
`name` char(32),
54-
`modified` int,
55-
`lifetime` int,
56-
`data` text,
57-
PRIMARY KEY (`id`, `name`)
58-
);
59-
```
60-
61-
### Basic usage
62-
63-
```php
64-
use Laminas\Db\TableGateway\TableGateway;
65-
use Laminas\Session\SaveHandler\DbTableGateway;
66-
use Laminas\Session\SaveHandler\DbTableGatewayOptions;
67-
use Laminas\Session\SessionManager;
68-
69-
$tableGateway = new TableGateway('session', $adapter);
70-
$saveHandler = new DbTableGateway($tableGateway, new DbTableGatewayOptions());
71-
$manager = new SessionManager();
72-
$manager->setSaveHandler($saveHandler);
73-
```
74-
7538
## Custom Save Handlers
7639

7740
There may be cases where you want to create a save handler. Creating a custom

Diff for: phpunit.xml.dist

-10
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,6 @@
2525
</groups>
2626
<php>
2727
<ini name="date.timezone" value="UTC"/>
28-
<env name="TESTS_LAMINAS_SESSION_ADAPTER_DRIVER_MYSQL" value="false"/>
29-
<env name="TESTS_LAMINAS_SESSION_ADAPTER_DRIVER_MYSQL_HOSTNAME" value="localhost"/>
30-
<env name="TESTS_LAMINAS_SESSION_ADAPTER_DRIVER_MYSQL_USERNAME" value="travis"/>
31-
<env name="TESTS_LAMINAS_SESSION_ADAPTER_DRIVER_MYSQL_PASSWORD" value=""/>
32-
<env name="TESTS_LAMINAS_SESSION_ADAPTER_DRIVER_MYSQL_DATABASE" value="laminas_session_test"/>
33-
<env name="TESTS_LAMINAS_SESSION_ADAPTER_DRIVER_PGSQL" value="false"/>
34-
<env name="TESTS_LAMINAS_SESSION_ADAPTER_DRIVER_PGSQL_HOSTNAME" value="localhost"/>
35-
<env name="TESTS_LAMINAS_SESSION_ADAPTER_DRIVER_PGSQL_USERNAME" value="travis"/>
36-
<env name="TESTS_LAMINAS_SESSION_ADAPTER_DRIVER_PGSQL_PASSWORD" value=""/>
37-
<env name="TESTS_LAMINAS_SESSION_ADAPTER_DRIVER_PGSQL_DATABASE" value="laminas_session_test"/>
3828
</php>
3929
<source>
4030
<include>

0 commit comments

Comments
 (0)