FormRequest, Resource classes).DTOTrait to existing DTO classes. No database or ORM modifications needed.sajadsdi/php-reflection), which is stable but may introduce minor runtime overhead (~1–5ms per DTO instantiation, negligible for most use cases).__get(), __set()) in parent classes.__call() implementations.HasFactory or Observables if DTOs are mistakenly used as Eloquent models.getSetName) could still cause issues if not tested.ReflectionClass instances).sajadsdi/php-reflection (v1.0+), which has no dependents—monitor for updates or forks.__construct(array $data) + no setters)? The package doesn’t enforce this.FormRequest or Validator for API input? If so, how will validation rules be attached?toArray() method is provided but not optimized for JSON.Illuminate\Support\Collection, Spatie’s Arrayable, or custom traits (e.g., Arrayable, Jsonable).arrayObject or attributes could replace this package.CreateUserRequestDTO, UserResourceDTO).ProcessOrderJobDTO).getName()/setName() with the trait.Validator or FormRequest by extending DTOs:
use Sajadsdi\DtoTool\Concerns\DTOTrait;
use Illuminate\Validation\Rules\RequiredIf;
class CreateUserDTO {
use DTOTrait;
private string $name;
private string $email;
public function rules(): array {
return [
'name' => ['required'],
'email' => ['required', 'email'],
];
}
}
toArray().Macroable).composer require sajadsdi/dto-tool sajadsdi/php-reflection
DTOTrait.// Before
class UserDTO {
private string $name;
public function getName(): string { return $this->name; }
public function setName(string $name): void { $this->name = $name; }
}
// After
class UserDTO {
use DTOTrait;
private string $name;
}
getName()/setName().toArray()/init().protected properties).sajadsdi/php-reflection for updates.getName not found" when reflection fails).getSetName collisions).#dto or #laravel for visibility.ReflectionClass instances (e.g., in a static property).| Scenario | Impact | Mitigation |
|---|---|---|
| Reflection fails (e.g., invalid property) | Silent failure or Error |
Add @property PHPDoc or runtime checks. |
| Property naming collisions | Overridden methods break | Test with getSetX edge cases. |
| Package abandonment | No updates/bug fixes | Fork or migrate to alternatives. |
| IDE misconfiguration | Autocomplete/method hints fail | Use @mixin PHPDoc for traits. |
How can I help you explore Laravel packages today?