Integrate WordPress & Laravel
Bring Laravel’s developer experience to WordPress
Use Blade, migrations, routing, and more without leaving WordPress
~/Code/
Blade templates in WordPress
Use Laravel’s powerful Blade templating engine throughout WordPress. Create cleaner, more maintainable templates with layouts, components, and directives. Render WordPress blocks, emails, and more with the template engine loved by PHP developers worldwide.
Rendering WordPress blocks with Blade
views/blocks/button.blade.php
Example Blade template
views/layouts/app.blade.php
Eloquent models for WordPress data
Use Laravel’s powerful Eloquent ORM to interact with WordPress data. Create models for posts, users, and custom tables with relationships, scopes, and clean query syntax.
WordPress Post model
app/Models/Post.php
Using the model in a controller
app/Http/Controllers/PostController.php
Laravel migrations for your WordPress projects
Use Laravel’s migration system to manage your WordPress database schema. Create, modify, and version your database structure with elegant PHP syntax.
Create & run migrations via WP-CLI
/srv/www/example.com
$ wp acorn make:migration
┌ What should the migration be named? ─────┐
│ create_example_table │
└──────────────────────────────────────────┘
INFO Migration [create_example_table.php] created successfully.
$ wp acorn migrate
INFO Running migrations.
create_example_table ...................... DONE
Migration file example
database/migrations/create_example_table.php
Laravel routing in WordPress
Create virtual pages and custom endpoints without wrestling with WordPress rewrite rules. Define routes with clean syntax, middleware support, and named routes.
Registering routes
routes/web.php
Error handling & logging
Capture and diagnose errors more effectively with Laravel’s exception handling and logging. Track issues in development and production with structured logs.
Advanced logging
example.php
Background jobs & queues
Process heavy tasks asynchronously with Laravel’s queue system. Perfect for image processing, email sending, data imports, or any task that shouldn’t block WordPress requests.
Queue setup & processing
/srv/www/example.com
$ wp acorn make:queue-table
INFO Migration [create_jobs_table.php] created successfully.
$ wp acorn migrate
INFO Running migrations.
create_jobs_table .......................... DONE
$ wp acorn queue:work
INFO Processing jobs...
Background job example
app/Jobs/ProcessImageUpload.php
Custom WP-CLI commands
Extend WordPress with custom Artisan commands accessible via WP-CLI. Build powerful maintenance tools, data migration scripts, and automated tasks that integrate seamlessly with your WordPress workflow.
Creating custom commands
/srv/www/example.com
$ wp acorn make:command CleanupDraftsCommand
INFO Console command [app/Console/Commands/CleanupDraftsCommand.php] created successfully.
$ wp acorn wp:cleanup-drafts --days=7
INFO Cleaning up drafts older than 7 days...
INFO Deleted 23 old draft posts.
Command implementation
app/Console/Commands/CleanupDraftsCommand.php
Controllers for clean APIs
Build robust REST APIs and handle requests with Laravel controllers. Clean separation of concerns, validation, and response formatting for WordPress integrations.
Middleware for request filtering
Filter and transform requests before they reach your application. Handle authentication, rate limiting, CORS, and custom business logic with reusable middleware.
API controller
app/Http/Controllers/PostController.php
Authentication middleware
app/Http/Middleware/AuthenticateAdmin.php
Supported Laravel components
Sponsors
Help support our open-source development efforts
Subscribe for updates
Join over 8,000 subscribers on our newsletter to get the latest Roots updates and tips on building better WordPress sites
Looking for WordPress plugin recommendations, the newest modern WordPress projects, and general web development tips and articles?