@ -1,16 +1,14 @@
< h1 align = center > ZEIT Now PHP < / h1 >
< h1 align = center > PHP Runtime for < a href = "https://vercel.com" > Vercel < / h1 >
< p align = center >
Enjoyable & powerful 🐘 PHP Runtime (< a href = "https://php.now.sh" > php.now.sh< / a > ) for ZEIT Now.
Enjoyable & powerful 🐘 PHP Runtime (< a href = "https://php.vercel.app" > php.vercel.app< / a > ) for Vercel platform.
< a href = "https://vercel.com/new/project?template=https://github.com/juicyfx/vercel-examples/tree/master/php" > < img src = "https://vercel.com/button" > < / a >
< / p >
< p align = center >
🕹 < a href = "https://f3l1x.io" > f3l1x.io< / a > | 💻 < a href = "https://github.com/f3l1x" > f3l1x< / a > | 🐦 < a href = "https://twitter.com/xf3l1x" > @xf3l1x< / a >
< / p >
< p align = center >
< a href = "https://www.npmjs.com/package/now-php" > < img alt = "npm" src = "https://img.shields.io/npm/dt/now-php?style=flat-square" > < / a >
< a href = "https://www.npmjs.com/package/now-php" > < img alt = "npm (latest)" src = "https://img.shields.io/npm/v/now-php/latest?style=flat-square" > < / a >
< a href = "https://www.npmjs.com/package/vercel-php" > < img src = "https://badgen.net/npm/v/vercel-php" > < / a >
< a href = "https://www.npmjs.com/package/vercel-php" > < img src = "https://badgen.net/npm/dt/vercel-php" > < / a >
< a href = "https://www.npmjs.com/package/vercel-php" > < img src = "https://badgen.net/github/status/juicyfx/vercel-php/master" > < / a >
< / p >
< p align = center >
@ -21,24 +19,63 @@ Enjoyable & powerful 🐘 PHP Runtime (<a href="https://php.now.sh">php.now.sh</
< a href = "https://github.com/phalcon" > < img src = "https://github.com/phalcon.png" width = "128" > < / a >
< / p >
< p align = center > < strong > 🏋️♀️ It works with these frameworks and tools. Discover more at < a href = "https://github.com/juicyfx/now-examples" > examples< / strong > .< / p >
< p align = center > < strong > 🏋️♀️ It works with these frameworks and tools. Discover more at < a href = "https://github.com/juicyfx/vercel-examples" > examples< / strong > .< / p >
-----
< p align = center >
Made with ❤️ by < a href = "https://github.com/f3l1x" > @f3l1x< / a > 🕹 < a href = "https://f3l1x.io" > f3l1x.io< / a > 🐦 < a href = "https://twitter.com/xf3l1x" > @xf3l1x< / a >
< / p >
-----
## 🐣 Versions
Let's picture you want to deploy your awesome microproject written in PHP and you don't know where. You have found [Vercel ](https://vercel.com ) 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.
```sh
project
├── api
│ └── index.php
└── now.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
< ?php
phpinfo();
```
Second file `now.json` is pure gold here. Setup your project with configuration like this and voila. That's all.
```json
{
"functions": {
"api/*.php": {
"runtime": "vercel-php@0.1.0"
}
}
}
```
Last thing you have to do is call `now` . If you are more interested take a look at features and usage.
| | Pkg | Tag | Stability | Info |
|----|---------|--------------|-------------|--------------------------|
| ✅ | now-php | latest | production | Rock-solid stable. |
| 🔥 | now-php | canary | testing | For early-adopters. |
| ⚠️ | now-php | experimental | development | Testing and high danger. |
```
# Install it globally
npm i -g now
> Need to know how things are changing? Here is [changelog ](./CHANGELOG.md ).
# Log in
now login
# Let's fly
now
```
## 🤗 Features
- **Architecture** : PHP development server (🚀 fast enough)
- **PHP version** : 7.4.4
- **PHP version** : 7.4.7
- **Extensions** : apcu, bcmath, brotli, bz2, calendar, Core, ctype, curl, date, dom, ds, exif, fileinfo, filter, ftp, gettext, hash, iconv, igbinary, imap, intl, json, libxml, lua, mbstring, msgpack, mysqli, mysqlnd, openssl, pcntl, pcre, PDO, pdo_mysql, pdo_pgsql, pdo_sqlite, pgsql, phalcon, Phar, protobuf, psr, readline, redis, Reflection, runkit7, session, SimpleXML, soap, sockets, sodium, SPL, sqlite3, standard, swoole, timecop, tokenizer, uuid, xml, xmlreader, xmlrpc, xmlwriter, xsl, Zend OPcache, zlib
- **Speed** : cold ~250ms / warm ~5ms
- **Memory** : ~90mb
@ -48,7 +85,7 @@ Enjoyable & powerful 🐘 PHP Runtime (<a href="https://php.now.sh">php.now.sh</
## ⚙️ Usage
Take a look at [ZEIT's](https://zeit.co ) blogpost about [`Serverless Functions` ](https://zeit.co /blog/customizing-serverless-functions).
Take a look at [Vercel's](https://vercel.com ) blogpost about [`Serverless Functions` ](https://vercel.com /blog/customizing-serverless-functions).
You should define `functions` property in `now.json` and list PHP files directly or using wildcard (*).
@ -56,7 +93,16 @@ You should define `functions` property in `now.json` and list PHP files directly
{
"functions": {
"api/*.php": {
"runtime": "now-php@0.0.10"
"runtime": "vercel-php@0.1.0"
},
// Can be list directly also
"api/one.php": {
"runtime": "vercel-php@0.1.0"
},
"api/two.php": {
"runtime": "vercel-php@0.1.0"
}
}
}
@ -68,7 +114,7 @@ If you need to show index page define `routes` properly.
{
"functions": {
"api/index.php": {
"runtime": "now-php@0.0.1 0"
"runtime": "vercel-php@0.1. 0"
}
},
"routes": [
@ -77,13 +123,13 @@ If you need to show index page define `routes` properly.
}
```
Additional function properties are `memory` , `maxDuration` .
Additional function properties are `memory` , `maxDuration` . Learn more about [functions ](https://vercel.com/docs/configuration#project/functions ).
```json
{
"functions": {
"api/*.php": {
"runtime": "now-php@0.0.1 0",
"runtime": "vercel-php@0.1. 0",
"memory": 3008,
"maxDuration": 500
}
@ -91,36 +137,37 @@ Additional function properties are `memory`, `maxDuration`.
}
```
**Click & Go**
[![Deploy with ZEIT Now ](https://zeit.co/button )](https://zeit.co/new/project?template=https://github.com/juicyfx/now-examples/tree/master/php)
## 👨💻`now dev`
For running `now dev` properly, you need to have PHP installed on your computer, [learn more ](errors/now-dev-no-local-php.md ).
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
```
## 👀 Demo
- official - https://php.now.sh/
- phpinfo - https://php.jfx.cz/
- extensions - https://php.jfx.cz /ext/
- ini - https://php.jfx.cz /ini/
- JSON API - https://php.jfx.cz /api/users.php
- test - https://php.jfx.cz /test.php
- official - https://php.vercel.app /
- phpinfo - https://phpshow.vercel.app /
- extensions - https://phpshow.vercel.app /ext/
- ini - https://phpshow.vercel.app /ini/
- JSON API - https://phpshow.vercel.app /api/users.php
- test - https://phpshow.vercel.app /test.php
![](docs/phpinfo.png)
## 🎯Examples
- [PHP - fast & simple ](https://github.com/juicyfx/ now -examples/tree/master/php/)
- [Composer - install dependencies ](https://github.com/juicyfx/ now -examples/tree/master/php-composer/)
- [Framework - Lumen ](https://github.com/juicyfx/ now -examples/tree/master/php-framework-lumen/)
- [Framework - Nette ](https://github.com/juicyfx/ now -examples/tree/master/php-framework-nette/)
- [Framework - Slim ](https://github.com/juicyfx/ now -examples/tree/master/php-framework-slim/)
- [Framework - Symfony - Microservice ](https://github.com/juicyfx/ now -examples/tree/master/php-framework-symfony-microservice/)
- [Framework - Phalcon ](https://github.com/juicyfx/ now -examples/tree/master/php-framework-phalcon/)
- [PHP - fast & simple ](https://github.com/juicyfx/ vercel -examples/tree/master/php/)
- [Composer - install dependencies ](https://github.com/juicyfx/ vercel -examples/tree/master/php-composer/)
- [Framework - Lumen ](https://github.com/juicyfx/ vercel -examples/tree/master/php-framework-lumen/)
- [Framework - Nette ](https://github.com/juicyfx/ vercel -examples/tree/master/php-framework-nette/)
- [Framework - Slim ](https://github.com/juicyfx/ vercel -examples/tree/master/php-framework-slim/)
- [Framework - Symfony - Microservice ](https://github.com/juicyfx/ vercel -examples/tree/master/php-framework-symfony-microservice/)
- [Framework - Phalcon ](https://github.com/juicyfx/ vercel -examples/tree/master/php-framework-phalcon/)
Browse [more examples ](https://github.com/juicyfx/ now -examples). 👀
Browse [more examples ](https://github.com/juicyfx/ vercel -examples). 👀
## 📜 Resources
@ -133,25 +180,26 @@ Browse [more examples](https://github.com/juicyfx/now-examples). 👀
## 🚧 Roadmap
- next-gen PHP runtime ✅
**WIP**
- customize php.ini
- composer.json scripts
**Done**
- next-gen PHP runtime
- Composer
- config.composer: true ✅
- composer.json detection ✅
- zero config ✅
- `now dev` ✅
- rewrite to typescript ✅
- setup CI ✅
- configure php.ini 🚧
- using `builds.config` ✅
- using `build.env` 🚧
- PHP versions
- 7.4 ✅ (used)
- 7.3 ✅
- 7.2 ✅
- config.composer: true
- composer.json detection
- zero config
- `now dev`
- typescript codebase
- github workflows (CI)
- PHP 7.4
**Help wanted**
- create many examples (majority frameworks and other use-cases)
- create examples using vercel-php
## 👨🏻 💻CHANGELOG