Adds support for MySQL storage in your application.
composer require phpolar/mysql-storage- Keep project small. See thresholds
- Automatically load and persist data
Note For more details see the acceptance tests results
$mysqlStorage = new MySqlStorage(
connection: $connection,
tableName: "table_name",
typeClassName: Person::class,
);
$mysqlStorage->save($item1->id, $item);
$mysqlStorage->replace($updatedItem->id, $updatedItem);
$mysqlStorage->remove($item2->id);
$item3 = $mysqlStorage->find("id3")
->orElse(static fn() => new NotFound())
->tryUnwrap();
$allItems = $mysqlStorage->findAll();use Phpolar\Phpolar\AbstractModel;
class Person extends AbstractModel
{
#[PrimaryKey]
#[Hidden]
public string $id;
public string $firstName;
public string $lastName;
public string $address1;
public string $address2;
public function getPrimaryKey(): string
{
return $id;
}
}| Module | Source Code Size * | Memory Usage | Required |
|---|---|---|---|
| phpolar/mysql-storage | 900 B | 110 kB | x |
- Note: Does not include comments.