Since this is a Symfony 2 bundle, direct Laravel integration isn’t natively supported. However, you can adapt its core logic (page management, SEO, and content handling) into Laravel using these steps:
Extract Core Functionality
AxstradPageBundle/Resources/config/doctrine/ (Doctrine ORM entities like Page).AxstradPageBundle/Controller/ (e.g., PageController for routing).AxstradPageBundle/DependencyInjection/ (services/configuration).Page entity (likely extends axstrad/content for content management).axstrad/seo-bundle).Laravel Equivalent Setup
composer require doctrine/dbal doctrine/orm illuminate/database
composer require axstrad/content axstrad/seo-bundle # If available via Packagist or forked
Page entity schema (from AxstradPageBundle/Resources/config/doctrine/Page.orm.xml) into a Laravel migration:
Schema::create('pages', function (Blueprint $table) {
$table->id();
$table->string('slug')->unique();
$table->text('title');
$table->text('content')->nullable();
$table->string('template')->default('default');
$table->timestamps();
});
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Axstrad\Content\Traits\Contentable; // Hypothetical trait (adapt from axstrad/content)
class Page extends Model
{
use Contentable; // If using axstrad/content
protected $fillable = ['slug', 'title', 'content', 'template'];
}
First Use Case: Dynamic Page Rendering
Route::get('/{slug}', [PageController::class, 'show']);
namespace App\Http\Controllers;
use App\Models\Page;
class PageController extends Controller
{
public function show($slug)
{
$page = Page::where('slug', $slug)->firstOrFail();
return view('pages.' . $page->template, ['page' => $page]);
}
}
resources/views/pages/default.blade.php):
<h1>{{ $page->title }}</h1>
<div>{!! $page->content !!}</div>
SEO Integration
axstrad/seo-bundle (or Laravel’s spatie/laravel-seo) to attach metadata:
// In PageController::show()
$page->seo()->setTitle($page->title);
$page->seo()->setDescription(substr($page->content, 0, 160));
Page CRUD logic from AxstradPageBundle/Controller/PageController.namespace App\Admin;
use Backpack\CRUD\app\Http\Controllers\OperationCrudController;
use App\Models\Page;
class PageCrudController extends OperationCrudController
{
public function setup()
{
CRUD::setModel(\App\Models\Page::class);
CRUD::setRoute(config('backpack.base.route_prefix') . '/page');
CRUD::setEntityNameStrings('page', 'pages');
}
}
axstrad/content for WYSIWYG or markdown support. In Laravel, use laravel-wysiwyg or tymon/jwt-auth for rich content.Route::get('/{page:slug}', [PageController::class, 'show']);
Route::fallback(function () {
return redirect('/404');
});
slug_redirects table to handle URL changes:
Schema::create('slug_redirects', function (Blueprint $table) {
$table->string('old_slug');
$table->string('new_slug');
$table->unique(['old_slug', 'new_slug']);
});
resources/views/pages/{template}.blade.php.default.blade.php.@include or @component for reusable sections (headers, footers).spatie/laravel-seo or manually inject tags:
// In PageController::show()
$seo = [
'title' => $page->title,
'description' => $page->meta_description ?? '',
'keywords' => $page->keywords ?? '',
];
return view('pages.' . $page->template, ['page' => $page, 'seo' => $seo]);
<!-- In your layout blade file -->
@if(isset($seo))
<meta property="og:title" content="{{ $seo['title'] }}">
<meta property="og:description" content="{{ $seo['description'] }}">
@endif
$page = Cache::remember("page:{$slug}", now()->addHours(1), function () use ($slug) {
return Page::where('slug', $slug)->first();
});
Cache::tags(['pages'])->put("page:{$slug}", $page);
laravel-doctrine/orm.doctrine/dbal and illuminate/database for hybrid setups.axstrad/seo-bundle and axstrad/content may not be Laravel-compatible. Fork and adapt or use alternatives like:
spatie/laravel-seolaravel-wysiwyg or spatie/laravel-medialibrary.use Illuminate\Support\Str;
class GenerateSlug
{
public function saving($page)
{
if (empty($page->slug)) {
$page->slug = Str::slug($page->title);
}
}
}
Page model:
protected static function boot()
{
parent::boot();
static::saving('GenerateSlug');
}
$page->slug = Str::lower($page->slug);
Page has relationships (e.g., author), eager load them:
$page = Page::with('author')->where('slug', $slug)->first();
slug and template columns in migrations:
$table->string('slug')->unique();
$table->string('template')->default('default');
Then run:
php artisan optimize:clear
axstrad/content or axstrad/seo-bundle are missing, check:
php artisan route:list to check for conflicts.
How can I help you explore Laravel packages today?