Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Cms Extbase Laravel Package

typo3/cms-extbase

TYPO3 Extbase framework extension: provides the MVC foundation for TYPO3 CMS extensions, including controllers, domain models, persistence, validation, and property mapping. Used to build structured, maintainable TYPO3 applications and plugins.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup for a Laravel Developer

  1. Understand the Core Concept Extbase is a Model-View-Controller (MVC) framework for TYPO3 CMS, not Laravel. However, its Domain-Driven Design (DDD) principles (Entities, Repositories, Services, Value Objects) align closely with Laravel’s Eloquent and Service Layer patterns.

    • First step: Treat Extbase as a domain modeling tool rather than a full-stack framework.
    • Key analogy:
      • Extbase Domain\Model\* → Laravel app/Models/
      • Extbase Repository → Laravel Eloquent + Repository pattern
      • Extbase Service → Laravel Services (e.g., App\Services\*)
      • Extbase Controller → Laravel Controller (but with TYPO3-specific hooks).
  2. Installation (TYPO3 Context) Since this is a TYPO3 package, you cannot use it directly in Laravel. Instead:

    • Option 1: Study Extbase’s design patterns and adapt them to Laravel (e.g., custom repositories, DTOs).
    • Option 2: Use it in a TYPO3 project alongside Laravel via TYPO3’s REST API or Laravel’s HTTP client to interact with Extbase-backed endpoints.
  3. First Use Case: Modeling a Blog Post

    // Extbase-style Domain Model (hypothetical Laravel adaptation)
    namespace App\Models;
    
    use Illuminate\Database\Eloquent\Model;
    
    class BlogPost extends Model
    {
        // Extbase-style property (like @var in TYPO3)
        protected $title;
        protected $content;
    
        // Extbase-style getter/setter (Laravel accessors)
        public function getTitle(): string
        {
            return $this->title;
        }
    
        public function setTitle(string $title): void
        {
            $this->title = $title;
        }
    }
    
    // Extbase Repository (Laravel Repository Pattern)
    namespace App\Repositories;
    
    use App\Models\BlogPost;
    use Illuminate\Pagination\LengthAwarePaginator;
    
    class BlogPostRepository
    {
        public function findAll(): LengthAwarePaginator
        {
            return BlogPost::paginate(10);
        }
    }
    
  4. Where to Look First

    • Extbase Documentation: Official TYPO3 Extbase Guide
    • Key Classes:
      • TYPO3\CMS\Extbase\Domain\Model\AbstractEntity (Base model)
      • TYPO3\CMS\Extbase\Persistence\Repository (Query builder)
      • TYPO3\CMS\Extbase\Domain\Object\AbstractValueObject (Immutable data objects)
    • Laravel Equivalent: Compare with Laravel’s Eloquent, Accessors/Mutators, and Repository interfaces.

Implementation Patterns

1. Domain-Driven Design (DDD) in Laravel

Extbase enforces strict separation of concerns via:

  • Entities: Business logic (e.g., User, Order).
  • Value Objects: Immutable data (e.g., Email, Money).
  • Repositories: Database abstraction (like Laravel’s Eloquent but with more constraints).
  • Services: Business logic (like Laravel’s Services).

Laravel Adaptation:

// Extbase ValueObject → Laravel Value Object (Immutable)
namespace App\ValueObjects;

final class Email
{
    private string $address;

    public function __construct(string $address)
    {
        $this->validate($address);
        $this->address = $address;
    }

    private function validate(string $address): void
    {
        if (!filter_var($address, FILTER_VALIDATE_EMAIL)) {
            throw new \InvalidArgumentException("Invalid email");
        }
    }

    public function getAddress(): string
    {
        return $this->address;
    }
}

2. Repository Pattern

Extbase repositories extend TYPO3\CMS\Extbase\Persistence\Repository and provide query methods. Laravel Equivalent: Use Spatie’s Laravel Repository or a custom trait.

// Extbase Repository → Laravel Repository
namespace App\Repositories;

