
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
@beyondcode/vercel-php
Advanced tools
Enjoyable & powerful 🐘 PHP Runtime (php.vercel.app) for Vercel platform.
🏋️♀️ It works with these frameworks and tools. Discover more at examples.
Made with ❤️ by @f3l1x (f3l1x.io) • 🐦 @xf3l1x
Let's picture you want to deploy your awesome microproject written in PHP and you don't know where. You have found Vercel it's awesome, but for static sites. Not anymore! I would like to introduce you your new best friend vercel-php, PHP runtime for Vercel platform.
Most simple example project is this one, using following project structure.
project
├── api
│ └── index.php
└── vercel.json
First file api/index.php is entrypoint of our application. It should be placed in api folder, it's very standard location for Vercel.
<?php
phpinfo();
Second file vercel.json is pure gold here. Setup your project with configuration like this and voila. That's all.
{
"functions": {
"api/*.php": {
"runtime": "vercel-php@0.3.1"
}
}
}
Last thing you have to do is call vercel. If you are more interested take a look at features and usage.
# Install it globally
npm i -g vercel
# Log in
vercel login
# Let's fly
vercel
Are you ready to deploy your first PHP project to Vercel? Click & Go!
List of all installable extensions is on this page https://blog.remirepo.net/pages/PECL-extensions-RPM-status.
Before you can start using this runtime, you should learn about Vercel and how runtimes works. Take a look at blogpost about Serverless Functions.
You should define functions property in vercel.json and list PHP files directly or using wildcard (*).
If you need to route everything to index, use routes property.
{
"functions": {
"api/*.php": {
"runtime": "vercel-php@0.3.1"
}
},
"routes": [
{ "src": "/(.*)", "dest": "/api/index.php" }
]
}
Do you have more questions (❓)? Let's move to FAQ.
vercel devFor running vercel dev properly, you need to have PHP installed on your computer, learn more.
But it's PHP and as you know PHP has built-in development server. It works out of box.
php -S localhost:8000 api/index.php
Browse more examples. 👀
Next
Done
vercel devHelp wanted
project
├── api
│ ├── index.php
│ ├── users.php
│ └── books.php
└── vercel.json
{
"functions": {
"api/*.php": {
"runtime": "vercel-php@0.3.1"
},
// Can be list also directly
"api/index.php": {
"runtime": "vercel-php@0.3.1"
},
"api/users.php": {
"runtime": "vercel-php@0.3.1"
},
"api/books.php": {
"runtime": "vercel-php@0.3.1"
}
}
}
{
"functions": {
"api/index.php": {
"runtime": "vercel-php@0.3.1"
}
},
"routes": [
{ "src": "/(.*)", "dest": "/api/index.php" }
]
}
Additional function properties are memory, maxDuration. Learn more about functions.
{
"functions": {
"api/*.php": {
"runtime": "vercel-php@0.3.1",
"memory": 3008,
"maxDuration": 60
}
}
}
Yes, Composer is fully supported.
project
├── api
│ └── index.php
├── composer.json
└── vercel.json
{
"functions": {
"api/*.php": {
"runtime": "vercel-php@0.3.1"
}
}
}
{
"require": {
"php": "^7.4",
"tracy/tracy": "^2.0"
}
}
It's also good thing to create .vercelignore file and put /vendor folder to this file. It will not upload
/vendor folder to Vercel platform.
Yes, you can override php configuration. Take a look at default configuration at first.
Create a new file api/php.ini and place there your configuration. Don't worry, this particulary file will be
removed during building phase on Vercel.
project
├── api
│ ├── index.php
│ └── php.ini
└── vercel.json
{
"functions": {
"api/*.php": {
"runtime": "vercel-php@0.3.1"
}
}
}
# Disable some functions
disable_functions = "exec, system"
# Update memory limit
memory_limit=1024M
Runtimes support excluding some files or folders, take a look at doc.
{
"functions": {
"api/**/*.php": {
"runtime": "vercel-php@0.3.1",
"excludeFiles": "{foo/**,bar/config/*.yaml}",
}
}
If you want to exclude files before uploading them to Vercel, use .vercelignore file.
Calling composer scripts during build phase on Vercel is supported via script named vercel. You can easilly call php, npm or node.
{
"require": { ... },
"require-dev": { ... },
"scripts": {
"vercel": [
"@php -v",
"npm -v"
]
}
}
Files created during composer run vercel script can be used (require/include) in your PHP lambdas, but can't be accessed from browser (like assets). If you still want to access them, create fake assets.php lambda and require them. Example of PHP satis.
If you are looking for config.includeFiles.
) in runtime, unfortunately you can't include extra files.
All files in root folder are uploaded to Vercel, use .vercelignore to exclude them before upload.
Show me CHANGELOG
git clone git@github.com:juicyfx/vercel-php.gitmake installmake buildmake testFAQs
Vercel PHP runtime
We found that @beyondcode/vercel-php demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.