Skip to content
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
68 changes: 34 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,55 +32,55 @@ layers the bridge's wiring on top of PhpDb's.

1. Install the package:

```bash
composer require webware/webware-phpdb
```
```bash
composer require webware/webware-phpdb
```

2. Merge its providers in the consumer's config aggregator:

```php
use Laminas\ConfigAggregator\ConfigAggregator;

$aggregator = new ConfigAggregator([
PhpDb\ConfigProvider::class,
PhpDb\WebwareProvider::class,
// ...
Mezzio\Session\ConfigProvider::class,
// After every provider that declares SessionPersistenceInterface:
// it re-points that alias at the database persistence.
PhpDb\Session\SessionProvider::class,
]);
```
```php
use Laminas\ConfigAggregator\ConfigAggregator;

$aggregator = new ConfigAggregator([
PhpDb\ConfigProvider::class,
PhpDb\WebwareProvider::class,
// ...
Mezzio\Session\ConfigProvider::class,
// After every provider that declares SessionPersistenceInterface:
// it re-points that alias at the database persistence.
PhpDb\Session\SessionProvider::class,
]);
```

`PhpDb\WebwareProvider` shares no config keys with `PhpDb\ConfigProvider`, so their relative order
does not change the merged result. `SessionProvider` is the one with an ordering requirement.
`PhpDb\WebwareProvider` shares no config keys with `PhpDb\ConfigProvider`, so their relative order
does not change the merged result. `SessionProvider` is the one with an ordering requirement.

3. Build table identifiers from a schema enum, so raw table names stay out of the application
layer:

```php
use PhpDb\SchemaFactory;
use PhpDb\SchemaInterface;
```php
use PhpDb\SchemaFactory;
use PhpDb\SchemaInterface;

enum WebwareSchema: string implements SchemaInterface
{
public const string NAME = 'webware';
enum WebwareSchema: string implements SchemaInterface
{
public const string NAME = 'webware';

case Session = 'session';
}
case Session = 'session';
}

$factory = $container->get(SchemaFactory::class);
$identifier = $factory(WebwareSchema::Session);
$factory = $container->get(SchemaFactory::class);
$identifier = $factory(WebwareSchema::Session);

$identifier->getTable(); // 'session' until a prefix is configured
$identifier->getSchema(); // 'webware'
```
$identifier->getTable(); // 'session' until a prefix is configured
$identifier->getSchema(); // 'webware'
```

4. Create the session table, and let Mezzio session middleware use it:

```bash
vendor/bin/webware session:init-db
```
```bash
vendor/bin/webware session:init-db
```

With `SessionProvider` merged, `Mezzio\Session\SessionPersistenceInterface` resolves to
`PhpDb\Session\PhpDbSessionPersistence`, which reads and writes that table.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"roave/security-advisories": "dev-master",
"webware/webware-console": "1.0.x-dev",
"webware/webware-event": "1.0.0-alpha.5",
"webware/webware-tools": "^1.0.0-rc.14"
"webware/webware-tools": "^1.1.0"
},
"suggest": {
"mezzio/mezzio-session": "Required to use the database-backed session persistence",
Expand Down
20 changes: 10 additions & 10 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/v1/schema-factory.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,4 @@ that a table belongs to the connection's default schema.
An empty value in configuration never reaches `TableIdentifier`: the shape assertion rejects it
while `SchemaFactory` is constructed, so only a call-time override can produce
`InvalidArgumentException` from the identifier itself. The shape is closed, so an unrecognized key
such as `prefx` fails at construction rather than being ignored.
such as `prefx` fails at construction rather than being ignored.
19 changes: 19 additions & 0 deletions markdownlint-cli2.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// markdownlint-cli2 configuration for aligned packages.
//
// Formatting consistency for documentation: every default rule except two.
//
// Off by design:
// MD013 line-length - 1588 findings in webware-console alone, and prose
// wrapping is not structural consistency
// MD060 table-column-style - alignment padding, same reasoning
//
// The required workflow runs this by name as the `markdown` job.
{
"config": {
"default": true,
"MD013": false,
"MD060": false
},
"globs": ["**/*.md"],
"ignores": ["vendor/**", "node_modules/**"]
}
11 changes: 6 additions & 5 deletions src/Session/Sql/Insert.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@
final class Insert extends BaseInsert
{
protected array $specifications = [
self::SPECIFICATION_INSERT => 'INSERT INTO %1$s (%2$s) VALUES (%3$s)'
. ' ON DUPLICATE KEY UPDATE'
. ' payload = VALUES(payload)'
. ', expires_at = VALUES(expires_at)'
. ', modified_at = VALUES(modified_at)',
self::SPECIFICATION_INSERT =>
'INSERT INTO %1$s (%2$s) VALUES (%3$s)'
. ' ON DUPLICATE KEY UPDATE'
. ' payload = VALUES(payload)'
. ', expires_at = VALUES(expires_at)'
. ', modified_at = VALUES(modified_at)',
self::SPECIFICATION_SELECT => 'INSERT INTO %1$s %2$s %3$s',
];
}
16 changes: 8 additions & 8 deletions src/TableGateway/Feature/EventDispatcherFeature.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function getEventDispatcher(): EventDispatcherInterface
public function postDelete(StatementInterface $statement, ResultInterface $result): void
{
$this->dispatch(
name: static::EVENT_POST_DELETE,
name : static::EVENT_POST_DELETE,
params: [
'statement' => $statement,
'result' => $result,
Expand All @@ -84,7 +84,7 @@ public function postInitialize(): void
public function postInsert(StatementInterface $statement, ResultInterface $result): void
{
$this->dispatch(
name: static::EVENT_POST_INSERT,
name : static::EVENT_POST_INSERT,
params: [
'statement' => $statement,
'result' => $result,
Expand All @@ -104,7 +104,7 @@ public function postSelect(
ResultSetInterface $resultSet,
): void {
$this->dispatch(
name: static::EVENT_POST_SELECT,
name : static::EVENT_POST_SELECT,
params: [
'statement' => $statement,
'result' => $result,
Expand All @@ -121,7 +121,7 @@ public function postSelect(
public function postUpdate(StatementInterface $statement, ResultInterface $result): void
{
$this->dispatch(
name: static::EVENT_POST_UPDATE,
name : static::EVENT_POST_UPDATE,
params: [
'statement' => $statement,
'result' => $result,
Expand All @@ -136,7 +136,7 @@ public function postUpdate(StatementInterface $statement, ResultInterface $resul
public function preDelete(Delete $delete): void
{
$this->dispatch(
name: static::EVENT_PRE_DELETE,
name : static::EVENT_PRE_DELETE,
params: ['delete' => $delete],
);
}
Expand All @@ -156,7 +156,7 @@ public function preInitialize(): void
public function preInsert(Insert $insert): void
{
$this->dispatch(
name: static::EVENT_PRE_INSERT,
name : static::EVENT_PRE_INSERT,
params: ['insert' => $insert],
);
}
Expand All @@ -168,7 +168,7 @@ public function preInsert(Insert $insert): void
public function preSelect(Select $select): void
{
$this->dispatch(
name: static::EVENT_PRE_SELECT,
name : static::EVENT_PRE_SELECT,
params: ['select' => $select],
);
}
Expand All @@ -180,7 +180,7 @@ public function preSelect(Select $select): void
public function preUpdate(Update $update): void
{
$this->dispatch(
name: static::EVENT_PRE_UPDATE,
name : static::EVENT_PRE_UPDATE,
params: ['update' => $update],
);
}
Expand Down