Laravel + Node.js: PHP in Watt Runtime

## Metadata
- Author: [[Stephen Belanger]]
- Full Title: Laravel + Node.js: PHP in Watt Runtime
- Category: #articles
- Document Note: ---
tags: [#laravel, #php, #nodejs, #platformatic]
Author: Fabio Maulo (Platformatic Team)
Source: Platformatic Blog
Reference: “Laravel + Node.js: PHP in Watt Runtime” post, Platformatic Blog
date created: 2025-07-18 17:02
---
# ⚡ Title: Laravel + Node.js: PHP in Watt Runtime
## 📑 Table of Contents:
- [📝 Summary](#-summary)
- [📖 Main Content](#-main-content)
- [🗒️ Notes](#-notes)
- [🗣️ Paraphrase](#-paraphrase)
- [📰 Newsletter](#-newsletter)
- [✅ Action Items](#-action-items)
- [🧪 Hypotheses](#-hypotheses)
- [📊 Methodology](#-methodology)
- [❓ Questions](#-questions)
- [🔮 Future Research](#-future-research)
- [💡 Implications](#-implications)
- [🧠 Learning Styles Assessment](#-learning-styles-assessment)
- [📊 Accessibility Assessment](#-accessibility-assessment)
- [🌍 DEIB Assessment](#-deib-assessment)
- [✅ Logical validity](#-logical-validity)
- [🔍 DARVO Analysis](#-darvo-analysis)
- [🔍 SEO Evaluation](#-seo-evaluation)
- [🎯 Conclusion](#-conclusion)
### References:
- Platformatic Blog: “Laravel + Node.js: PHP in Watt Runtime” :contentReference[oaicite:0]{index=0}
- GitHub repo: platformatic/watt-next-laravel :contentReference[oaicite:1]{index=1}
- Matteo Collina & Luca M LinkedIn posts :contentReference[oaicite:2]{index=2}
## 📝 Summary:
Platformatic introduces a breakthrough: Laravel apps can now run inside Node.js using the Watt runtime with the Platformatic PHP stackable. Built on a Rust-based PHP runtime, this unifies PHP and Node.js ecosystems, reduces infrastructure complexity, and boosts performance via shared resources and streamlined deployment.
## 📖 Main Content:
The integration uses a native Rust module (`@platformatic/php-node`) embedding a multi-threaded PHP runtime inside Node.js. This enables Laravel to function as a stackable within Watt, offering:
- **Unified deployment**: PHP and Node services deploy together.
- **Shared resources**: Cuts infrastructure overhead.
- **Low latency**: Direct service invocation without heavy cross-process calls.
- **Progressive migration**: Legacy PHP apps cohabit with JS microservices.
- **Ecosystem blending**: Give Laravel apps access to wider JS tools.
Platformatic’s GitHub boilerplate (`watt-next-laravel`) showcases a full-stack demo combining Next.js, Laravel backend, and orchestration via Composer—all running under Watt. :contentReference[oaicite:3]{index=3}
### 🗒️ Notes
- ⚙️ **Architecture**
- Watt runtime built in Rust supports multi-threaded PHP. :contentReference[oaicite:4]{index=4}
- Stackable model lets Laravel plug into Watt’s modular service system.
- 🚀 **Developer Benefits**
- One runtime to rule PHP & JS.
- Infrastructure simplification—no siloed stacks.
- Lower deployment friction for full-stack teams.
- 📊 **Performance & Efficiency**
- Shared memory, faster inter-service communication.
- Smaller deployment footprint = cost savings.
- 🛠 **Use Cases**
- Smooth migration to JS-focused infrastructures.
- Modernize legacy Laravel by mixing in JS features.
- Ideal for teams handling both PHP and Node workloads.
- 📚 **Community Engagement**
- Matteo Collina: calls it a paradigm shift for full-stack development. :contentReference[oaicite:5]{index=5}
- Luca M.: highlights reduced chaos, unified workflows, and modern frontend synergy. :contentReference[oaicite:6]{index=6}
## 🗣️ Paraphrase:
> “Our new stackable embeds a multi-threaded PHP runtime in Node.js, giving Laravel direct access to Watt’s environment.”
> → Platformatic’s PHP module runs Laravel applications natively in Node, enabling tight integration with Watt.
> “Unified deployment, shared resources, gradual migration… this is a gamechanger.”
> → Consolidating deployment and infra, you can incrementally shift PHP apps into modern JS ecosystems more seamlessly.
## 📰 Newsletter:
**🔁 Full-Stack Fusion Alert!**
This week we’re spotlighting a major leap: run **Laravel inside Node.js** with Platformatic’s Watt runtime and PHP stackable. One runtime, fewer infrastructure headaches—and your Laravel apps get native JS perks + low-latency performance. Whether you're refactoring legacy code or embracing polyglot development, this is a must-see. Preview the demo over on GitHub and let your team rethink full-stack workflows. 🚀
👉 [Read the full guide on Platformatic Blog](https://blog.platformatic.dev/laravel-nodejs-php-in-watt-runtime)
## ✅ Action Items:
- **For Advocacy & Teaching**
- Demo the Watt runtime in JavaScript and PHP workshops.
- Use the demo repo to show students real-world polyglot workflows.
- **For OSPO Aspirations**
- Explore legal/licensing aspects: Apache‑2.0 for interop code.
- Align mixed-stack governance processes with open‑source compliance.
- **For Community Engagement**
- Host a meetup or webinar on hybrid runtime strategies.
- Produce blog posts comparing GPL/PHPWP licensing in cross‑runtime contexts.
## 🧪 Hypotheses:
- Unified runtimes increase team agility and deployment speed.
- Polyglot apps reduce infrastructure cost compared to siloed stacks.
- Developer satisfaction improves with consolidated workflows.
### 📊 Methodology:
- Build mirrored projects: one mono-stack, one Watt integrated.
- Track deployment time, infra cost, and dev feedback re: workflow.
- Survey teams during transition phases to measure friction points.
### ❓ Questions:
- How does debugging differ in a mixed-runtime Watt environment?
- Will security vulnerabilities cross runtime boundaries?
- What performance trade-offs emerge at scale?
### 🔮 Future Research:
- Compare dev productivity before/after Watt adoption.
- Study runtime coupling impact on CI/CD complexity.
- Explore licensing considerations when merging ecosystems.
### 💡 Implications:
- Could lead to standardization of polyglot architecture in OSS.
- Inform platform governance models in OSPO roles.
- Encourage more hybrid runtime options in open-source products.
## 🧠 Learning Styles Assessment:
- **Readability**: ~11th-grade—clear technical language.
- **Visual**: ❌ No diagrams; include architecture flowcharts.
- **Aural**: ❌ Missing; add narrated walkthrough or podcast.
- **Verbal**: ✅ Good analogies and comparisons; could add more code examples.
- **Physical**: ✅ Demo repo provides hands-on practice.
- **Logical**: ✅ Structured reasoning with clear cause-effect.
- **Social**: ✅ Community posts spark discussion.
- **Solitary**: ✅ Self-guided demo supports solo learning.
- **Naturalistic**: ❌ No metaphors—could compare runtime blend to ecosystems merging.
## 📊 Accessibility Assessment:
- **Screen Reader**: Standard HTML likely, but add alt text for code diagrams.
- **Keyboard Nav**: Platformatic site seems accessible—verify proper heading use.
- **Contrast/Readability**: Good, but code blocks need monospaced clarity.
- **Improvements**: Provide downloadable PDF, audio summary, and diagram alt-text.
## 🌍 DEIB Assessment:
- **Cultural Relevance**: Global dev audience; include diverse case studies.
- **Inclusive Language**: ✅ Clear, neutral.
- **Neurodiversity**: ✅ Short sections; code could include inline comments.
- **Representation**: ❌ No testimonials from varied team sizes; include small/large org examples.
- **Psych Safety**: ✅ Encourages experimentation without penalty.
## ✅ Logical validity:
- **Sound Deductive Reasoning**: Clear premise → benefit alignment (unified runtime → simpler infra).
- **Causal Reasoning**: Improved performance + lower latency logically follows embedding.
- **Strong Inductive Reasoning**: Backed by demo repo and community feedback.
- **Logical Flow**: Easy progression: intro → implementation → benefits → use cases.
- ❌ **Potential Weakness**: Lacks long-term benchmarks; early days claims need future data.
## 🔍 DARVO Analysis:
- No Deny, Attack, or Reverse‑Victim rhetoric.
- Tone is enthusiastic, inclusive, and solution‑focused.
- No emotional manipulation; argument rests on technical value and community feedback.
## 🔍 SEO Evaluation:
- **Keywords**: Good boolean of “Laravel”, “Node.js”, “Watt runtime”, “PHP stackable”.
- **Headline**: Effective but could be shorter (“Laravel in Node.js Watt Runtime”).
- **
- Summary: Run Laravel apps on Node.js Watt runtime with Platformatic PHP for improved performance and simplified infrastructure
- URL: https://blog.platformatic.dev/laravel-nodejs-php-in-watt-runtime

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.
#### Why This Matters
The traditional separation between PHP and Node.js environments has long required developers to maintain separate infrastructures. With [`@platformatic/php`](https://github.com/platformatic/php), you can now:
* Run Laravel applications within a Node.js process
* Share resources and reduce infrastructure complexity
* Leverage the Node.js ecosystem while maintaining your Laravel codebase
* Deploy PHP applications alongside JavaScript microservices in a unified runtime
#### How It Works
The Platformatic PHP stackable uses [`@platformatic/php-node`](https://github.com/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](https://platformatic.dev/docs/getting-started/quick-start-watt), where it has direct access to other services without needing to go to the network, substantially reducing latency.
#### Getting Started: Run Laravel in Node.js
Let's walk through setting up a Laravel application in Watt runtime. The process is quite straightforward.
* Node.js 20.6.0+
* npm or your preferred package manager
* A Laravel application (or create a fresh one)
##### Step 1: Set Up Your Project Structure
Create a new directory for your project and initialize it:
##### Step 2: Configure the Package Structure
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"
}
}
```
##### Step 3: Add Your Laravel Application
Create the workspace directory and add your Laravel application:
##### Step 4: Configure the PHP Stackable
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"
}
}
```
##### Step 5: Create the Platformatic Configuration
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:
* Sets the document root to Laravel's `public` directory
* Configures URL rewriting to route all requests through `index.php` (essential for Laravel's routing)
* Enables file watching for development
##### Step 6: Install Dependencies and Run
From your project root:
Your Laravel application is now running within the Node.js Watt runtime.
#### Configuration Deep Dive
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 development
#### What's Next?
This integration opens up several possibilities:
* **Unified Deployment**: Deploy PHP and Node.js services together
* **Shared Resources**: Optimize resource usage by running everything in a single runtime
* **Gradual Migration**: Incrementally migrate PHP applications to JavaScript while maintaining existing functionality
* **Polyglot Microservices**: Mix PHP, JavaScript, and other languages in your architecture
#### Advanced Features
The PHP stackable supports additional configuration options for more complex scenarios:
* Custom PHP extensions
* Environment variable management
* Performance tuning options
* Integration with other Platformatic services
#### Conclusion
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](https://github.com/platformatic/watt-next-laravel) and join our community to share your experiences!
*The Platformatic PHP stackable is actively maintained and we welcome contributions. Visit our [documentation](https://docs.platformatic.dev) for more details and advanced configuration options.*, Laravel + Node.js: PHP in Watt Runtime, Stephen Belanger, 01k0d5wp91dn4g0t9tg49pahsh.