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

Source Laravel Package

redaxo/source

REDAXO is an easy-to-learn, flexible CMS/website framework. Build websites with custom modules and full control over input/output. Multilingual, highly extendable, and adaptable to your workflow, backed by an active community since 2004.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup for Laravel Developers

To integrate REDAXO Core into a Laravel-like workflow (or leverage its patterns in a Laravel project), start by:

  1. Install via Composer (if using REDAXO directly):

    composer require redaxo/source
    

    For Laravel integration, treat REDAXO as a modular dependency and use its core utilities (e.g., rex_*) via service providers.

  2. First Use Case: Database Abstraction REDAXO’s rex_sql and rex_sql_table classes provide a lightweight ORM-like layer. Example:

    use rex_sql::getInstance();
    $db = rex_sql::factory();
    $result = $db->getArray("SELECT * FROM pages WHERE id = ?", [1]);
    

    Laravel Tip: Wrap this in a Laravel service class to maintain consistency with Eloquent.

  3. Key Entry Points

    • rex namespace: Core utilities (e.g., rex_string, rex_file, rex_dir).
    • Event System: REDAXO uses "Extension Points" (EPs) for hooks. Example:
      rex_extension::register('EVENT_NAME', function($params) {
          // Modify $params or trigger logic
      });
      
    • Configuration: Load via rex_config or YAML files (e.g., config.yml with !env support).
  4. Demo Projects Clone the demo_base repo to explore REDAXO’s structure and workflows.


Implementation Patterns

1. Modular Architecture

REDAXO treats everything as a "module" (even core features). Laravel developers can mirror this:

  • Structure: Organize code into addons/ (like Laravel packages) with:
    /addons/
      └── my_addon/
          ├── boot.php       # Laravel-style service provider
          ├── functions.php  # Core logic (rex_* helpers)
          └── templates/     # Twig/Blade-like templates
    
  • Bootstrapping: Use rex_extension::register('BOOT', 'my_addon/boot.php') to initialize.

2. Event-Driven Workflows

Leverage REDAXO’s Extension Points (EPs) for Laravel events:

REDAXO EP Laravel Equivalent Example Use Case
PAGE_BEFORE_RENDER View::composing Modify page output before rendering.
MEDIA_LIST_QUERY Model::booting Filter media queries.
SLICE_BE_PREVIEW View::composed Preview slice revisions.

Example: Laravel-Style Event Listener

// In boot.php
rex_extension::register('PAGE_BEFORE_RENDER', function($params) {
    $params['content'] = app()->make(MyModifier::class)->modify($params['content']);
});

3. Database Patterns

  • Migrations: Use rex_sql_table for schema definitions:

    $table = new rex_sql_table('my_table', [
        'id' => ['type' => 'int', 'autoinc' => true],
        'title' => ['type' => 'varchar', 'length' => 255],
    ]);
    $table->create();
    

    Laravel Tip: Generate Laravel migrations from REDAXO tables using rex_sql::getTableStructure().

  • Query Builder: Chain methods like Eloquent:

    $db = rex_sql::factory();
    $pages = $db->getArray("SELECT * FROM pages WHERE status = ?", [1])
                ->map(fn($row) => new PageModel($row));
    

4. File and Media Handling

REDAXO’s rex_file and rex_media classes handle uploads, MIME types, and storage:

// Upload a file (Laravel-style)
$file = rex_file::upload($_FILES['file'], 'uploads/');
if ($file) {
    $media = rex_media::add($file->getPath());
    // Store $media->getId() in DB
}

Laravel Tip: Use rex_media for file storage and Storage::disk() for Laravel’s filesystem.

5. Configuration Management

REDAXO uses YAML for config (with !env support):

# config.yml
database:
  host: !env DB_HOST
  password: !env DB_PASSWORD

Load via:

$config = rex_config::get('database.host');

6. Localization and Multilingual Support

REDAXO’s rex_language handles translations:

// Define translations
rex_language::set('my_addon', 'en', ['greeting' => 'Hello']);

// Use translations
echo rex_language::get('my_addon', 'greeting');

Laravel Tip: Integrate with Laravel’s trans() helper by extending rex_language.


Gotchas and Tips

1. PHP 8.3+ Requirements

  • REDAXO requires PHP 8.3+. Test locally with:
    docker run --rm -it -v $(pwd):/app php:8.3-cli composer install
    
  • Laravel Tip: Use php:8.3 in your Docker setup if migrating.

2. Autoloader Quirks

  • REDAXO’s autoloader prioritizes vendor classes. If you get ClassNotFound errors:
    • Ensure your classes are in addons/ or lib/ with proper boot.php registration.
    • Use rex_extension::register('BOOT', 'path/to/autoloader.php') for custom PSR-4 loading.

3. Session and Cache Handling

  • Session Timeout Overlay: REDAXO shows a modal when sessions expire. Disable via:
    rex_config::set('BE_SESSION_TIMEOUT', 0);
    
  • Cache Invalidation: Use rex_cache::delete() or rex_finder::ignoreUnreadableDirs(true) to avoid race conditions during cache clears.

4. Security Pitfalls

  • XSS in Media Pool: Always escape media filenames:
    echo htmlspecialchars(rex_media::get($id)->getFileName(), ENT_QUOTES);
    
  • SQL Injection: Use rex_sql::factory()->query() with bound parameters (never concatenate queries).
  • File Uploads: Validate MIME types with rex_file::getMimeType():
    $allowedTypes = ['image/jpeg', 'image/png'];
    if (!in_array(rex_file::getMimeType($file), $allowedTypes)) {
        throw new Exception("Invalid file type");
    }
    

5. Debugging Tips

  • Psalm Cache Issues: If you see false positives, run:
    composer psalm:no-cache
    
  • Extension Point Debugging: Dump EPs with:
    print_r(rex_extension::getRegistered('*'));
    
  • Database Logs: Enable SQL logging:
    rex_sql::setDebug(true);
    

6. Performance Optimizations

  • Batch Processing: Use rex_sql::getArray() with LIMIT for large datasets.
  • Media Pool Queries: Add PAGER to rex_media_service::getList() to avoid loading all media at once:
    $media = rex_media_service::getList(null, null, null, ['PAGER' => ['page' => 1, 'perPage' => 20]]);
    

7. Laravel-Specific Integrations

  • Service Providers: Register REDAXO helpers in Laravel’s AppServiceProvider:
    public function boot() {
        $this->app->singleton('redaxo.db', function() {
            return rex_sql::factory();
        });
    }
    
  • Blade vs. REDAXO Templates: Use rex_template for backend templates and Blade for frontend:
    // In a Laravel controller
    $content = rex_template::get('my_template')->parse();
    return view('frontend.layout', ['content' => $content]);
    
  • Authentication: Bridge REDAXO’s rex_user with Laravel’s Auth:
    Auth::loginUsingId(rex_user::getCurrent()->getId());
    

8. Common Errors and Fixes

Error Cause Solution
Class 'rex_*' not found Autoloader not registered Add rex_extension::register('BOOT', ...)
Deprecated: imagedestroy() PHP 8.5+ deprecation Update to media_manager 2.18.1+
Session expired overlay BE_SESSION_TIMEOUT misconfig
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.
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
ecotone/kafka
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata