Skip to content

Commit 9471306

Browse files
ivosgemspont4e
andauthored
Update Laravel version to 11.x and PHP version to 8.2 (#30)
* Added support for Laravel 10.x (#15) * Updated mongodb/laravel-mongodb package (#16) * Refactor method signatures in MongoDbSessionHandler for clarity and type safety. Add .editorconfig for consistent coding style across files. Update composer.json to include ext-mongodb requirement. (#23) * V5.x rebase (#25) * v5.x to master (#17) * Added support for Laravel 10.x (#15) * Updated mongodb/laravel-mongodb package (#16) # Conflicts: # composer.json * Update laravel mongodb to rc1 (#18) * Added support for Laravel 10.x (#15) * Updated mongodb/laravel-mongodb package (#16) * Updated mongodb/laravel-mongodb to rc1. * Updated mongodb/laravel-mongodb to stable version 4. (#19) * Changed package version * Update deprecated MongoDB read preference constants to use current values (#28) * Update deprecated MongoDB read preference constants to use current values * Bump version to 5.0.5 in composer.json for updated dependencies * Update session testing suite, add MongoDB test cases, and configure PHPUnit - Enhance `.gitignore` to exclude `.phpunit.cache`. - Update GitHub workflow to include Testbench version for Laravel 10.x. - Create new feature tests: `TestHelperIntegrationTest`, `HttpSessionTest`, and `MongoDbSessionHandlerTest` to validate session handling with MongoDB. - Refactor MongoDB session command files to remove unnecessary docblocks. - Document testing process in `README.md`, including setup and expected results. - Add basic PHPUnit configuration file. - Define session environment in the base `TestCase`. - Ensure session operations like reading, writing, and destruction are tested against MongoDB. * Update GitHub Actions workflow to use MongoDB 7 and improve caching - Add MongoDB 7 service to CI workflow - Upgrade checkout action to v3 - Include MongoDB extension in PHP setup - Implement Composer dependency caching for faster builds - Modify composer install command for better performance - Set environment variables for MongoDB connection during test execution - Update README.md to reflect changes in the CI process * Remove deprecated MongoDB version constraint from composer.json * Update mongodb/laravel-mongodb package to version 5.0 in composer.json (#27) * Update mongodb/laravel-mongodb package to version 5.0 in composer.json * Update MongoDB commands and improve session handling Refactor the command to use `getDatabase()` instead of `getMongoDB()`. Update payload access in `MongoDbSessionHandler` from array syntax to object syntax for better readability. Adjust test assertions to match the new access methodology and ensure compatibility with Carbon instances for expiration and last activity timestamps. Clean up formatting inconsistencies throughout the code. * Update MongoDB connection method to use getDatabase() instead of getMongoDB() in MongodbSessionIndex command * Update GitHub Actions workflow to trigger on the master branch * Update Laravel version to 11.x and PHP version to 8.2, adjust workflow and configuration files accordingly --------- Co-authored-by: Ivaylo Mutafov <[email protected]>
1 parent 1f354ed commit 9471306

File tree

7 files changed

+25
-28
lines changed

7 files changed

+25
-28
lines changed

.github/workflows/run-tests-l10.yml renamed to .github/workflows/run-tests-l11.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
name: "Run Tests - Laravel 10"
1+
name: "Run Tests - Laravel 11"
22

33
on:
44
push:
5-
branches: [ v5.x, master ]
5+
branches: [ v6.x, master ]
66

77
pull_request:
8-
branches: [ v5.x, master ]
8+
branches: [ v6.x, master ]
99

1010
jobs:
1111
tests:
@@ -26,11 +26,11 @@ jobs:
2626
strategy:
2727
fail-fast: false
2828
matrix:
29-
php: [ 8.1 ]
30-
laravel: [ 10.* ]
29+
php: [ 8.2 ]
30+
laravel: [ 11.* ]
3131
include:
32-
- laravel: 10.*
33-
testbench: 10.*
32+
- laravel: 11.*
33+
testbench: 11.*
3434

3535
name: P${{ matrix.php }} - L${{ matrix.laravel }}
3636

.phprc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
php8.1
1+
php8.2

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ A MongoDB session driver for Laravel
44

55
| **Laravel<br/>Version** | **Package<br/>Version** | **Install using<br/>this command** |
66
|-------------------------|-------------------------|---------------------------------------------------|
7+
| 11.x | 6.x.x | composer require 1ff/laravel-mongodb-session:^6.0 |
78
| 10.x | 5.x.x | composer require 1ff/laravel-mongodb-session:^5.0 |
89
| 9.x | 4.x.x | composer require 1ff/laravel-mongodb-session:^4.0 |
910
| 8.x | 3.x.x | composer require 1ff/laravel-mongodb-session:^3.0 |

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
"description": "A mongodb session driver for laravel",
44
"type": "library",
55
"require": {
6-
"php": "^8.1",
7-
"illuminate/session": "^10.0",
6+
"php": "^8.2",
7+
"illuminate/session": "^11.0",
88
"mongodb/laravel-mongodb": "^5.0",
99
"ext-mongodb": "*"
1010
},
1111
"require-dev": {
12-
"phpunit/phpunit": "^10.0",
13-
"orchestra/testbench": "^8.0"
12+
"phpunit/phpunit": "^11.0",
13+
"orchestra/testbench": "^9.0"
1414
},
1515
"license": "MIT",
1616
"authors": [
@@ -42,6 +42,6 @@
4242
}
4343
},
4444
"scripts": {
45-
"test": "vendor/bin/phpunit"
45+
"test": "$(head -1 .phprc) ./vendor/bin/phpunit"
4646
}
4747
}

