Deploy PHP Application to Vercel
There are several platforms that can be used to host websites created with the PHP programming
language, one of them is Vercel. Vercel is a cloud platform for frontend frameworks and static sites. To
be able to host PHP application, we will use the PHP Runtime for Vercel Serverless Function that was
created by vercel-community.
Prerequisite
Before we get started, there are a few things that need to be prepared.
GitHub
GitHub is used to connect Vercel with your GitHub repository. So whenever you change your
code, Vercel will automatically deploy your application with the changes you make. You can sign
up and create your account here.
Vercel
Vercel is used to deploy the application and integrated it with your GitHub repository. We also
need some configuration on Vercel to make the application run perfectly. You can sign up and
create your account here.
PHP
PHP is used in development, especially in local development. You can modify the application and
run it locally using PHP. After that, push your changes to GitHub and Vercel will do the rest. You
can download PHP here.
Composer
Composer is used to manage dependency for PHP application. With Composer you can easily
manage your external libraries used in PHP application. You can download Composer here.
Create Application
To simplify the process, we will use this website. You can create a new GitHub repository using this
template.
Create a new repository from template.
Give the repository name and description, then . Create repository
The PHP application is ready. Next we will configure Vercel for deployment.
Configure Vercel
First, you need to have a Vercel account, then connect your GitHub repository to Vercel.
Select then choose . Add new Project
Connect with your previous created repository, then click . Import
Give project name and click . Deploy
Wait a moment and then your app has been deployed, after that choose . Continue to Dashboard
Select in your project dashboard. Settings
Under your project's , choose and then add your Font Awesome kit URL. Settings Environment
Variables
A new deployment is required for your changes to take effect, go to to redeploy it. Deployments
Under your project's , click the ellipsis (tree dots) and then choose . Deployments Redeploy
Confirm redeploy by clicking . REDEPLOY
Wait a moment and then your app has been redeployed, after that click to view your
application. Visit
Congratulations, you have successfully deploy your PHP application to Vercel.
Local Development
If you want to start to develop your application locally, you can clone the repository you created
before. Remember to change with your GitHub username and with your repository name. your-
name repo-name
git clone https://github.com/your-name/repo-name.git
Install the dependencies.
composer install
Create a file to store your Font Awesome kit URL. .env
cp .env.example .env
Run the app locally.
php -S localhost:8000
Open in your browser.
localhost:8000/api/index.php
Summary
That's all about how to deploy PHP application to Vercel. If you encounter a problem or want to make
a contribution just raise an issue or pull request. Highly recommended if you also read the
documentation from Vercel and from Vercel-Community.
Created with Bootstrap