apie/type-converter
Apie type converter converts PHP objects into other objects, ideal for mapping DTOs to domain objects and back. It ships with default converters and lets you easily write your own.
bind() or tag()).Validator or custom logic).| Risk Area | Assessment | Mitigation Strategy |
|---|---|---|
| Maturity | Low stars/dependents; minimal documentation. | Start with proof-of-concept in a non-critical module. Monitor for updates. |
| Breaking Changes | Unstable API (no major releases yet). | Pin to a specific version in composer.json and test upgrades rigorously. |
| Error Handling | Limited built-in error handling for invalid conversions. | Wrap conversions in try-catch blocks or extend the package with custom exceptions. |
| Testing Coverage | Coverage badge shows ~80%, but real-world edge cases may be untested. | Write integration tests for critical conversion paths. |
| Laravel-Specific Gaps | No native integration with Laravel’s API Resources or Eloquent. | Build wrapper classes or middleware to bridge the package with Laravel patterns. |
DefaultConvertersFactory handle 80% of use cases?User->Posts->Comments) be managed? Recursive conversion or manual mapping?api_resources.apie-lib ecosystem actively maintained? Check for recent commits/updates.spatie/array-to-object, league/glide, or custom solutions) that might be more mature?$this->app->bind(ConverterInterface::class, function ($app) {
return DefaultConvertersFactory::create();
});
Converter facade for cleaner syntax:
use Apie\TypeConverter\ConverterInterface;
facade(ConverterInterface::class, 'converter');
Usage:
$userDto = converter()->convert(User::class, UserDto::class, $userEntity);
AppServiceProvider or a dedicated ConverterServiceProvider.array_map/json_encode in controllers with converter-based responses:
return response()->json(
converter()->convert(User::class, UserResource::class, $user)
);
JsonResource:
public function toArray($request): array {
return converter()->convert($this->resource, ArrayableDto::class);
}
fill()):
$user = converter()->convert(stdClass::class, User::class, $rawData);
boot()).laravel/framework, spatie/laravel-activitylog).cache() helper).$this->mock(ConverterInterface::class)->shouldReceive('convert')
->andReturn($mockDto);
User → UserDto).array_map, json_encode, or manual property assignments.tests/Feature).How can I help you explore Laravel packages today?