Installation Add the bundle via Composer:
composer require chill-project/person
Register the bundle in config/bundles.php (Symfony) or config/app.php (Laravel wrapper if available):
Chill\PersonBundle\ChillPersonBundle::class => ['all' => true],
Database Migration Run the bundle’s migrations (if provided):
php artisan migrate
Check src/Chill/PersonBundle/Resources/migrations/ for schema definitions.
First Use Case Fetch a person by ID:
use Chill\PersonBundle\Entity\Person;
$person = app(\Chill\PersonBundle\Repository\PersonRepository::class)
->find(1);
CRUD Operations Use the repository pattern for all interactions:
// Create
$person = new Person();
$person->setFirstName('John');
$person->setLastName('Doe');
$repository->save($person);
// Update
$person->setEmail('[email protected]');
$repository->save($person);
// Delete
$repository->remove($person);
Querying Leverage DQL or QueryBuilder:
$adults = $repository->createQueryBuilder('p')
->where('p.age >= :age')
->setParameter('age', 18)
->getQuery()
->getResult();
Events & Lifecycle Subscribe to bundle events (if documented):
// Example: Listen for person creation
event(new \Chill\PersonBundle\Event\PersonCreatedEvent($person));
Person entity with custom validation rules (e.g., unique:persons,email).Resource classes to format responses:
return new PersonResource($person);
PersonRepository in unit tests:
$this->mock(PersonRepository::class)->shouldReceive('find')->andReturn($mockPerson);
Archived Status
Documentation Gaps
src/Chill/PersonBundle/Tests/ for usage patterns.Entity Configuration
config/packages/doctrine.yaml includes:
orm:
mappings:
chill_person:
type: attribute
dir: "%kernel.project_dir%/vendor/chill-project/person/src/Entity"
prefix: "Chill\PersonBundle\Entity"
alias: ChillPerson
Person entity is properly mapped in Doctrine:
php bin/console doctrine:schema:validate
public function onPersonCreated(PersonCreatedEvent $event) {
\Log::info('Person created:', [$event->getPerson()->getId()]);
}
email, last_name) via custom migrations.Custom Fields
Extend the Person entity (use inheritance or traits):
namespace App\Entity;
use Chill\PersonBundle\Entity\Person as BasePerson;
class Person extends BasePerson {
#[ORM\Column]
private ?string $customField = null;
}
Repository Overrides Create a custom repository and bind it in services:
# config/services.yaml
App\Repository\CustomPersonRepository:
arguments: ['@entity_manager']
tags: ['doctrine.repository_service']
API Resources
Override serialization groups in Person:
#[Groups(['default', 'admin'])]
public function getFullName(): string {
return $this->firstName . ' ' . $this->lastName;
}
How can I help you explore Laravel packages today?