1. Go to this page and download the library: Download splitstack/aristotle 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/ */
splitstack / aristotle example snippets
// app/Domain/Auth/Entities/UserEntity.php
namespace App\Domain\Auth\Entities;
use Carbon\CarbonInterface;
use Splitstack\Aristotle\BaseEntity;
final class UserEntity extends BaseEntity
{
public function __construct(
public ?int $id = null,
public string $name,
public string $email,
public ?CarbonInterface $email_verified_at = null,
) {}
}
$user = UserEntity::fromArray($model->toArray());
$user->name; // typed access
$user['email']; // ArrayAccess
foreach ($user as $key => $value) { ... } // iterable
$user->toArray(); // back to array
// config/aristotle.php
return [
// Root namespace for all domains
'namespace' => 'App\\Domain',
// Sub-folder appended after the domain name
// e.g. "Entities" → App\Domain\Auth\Entities
// Set to null or '' to place entities directly under the domain
'entities_folder' => 'Entities',
// Optional suffix appended to generated class names
// e.g. "Entity" → UserEntity
'entity_suffix' => env('ARISTOTLE_ENTITY_SUFFIX', 'Entity'),
];