You cannot directly add PHP code to a Webflow site because Webflow is a static site builder and does not support server-side scripting like PHP. Here's how to implement more advanced features instead.
1. Understand Webflow’s Limitations
- Webflow does not support server-side technologies, including PHP, Python, or Node.js.
- Sites exported from Webflow are static HTML, CSS, JavaScript files — no server-side language gets processed.
- The built-in CMS and Logic tools can only handle basic dynamic content and simple logic.
2. Use Webflow's Native Features First
- Webflow CMS: For dynamic content like blogs, portfolios, listings.
- Webflow Logic (Beta): Automate workflows (such as form submissions triggering external calls).
- Webflow Forms + Zapier/Make: Connect form data to third-party apps or Google Sheets.
3. Use External Scripts and APIs
- You can add JavaScript, including AJAX requests, in the Page Settings > Custom Code or an Embed element.
- Use third-party APIs to fetch data or trigger actions, such as authentication or data storage from services like Firebase, Airtable, or Supabase.
- Example: Use JavaScript
fetch
to pull product data from an external API instead of relying on the native CMS.
4. Host Exported Code Externally (If PHP is Required)
If PHP is essential:
- Export your Webflow site (requires a paid plan).
- Host it on a server that supports PHP (e.g., Bluehost, SiteGround, DigitalOcean).
- Insert your PHP code into the exported HTML files manually.
- Limitations:
- You lose Webflow’s CMS and form handling.
- Ongoing design edits must be redone in Webflow and re-exported.
5. Use Reverse Proxy with Webflow + Backend
For a more scalable solution:
- Keep your design in Webflow and publish it to a custom domain (e.g., design.example.com).
- Set up a reverse proxy on a backend server (e.g., on example.com) using Nginx or Apache, which injects server-side PHP features while preserving Webflow’s frontend.
- Requires advanced dev setup, but allows combining both worlds.
Summary
You can't run PHP directly on a Webflow-hosted site. For advanced features, use JavaScript and third-party APIs, or export and host the site elsewhere to embed PHP. For full control, consider using a reverse proxy or switch to a platform that supports both design and backend logic.