Skip to content
This repository was archived by the owner on Jul 31, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: "Run Tests - Laravel 10"
name: "Run Tests - Laravel 11"

on:
push:
branches: [ v5.x, master ]
branches: [ v6.x, master ]

pull_request:
branches: [ v5.x, master ]
branches: [ v6.x, master ]

jobs:
tests:
Expand All @@ -26,11 +26,11 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [ 8.1 ]
laravel: [ 10.* ]
php: [ 8.2 ]
laravel: [ 11.* ]
include:
- laravel: 10.*
testbench: 10.*
- laravel: 11.*
testbench: 11.*

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

Expand Down
2 changes: 1 addition & 1 deletion .phprc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
php8.1
php8.2
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ A MongoDB session driver for Laravel

| **Laravel<br/>Version** | **Package<br/>Version** | **Install using<br/>this command** |
|-------------------------|-------------------------|---------------------------------------------------|
| 11.x | 6.x.x | composer require 1ff/laravel-mongodb-session:^6.0 |
| 10.x | 5.x.x | composer require 1ff/laravel-mongodb-session:^5.0 |
| 9.x | 4.x.x | composer require 1ff/laravel-mongodb-session:^4.0 |
| 8.x | 3.x.x | composer require 1ff/laravel-mongodb-session:^3.0 |
Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
"description": "A mongodb session driver for laravel",
"type": "library",
"require": {
"php": "^8.1",
"illuminate/session": "^10.0",
"php": "^8.2",
"illuminate/session": "^11.0",
"mongodb/laravel-mongodb": "^5.0",
"ext-mongodb": "*"
},
"require-dev": {
"phpunit/phpunit": "^10.0",
"orchestra/testbench": "^8.0"
"phpunit/phpunit": "^11.0",
"orchestra/testbench": "^9.0"
},
"license": "MIT",
"authors": [
Expand Down Expand Up @@ -42,6 +42,6 @@
}
},
"scripts": {
"test": "vendor/bin/phpunit"
"test": "$(head -1 .phprc) ./vendor/bin/phpunit"
}
}
4 changes: 2 additions & 2 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
colors="true"
processIsolation="false"
stopOnFailure="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.0/phpunit.xsd"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
>
Expand All @@ -24,4 +24,4 @@
<env name="MONGODB_PORT" value="27017"/>
<env name="MONGODB_DATABASE" value="laravel_session_test"/>
</php>
</phpunit>
</phpunit>
19 changes: 8 additions & 11 deletions src/MongoDbSessionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,20 @@

namespace ForFit\Session;

use Illuminate\Database\ConnectionInterface;
use Illuminate\Database\Query\Builder;
use MongoDB\BSON\Binary;
use MongoDB\BSON\UTCDateTime;
use MongoDB\Driver\Exception\BulkWriteException;
use SessionHandlerInterface;

class MongoDbSessionHandler implements SessionHandlerInterface
{
protected $connection;
protected $minutes;
protected $table;
protected ConnectionInterface $connection;
protected int $minutes;
protected string $table;

/**
* @param \Illuminate\Database\ConnectionInterface $connection
* @param string $table
* @param integer $minutes
*/
public function __construct($connection, $table = 'sessions', $minutes = 60)
public function __construct(ConnectionInterface $connection, string $table = 'sessions', int $minutes = 60)
{
$this->connection = $connection;
$this->minutes = (int)$minutes;
Expand Down Expand Up @@ -89,7 +86,7 @@ public function gc($max_lifetime): false|int
* Returns the query builder
*
*/
protected function query()
protected function query(): Builder
{
return $this->connection->table($this->table);
}
Expand All @@ -100,7 +97,7 @@ protected function query()
* @param string|null $data
* @return array
*/
protected function buildPayload($data)
protected function buildPayload($data): array
{
return [
'payload' => new Binary($data, Binary::TYPE_OLD_BINARY),
Expand Down
3 changes: 1 addition & 2 deletions src/SessionServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ class SessionServiceProvider extends ParentServiceProvider
* Register any application services.
*
* @throws \Exception
* @return void
*
*/
public function boot()
public function boot(): void
{
if (config('session.driver') !== 'mongodb') {
return;
Expand Down