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, multilingual website framework/CMS with custom modules for full control over input and output. Simple yet flexible since 2004, highly extendable and adaptable to your workflow, backed by an active community and solid docs.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps to Begin

  1. Install REDAXO

    • Download the latest release from GitHub or use the installer via the admin panel.
    • Run the built-in installer (select demo_base for an English demo).
    • Access the backend at /redaxo/.
  2. First Use Case: Create a Basic Page

    • Navigate to Structure → Pages in the backend.
    • Create a new page (e.g., Home).
    • Assign a template (e.g., default).
    • Add content via the Slice Editor (drag-and-drop elements like text, images, or modules).
  3. Key Directories to Explore

    • /redaxo/src/ – Core classes (e.g., rex_*, rex_sql_table).
    • /redaxo/var/ – Runtime data (caches, uploads).
    • /redaxo/var/packages/ – Addons (extend functionality).
    • /redaxo/var/structure/ – Page structure and content.
  4. First Code Interaction

    • Override a template: Copy /redaxo/var/templates/default/ to your project and modify.
    • Extend a module: Create a new addon in /redaxo/var/packages/ with a package.yml and PHP classes.

Implementation Patterns

Core Workflows

  1. Content Management

    • Pages & Slices: Use rex_article and rex_article_slice to fetch/edit content.
      $article = rex_article::getCurrent();
      $slices = $article->getSlices();
      
    • Multilingual Support: Leverage rex_language for language-specific content.
      rex_language::set('en');
      $content = rex_article::getCurrent()->getSlice('intro')->getValue();
      
  2. Module Development

    • Basic Module Structure:
      /my_module/
      ├── package.yml       # Metadata (name, version, dependencies)
      ├── lib/               # PHP classes (e.g., `my_module.php`)
      ├── templates/         # Frontend templates
      └── backend/           # Admin UI (if needed)
      
    • Register a Module:
      class my_module extends rex_module {
          public function getConfig() {
              return [
                  'name' => 'My Module',
                  'author' => 'You',
              ];
          }
      }
      
    • Hook into Events: Use extension points (EPs) like REGISTER_MODULES or ARTICLE_SAVE.
      rex_extension::register('REGISTER_MODULES', function() {
          rex_module::register('my_module');
      });
      
  3. Database Operations

    • Query Builder: Use rex_sql for queries.
      $articles = rex_sql::factory()->getArray(
          'SELECT * FROM rex_article WHERE id > 0'
      );
      
    • Table Definitions: Extend with rex_sql_table.
      class my_table extends rex_sql_table {
          public function getTableStructure() {
              return [
                  'id' => ['type' => 'int', 'autoinc' => true],
                  'name' => ['type' => 'varchar', 'length' => 255],
              ];
          }
      }
      
  4. Frontend Integration

    • Templates: Use Smarty-like syntax in .tpl files.
      {if $article->getSlice('hero_image')->getValue()}
          <img src="{$article->getSlice('hero_image')->getValue()}" />
      {/if}
      
    • Dynamic Content: Fetch data in PHP and pass to templates.
      $this->setVar('custom_data', ['key' => 'value'], false);
      
  5. Backend Extensions

    • Admin UI: Extend with rex_be_controller or override be_style addon templates.
    • Permissions: Use rex_user and rex_right for role-based access.
      if (!rex_user::getCurrent()->hasPermission('my_module_edit')) {
          rex_response::redirect('index.php');
      }
      
  6. CLI & Automation

    • Console Commands: Create custom commands in /lib/ of your addon.
      class my_command extends rex_cli_command {
          public function execute() {
              echo "Running custom task...\n";
          }
      }
      
    • Cronjobs: Schedule tasks via the cronjob addon.
      class my_cronjob extends rex_cronjob {
          public function execute() {
              // Your logic here
          }
      }
      

Integration Tips

  1. Addon Dependencies

    • Declare dependencies in package.yml:
      dependencies:
          - structure
          - mediapool
      
    • Use rex_addon::get('mediapool') to access addon services.
  2. Asset Management

    • Place CSS/JS in /templates/ or /backend/ of your addon.
    • Register assets in getConfig():
      'assets' => [
          'css' => ['my_module.css'],
          'js' => ['my_module.js'],
      ],
      
  3. Localization

    • Use rex_i18n for translations:
      rex_i18n::set('en', 'my_module');
      echo rex_i18n::msg('hello_world');
      
    • Store translations in /lang/ (e.g., en.yml).
  4. Debugging & Logging

    • Enable debug mode in config.yml:
      debug: true
      
    • Log messages:
      rex_logger::log('My log message', rex_logger::LEVEL_INFO);
      
  5. Security Best Practices

    • Sanitize inputs:
      $clean_input = rex_request::sanitizePostValue('user_input');
      
    • Use rex_escape for output:
      echo rex_escape($unsafe_data);
      
    • Validate file uploads with rex_mediapool::setAllowedMimeTypes().

Gotchas and Tips

Pitfalls

  1. Namespace Conflicts

    • REDAXO uses rex_* for core classes. Avoid naming your classes/modules with rex_ prefix.
    • Fix: Use unique prefixes (e.g., my_module_*).
  2. Caching Quirks

    • Templates and compiled classes are cached aggressively. Clear cache after changes:
      php redaxo/var/cli.php cache:clear
      
    • Tip: Use rex_cache::set() for custom caching:
      rex_cache::set('my_cache_key', $data, ['lifetime' => 3600]);
      
  3. Database Compatibility

    • REDAXO supports both MySQL and MariaDB, but some TEXT column defaults may behave differently.
    • Fix: Normalize defaults with rex_sql_table:
      'description' => ['type' => 'text', 'default' => ''],
      
  4. File Permissions

    • Uploads and caches require writable directories (/var/, /var/uploads/).
    • Fix: Set permissions via:
      chmod -R 755 redaxo/var/
      chmod -R 777 redaxo/var/uploads/
      
  5. Event Point (EP) Timing

    • Some EPs (e.g., ARTICLE_SAVE) fire before data is fully processed.
    • Tip: Use rex_extension::register('ARTICLE_SAVE', 'my_priority') to control order.
  6. Multilingual Content Gaps

    • Missing translations can break frontend output.
    • Fix: Ensure all languages are defined in rex_language and use fallbacks:
      echo rex_i18n::msg('key', 'en', 'default_value');
      
  7. PHP 8.3+ Deprecations

    • REDAXO 5.x requires PHP 8.3+. Watch for deprecated functions (e.g., rex_editor in PHP 8.5).
    • Tip: Check rex_sql::factory() for MySQL/MariaDB driver updates.
  8. Addon Updates

    • Updating addons may break plugins or configurations.
    • Fix: Backup var/packages/ before updates and test in staging.

Debugging Tips

  1. Enable Debug Output

    • Set debug: true in config.yml and check /var/log/ for errors.
  2. Whoops Error Pages

    • Configure in config.yml:
      error_handler:
          whoops: true
      
  3. SQL Debugging

    • Log queries with:
      rex_sql::setDebug(true);
      
  4. Template Debugging

    • Enable Smarty
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport
twbs/bootstrap4