Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
inxilpro committed Jan 20, 2024
1 parent 53c4193 commit 94771ac
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class MySessionClass implements SessionHandlerInterface

public function public open(string $path, string $name): bool
{
$this->callHook('beforeOpened');
$this->callHook('beforeOpened', $name);
// ...
}

Expand All @@ -78,12 +78,12 @@ Now, you can hook into these points from elsewhere in your app:
$hooks = Session::hook();

// Register your custom code to execute at those points
$hooks->beforeOpened(fn() => Log::info('Session starting'));
$hooks->beforeOpened(fn($name) => Log::info("Starting session '$name'"));
$hooks->beforeWritten(fn() => Log::info('Writing session to storage'));
```

Now, whenenver `MySessionClass::open` is called, a `"Session starting"` message will be logged,
and whenever `MySessionClass::write` is called, a `"Writing session to storage"` message will be logged.
Now, whenenver `MySessionClass::open` is called, a "Starting session '<session name>'" message will be logged,
and whenever `MySessionClass::write` is called, a "Writing session to storage" message will be logged.

### When to use class hooks

Expand Down

0 comments on commit 94771ac

Please sign in to comment.