Laravel + Node.js: PHP in Watt Runtime

Search for a command to run...

No comments yet. Be the first to comment.
Nitro is a server toolkit used by many JavaScript applications. You can use it on its own for APIs or full-stack servers, or combine it with Vite to get a familiar frontend workflow with a Nitro serve

All durable execution engines give the same versioning advice: pin your runs. Temporal pins runs to worker builds. Vercel's Workflow SDK pins each run to the deployment that started it. Azure Durable

Eve organizes AI agents in a simple way: use Markdown for instructions and skills, TypeScript for tools, and separate files for channels, schedules, and subagents. Behind this setup, Eve relies on the

Picture an online store launching a new product and sending out a mailing list campaign. Thousands of users click the same link at once. The product page, built with a Node.js app like Next.js, needs

How Platformatic ICC Outperforms AWS ECS Target Tracking and Step Scaling

We're pleased to announce that Laravel applications can now run within Node.js using the Platformatic PHP stackable. This integration brings Laravel's PHP framework into the Node.js ecosystem through Watt runtime, opening up new possibilities for full-stack JavaScript developers and PHP developers.
The traditional separation between PHP and Node.js environments has long required developers to maintain separate infrastructures. With @platformatic/php, you can now:
The Platformatic PHP stackable uses @platformatic/php-node, a Rust-based native module that embeds a multi-threaded PHP runtime directly inside Node.js. This provides a high-performance bridge between the PHP and JavaScript worlds. Your Laravel application runs as a stackable module within Watt, where it has direct access to other services without needing to go to the network, substantially reducing latency.
Let's walk through setting up a Laravel application in Watt runtime. The process is quite straightforward.
Create a new directory for your project and initialize it:
mkdir my-laravel-watt-app
cd my-laravel-watt-app
npm init -y
Update your package.json to include workspaces and necessary dependencies:
{
"name": "my-laravel-watt-app",
"workspaces": [
"web/*"
],
"scripts": {
"start": "wattpm start",
"dev": "wattpm dev",
"build": "wattpm build"
},
"dependencies": {
"@platformatic/runtime": "^2.64.0",
"platformatic": "^2.64.0",
"wattpm": "^2.64.0"
},
"engines": {
"node": ">=20.6.0"
}
}
Create the workspace directory and add your Laravel application:
mkdir -p web/laravel
# Copy your Laravel application into web/laravel/
# Or create a fresh Laravel app:
cd web/laravel
composer create-project laravel/laravel .
Create a package.json in your Laravel directory (web/laravel/package.json):
{
"private": true,
"type": "module",
"scripts": {
"start": "platformatic start"
},
"dependencies": {
"@platformatic/php": "^0.5.2"
}
}
The key configuration is in web/laravel/platformatic.json. This file tells Platformatic how to run your Laravel application:
{
"$schema": "https://schemas.platformatic.dev/@platformatic/php/0.3.1.json",
"module": "@platformatic/php",
"php": {
"docroot": "public",
"rewriter": [
{
"conditions": [
{ "type": "not_exists" }
],
"rewriters": [
{
"type": "href",
"args": ["/(.*)", "/index.php?/$1"]
}
]
}
]
},
"watch": true
}
This configuration:
public directory index.php (essential for Laravel's routing) From your project root:
npm install
cd web/laravel
npm install
cd ../..
npm run dev
Your Laravel application is now running within the Node.js Watt runtime.
The platformatic.json file is where the PHP stackable is configured. Let's break down the key components:
module: Specifies @platformatic/php as the stackable module docroot: Points to Laravel's public directory where index.php resides rewriter: Implements Laravel's front controller pattern, ensuring all requests are routed through index.php watch: Enables hot reloading during developmentThis integration opens up several possibilities:
The PHP stackable supports additional configuration options for more complex scenarios:
The ability to run Laravel within Node.js through the Platformatic PHP stackable represents a significant step forward in runtime interoperability. Whether you're a PHP developer looking to leverage Node.js tooling or a JavaScript developer needing to integrate PHP applications, this solution provides a seamless bridge between both worlds.
We look forward to seeing what you'll build with this capability. The combination of Laravel and the Node.js ecosystem creates new opportunities for modern web development.
Ready to give it a try? Check out the complete example on GitHub and join our community to share your experiences!
The Platformatic PHP stackable is actively maintained and we welcome contributions. Visit our documentation for more details and advanced configuration options.