1. Go to this page and download the library: Download subtext/persistables library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
subtext / persistables example snippets
namespace Subtext\Persistables;
#[Table(name: 'users', primaryKey: 'userId')]
class User extends Persistable
{
#[Column(name: 'user_id')]
protected ?int $userId = null;
#[Column(name: 'user_name')]
protected ?string $userName = null;
#[Column(name: 'email_address')]
protected ?string $email = null;
/**
* Defining an empty constructor allows the entity to be autowired for
* dependency injection
*/
public function __construct()
{}
public function getUserId(): ?int
{
return $this->userId;
}
public function setUserId(?int $userId): void
{
$this->modify('userId', $userId);
}
public function getUserName(): ?string
{
return $this->userName;
}
public function setUserName(string $userName): void
{
$this->modify('userName', $userName);
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): void
{
$this->modify('email', $email);
}
public function jsonSerialize(): mixed
{
return (object) [
'userId' => $this->getUserId(),
'userName' => $this->getUserName(),
'email' => $this->getEmail(),
];
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.