use App\Models\BlogPost;
use Spatie\Repository\Repository;

class BlogPostRepository extends Repository
{
    public function model()
    {
        return BlogPost::class;
    }

    // Extbase-style query method
    public function findPublished(): array
    {
        return $this->model->where('published', true)->get();
    }
}

3. Dependency Injection (DI)

Extbase uses TYPO3’s DI container, but Laravel’s service container works similarly. Example: Inject a repository into a service/controller.

// Extbase Controller → Laravel Controller
namespace App\Http\Controllers;

use App\Repositories\BlogPostRepository;
use Illuminate\Http\Request;

class BlogController extends Controller
{
    protected $blogPostRepository;

    public function __construct(BlogPostRepository $blogPostRepository)
    {
        $this->blogPostRepository = $blogPostRepository;
    }

    public function index()
    {
        $posts = $this->blogPostRepository->findPublished();
        return view('posts.index', compact('posts'));
    }
}

4. Validation

Extbase uses TYPO3\CMS\Extbase\Validation\Validator\*. Laravel Equivalent: Use Laravel’s Validation or Respect/Validation.

// Extbase Validator → Laravel Validator
use Illuminate\Support\Facades\Validator;

$validator = Validator::make($data, [
    'email' => 'required|email',
    'title' => 'required|max:255',
]);

if ($validator->fails()) {
    // Handle errors (Extbase throws \TYPO3\CMS\Extbase\Validation\Exception\InvalidValidationResultException)
}

5. API Integration (TYPO3 ↔ Laravel)

If using Extbase in TYPO3 and Laravel separately:

  • Option 1: Expose Extbase models via TYPO3’s REST API and consume in Laravel.
  • Option 2: Sync data via webhooks or cron jobs.
// Laravel HTTP Client to fetch Extbase data
$response = Http::get('https://typo3-site.com/api/posts');
$posts = $response->json();

Gotchas and Tips

1. Extbase is TYPO3-Centric

  • Pitfall: Assumes TYPO3’s database schema (e.g., tt_content, sys_file_reference).
    • Workaround: Adapt to Laravel’s migrations or use a data mapper pattern.
  • Pitfall: Uses TYPO3’s fluid templating (not Blade).
    • Workaround: Treat Extbase as a data source and render with Laravel’s Blade.

2. Strict Typing and Naming Conventions

  • Extbase enforces camelCase for properties and PascalCase for classes.
    • Tip: Use PHPStan or Psalm to enforce consistency in Laravel.
  • Gotcha: Extbase requires getters/setters for properties (even if Laravel allows direct access).
    • Tip: Use Laravel accessors/mutators or Spatie’s Laravel Data for DTOs.

3. Persistence Layer Quirks

  • Extbase repositories auto-load related models (like Eloquent’s with()).
    • Gotcha: N+1 queries can happen if not careful.
    • Tip: Use Laravel’s eager loading or Extbase’s findBy* methods with initializeObject().

4. Caching and Performance

  • Extbase caches repository queries by default (via TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager).
    • Tip: In Laravel, use Eloquent caching or Redis for similar behavior.
  • Gotcha: Extbase’s caching is TYPO3-specific (e.g., cache_hash in DB).
    • Workaround: Implement a custom cache driver in Laravel.

5. Testing

  • Extbase uses TYPO3’s testing framework (PHPUnit with TYPO3 extensions).
    • Tip: For Laravel, use Pest or PHPUnit with Mockery for repositories/services.
  • Gotcha: Extbase mocking requires knowledge of TYPO3’s DI container.
    • Workaround: Extract business logic into pure PHP classes (no TYPO3 dependencies).

6. Extending Extbase in Laravel

  • Tip: Create a Laravel wrapper for Extbase-like functionality:
    // Example: Extbase-style Service in Laravel
    namespace App\Services;
    
    use App\Repositories\BlogPostRepository;
    
    class BlogService
    {
        protected $repository;
    
        public function __construct(BlogPostRepository
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
craftcms/url-validator
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony