Skip to content

Framework Integration Overview

Overview of framework integrations for Laravel, Symfony, Doctrine, and Plain PHP.

Data Helpers works with any PHP 8.2+ project and provides optional framework integrations:

  • Laravel 9+ - Automatic service provider, controller injection, Eloquent integration
  • Symfony 6+ - Bundle registration, value resolvers, Doctrine integration
  • Doctrine 2+ - Entity mapping, collection support
  • Plain PHP - Works out of the box with arrays, objects, JSON

All framework integrations are automatically detected at runtime:

// Laravel Detection
if (class_exists(\Illuminate\Support\Collection::class)) {
// Enable Laravel Collection support
}
// Symfony Detection
if (class_exists(\Symfony\Component\HttpFoundation\Request::class)) {
// Enable Symfony Request support
}
Terminal window
composer require event4u/data-helpers

That’s it! Data Helpers automatically detects your framework.

Features:

  • ✅ Service Provider auto-registration
  • ✅ Controller dependency injection
  • ✅ Eloquent Model integration
  • ✅ Artisan commands (make:dto, dto:typescript)
  • ✅ Laravel-specific attributes (WhenAuth, WhenCan, WhenRole)

Features:

  • ✅ Bundle auto-registration (with Flex)
  • ✅ Value Resolver for controllers
  • ✅ Doctrine Entity integration
  • ✅ Console commands (make:dto, dto:typescript)
  • ✅ Symfony-specific attributes (WhenGranted, WhenSymfonyRole)

Features:

  • ✅ Entity mapping (fromEntity, toEntity)
  • ✅ Collection support
  • ✅ Lazy loading

Features:

  • ✅ Arrays, Objects, JSON, XML
  • ✅ No dependencies required
class UserDTO extends SimpleDTO
{
public function __construct(
#[Required, Email]
public readonly string $email,
) {}
}
// In controller
public function store(UserDTO $dto) {
// Automatic validation & injection
}
#[Route('/users', methods: ['POST'])]
public function create(UserDTO $dto): JsonResponse {
// Automatic validation & injection
}
$dto = UserDTO::fromArray($_POST);
$dto->validate();