redaxo/core
REDAXO core is a PHP-based CMS and framework for building and managing websites. It provides the admin backend, addon system, content structure, and essential services like routing, media handling, and templating—forming the foundation for REDAXO projects.
Installation in Laravel Project
composer require redaxo/core
php artisan vendor:publish --provider="Redaxo\Core\Providers\RedaxoServiceProvider" --tag="config"
config/redaxo.php with your database and storage paths.First Use Case: Display REDAXO Content in Laravel Blade
// routes/web.php
Route::get('/article/{id}', [ArticleController::class, 'show']);
// app/Http/Controllers/ArticleController.php
public function show($id) {
$article = rex::factory()->createObject('rex_article');
$article->setId($id);
$content = $article->getContent();
return view('articles.show', compact('content'));
}
// resources/views/articles/show.blade.php
<div class="article-content">
{!! $content !!}
</div>
Where to Look First
/index.php?page=start (REDAXO admin panel).rex::factory() (factory pattern for core objects)./pages/ directory for frontend overrides./docs/ (if installed) or REDAXO Wiki.REDAXO’s add-ons (similar to Laravel packages) extend functionality. Structure them like Laravel modules:
addons/
├── my_addon/
│ ├── bootstrap.php # Service provider equivalent
│ ├── functions.php # Core functions (like Laravel helpers)
│ ├── pages/ # Template overrides
│ └── config.yaml # Add-on configuration
Example: Adding a Custom Field to Articles
// addons/my_addon/functions.php
rex_extension::register('REX_PAGES_PAGE_AFTER_SAVE', function($page) {
$customField = rex::getUser()->getVar('custom_field_value');
$page->setVar('custom_field', $customField);
$page->save();
});
REDAXO uses hooks (similar to Laravel events). Bind them in bootstrap.php:
// addons/my_addon/bootstrap.php
rex_extension::register('REX_PAGES_PAGE_AFTER_GET', function($page) {
event(new \App\Events\PageRetrieved($page));
});
Laravel Integration:
// app/Providers/EventServiceProvider.php
protected $listen = [
\App\Events\PageRetrieved::class => [
\App\Listeners\LogPageAccess::class,
],
];
Use REDAXO’s database abstraction alongside Laravel Eloquent:
// Access REDAXO DB via Laravel Query Builder
$articles = DB::table('rex_articles')->where('active', 1)->get();
// Or extend REDAXO models with Eloquent
class RedaxoArticle extends \Illuminate\Database\Eloquent\Model {
protected $table = 'rex_articles';
protected $primaryKey = 'id';
}
Override REDAXO templates to use Blade:
// pages/my_template.yaml
title: "Custom Template"
content:
type: "blade"
name: "main"
// pages/my_template.php
@extends('layouts.app')
@section('content')
{!! $this->content['main'] !!}
@endsection
Leverage REDAXO’s media manager in Laravel:
// Upload a file via REDAXO API
$media = rex_media::upload($_FILES['file'], 'articles');
$url = $media->getUrl();
// Access in Blade
<img src="{{ $media->getUrl() }}" alt="Article Image">
Use REDAXO’s built-in API in Laravel:
// Fetch articles via REDAXO API
$response = Http::get('https://your-redaxo-site.com/api/articles');
$articles = $response->json();
Global rex() Function
rex() calls (e.g., rex::factory()). Avoid in Laravel services.// app/Providers/AppServiceProvider.php
public function register() {
$this->app->singleton('redaxo', function() {
return rex::factory();
});
}
Database Schema Conflicts
rex_* tables may clash with Laravel migrations./database/redaxo_migrations) or prefix tables.Template Caching
config.yaml during development:
cache:
enabled: false
CSRF Token Mismatch
// In Laravel middleware
if (rex::isBackend()) {
return redirect()->route('redaxo.backend');
}
Add-on Autoloading
/addons/ and registered in config.yaml.composer.json autoloading for local add-ons:
"autoload": {
"psr-4": {
"App\\Addons\\": "addons/"
}
}
rex::setDebugMode(true);
storage/logs:
rex::setLogFile(app()->storagePath('logs/redaxo.log'));
DB::enableQueryLog() alongside REDAXO’s rex_db::debug().Custom Backend Pages Extend REDAXO’s backend with Laravel routes:
// routes/web.php
Route::prefix('redaxo')->group(function() {
Route::get('/custom-page', [CustomController::class, 'index']);
});
rex::backend() middleware to enforce auth.Laravel Blade in REDAXO Override REDAXO’s template parser:
// addons/my_addon/bootstrap.php
rex_extension::register('REX_PAGES_TEMPLATE_PARSER', function($parser) {
$parser->addDirective('blade', function($content) {
return Blade::compileString($content);
});
});
Queue Integration Use Laravel queues for REDAXO tasks:
// Dispatch a REDAXO task
dispatch(new ProcessRedaxoTask($data));
// In Laravel queue worker
ProcessRedaxoTask::handle() {
rex::executeTask('my_task', $data);
}
rex::getUser() in Loops
Cache user data:
$user = rex::getUser();
foreach ($articles as $article) {
echo $user->getVar('role'); // Cached
}
rex_extension::register() sparingly in high-traffic areas.{!! htmlspecialchars($redaxoContent, ENT_QUOTES, 'UTF-8') !!}
config.yaml:
security:
csrf_protection: false
How can I help you explore Laravel packages today?