phpunit.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
colors="true"
77
processIsolation="false"
88
stopOnFailure="false"
9-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
9+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.0/phpunit.xsd"
1010
cacheDirectory=".phpunit.cache"
1111
backupStaticProperties="false"
1212
>
@@ -24,4 +24,4 @@
2424
<env name="MONGODB_PORT" value="27017"/>
2525
<env name="MONGODB_DATABASE" value="laravel_session_test"/>
2626
</php>
27-
</phpunit>
27+
</phpunit>

src/MongoDbSessionHandler.php

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,20 @@
22

33
namespace ForFit\Session;
44

5+
use Illuminate\Database\ConnectionInterface;
6+
use Illuminate\Database\Query\Builder;
57
use MongoDB\BSON\Binary;
68
use MongoDB\BSON\UTCDateTime;
79
use MongoDB\Driver\Exception\BulkWriteException;
810
use SessionHandlerInterface;
911

1012
class MongoDbSessionHandler implements SessionHandlerInterface
1113
{
12-
protected $connection;
13-
protected $minutes;
14-
protected $table;
14+
protected ConnectionInterface $connection;
15+
protected int $minutes;
16+
protected string $table;
1517

16-
/**
17-
* @param \Illuminate\Database\ConnectionInterface $connection
18-
* @param string $table
19-
* @param integer $minutes
20-
*/
21-
public function __construct($connection, $table = 'sessions', $minutes = 60)
18+
public function __construct(ConnectionInterface $connection, string $table = 'sessions', int $minutes = 60)
2219
{
2320
$this->connection = $connection;
2421
$this->minutes = (int)$minutes;
@@ -89,7 +86,7 @@ public function gc($max_lifetime): false|int
8986
* Returns the query builder
9087
*
9188
*/
92-
protected function query()
89+
protected function query(): Builder
9390
{
9491
return $this->connection->table($this->table);
9592
}
@@ -100,7 +97,7 @@ protected function query()
10097
* @param string|null $data
10198
* @return array
10299
*/
103-
protected function buildPayload($data)
100+
protected function buildPayload($data): array
104101
{
105102
return [
106103
'payload' => new Binary($data, Binary::TYPE_OLD_BINARY),

src/SessionServiceProvider.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ class SessionServiceProvider extends ParentServiceProvider
1313
* Register any application services.
1414
*
1515
* @throws \Exception
16-
* @return void
1716
*
1817
*/
19-
public function boot()
18+
public function boot(): void
2019
{
2120
if (config('session.driver') !== 'mongodb') {
2221
return;

0 commit comments

Comments
 (0)