DEV Community

Milan Felix Šulc for NetrixOne

Posted on • Edited on

2 2

Deploy Static Frontend + PHP Files Using ZEIT Now

I am quite a fan of ZEIT company and even more of their tool called Now.

I consider myself mainly as PHP developer, but I also like JavaScript. In these days static site generators are raising and I am totally into it.

So how to take advantage of static frontend but with dynamic backend written in PHP?

Since November 2019 it's simple as possible with ZEIT Now.

👀 https://imgur.com/V7CcInl


Minimal project structure looks like this, you gonna need only 3 files.

project/
├── api/
│   ├── index.php
├── now.json
└── index.html

File index.html contains static frontend.

<html>
<head></head>
<body>

#
# Fetch data from /api/index.php using Fetch API
#

</body>
</html>

File api/index.php contains dynamic data or expose API endpoint.

<?php

header('conten-type: application/json');
echo json_encode(['tech' => 'ZEIT Now']);

File now.json setup deployment.

{
  "functions": {
    "api/index.php": {
      "runtime": "now-php@0.0.7"
    }
  }
}

Finally you can call now command and see what happened.

View this example on Github.

Heroku

Built for developers, by developers.

Whether you're building a simple prototype or a business-critical product, Heroku's fully-managed platform gives you the simplest path to delivering apps quickly — using the tools and languages you already love!

Learn More

Top comments (0)

Image of PulumiUP 2025

Let's talk about the current state of cloud and IaC, platform engineering, and security.

Dive into the stories and experiences of innovators and experts, from Startup Founders to Industry Leaders at PulumiUP 2025.

Register Now

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay