WordPress, with the structure of a framework.Fluent. Testable. Still WordPress.
Mantle is a Laravel-inspired framework for building large, robust websites and applications with WordPress.
composer require alleyinteractive/mantle-framework// Respond to WordPress requests with a route.
Route::get('/post/{post}', function (Post $post) {
return view('post')->with('post', $post);
});
Route::post('/upload/', function (Request $request) {
$id = $request->file('image')->store_as_attachment();
// Generate thumbnails in the background.
Generate_Thumbnails::dispatch($id);
return response()->json([ 'attachment_id' => $id ], 201);
});
Route::rest_api('namespace/v1', '/route-to-use', function () {
return [ ... ];
});
Everything an application needs. WordPress core underneath.
Underneath the hood, Mantle uses WordPress core functions and APIs. On top, you get the fluent toolkit you’d expect from Laravel.
Route::get()RoutingRegister web and REST API routes fluently, without touching add_rewrite_rule().Post::where()Models & ORMEloquent-style models, relationships, a query builder, factories and seeding for posts and terms.@foreachBlade TemplatingRender views with Blade or native PHP, with template helpers to keep them DRY.dispatch()QueuesRun jobs in the background instead of blocking the request.Http::get()HTTP ClientA fluent client for remote requests, built on the WordPress HTTP API.wp mantleConsole CommandsWrite WP-CLI commands as classes with typed arguments and options.Schedule::job()SchedulingDefine recurring tasks fluently, without wiring up WP-Cron by hand.Event::listen()Hooks & EventsAn observer pattern on top of WordPress hooks, with typed listeners.Cache::get()CacheA fluent caching API backed by the WordPress object cache.Storage::put()File SystemFlysystem-powered storage for local uploads or remote disks.register()Service ProvidersBootstrap and organize your application’s functionality in one place.->assertOk()TestingFast, isolated tests with fluent HTTP and database assertions.An independent test framework for WordPress.
A drop-in replacement for the WordPress core test suite that runs faster and gives you IDE-friendly, fluent assertions. PHPUnit out of the box, with Pest support.
class UploadTest extends TestCase {
public function test_upload_file(): void {
$post = static::factory()->post->create_and_get();
$this->get($post)
->assertOk()
->assertSee($post->post_title);
$this->post('/upload', [ 'image' => [ ... ] ])
->assertStatus(201);
}
}
Not on Mantle? Use Testkit.
Bring the Mantle Testing Framework to an existing plugin, theme or wp-content project with no refactoring.
composer require --dev mantle-framework/testkitSimplicity first
Enterprise-level WordPress development is possible and should have a simple, delightful syntax.
Inspired by Laravel
The flexibility of the Laravel framework inside WordPress, with a baked-in WordPress integration.
Readable for people and agents
Every page is available as Markdown, with llms.txt and llms-full.txt for AI tools.