1. Go to this page and download the library: Download websk/php-entity 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/ */
websk / php-entity example snippets
use WebSK\Entity\Entity;
final class Article extends Entity
{
public const string DB_TABLE_NAME = 'articles';
protected string $title = '';
public function getTitle(): string
{
return $this->title;
}
public function setTitle(string $title): void
{
$this->title = $title;
}
}
use WebSK\DB\DBService;
use WebSK\Entity\EntityRepository;
final class ArticleRepository extends EntityRepository
{
}
$repository = new ArticleRepository(Article::class, $db_service);
$article = $repository->findById(1);
use WebSK\Entity\EntityService;
final class ArticleService extends EntityService
{
}
$service = new ArticleService(Article::class, $repository, $cache_service);
$article = $service->getById(1);
use WebSK\Entity\EntityConfig;
EntityConfig::setIgnoreMissingPropertiesOnLoad(true);
EntityConfig::setIgnoreMissingPropertiesOnSave(true);
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.