Skip to content

Commit 797fe5d

Browse files
committed
Refactoring: now-php -> vercel-php
1 parent e926480 commit 797fe5d

File tree

24 files changed

+279
-166
lines changed

24 files changed

+279
-166
lines changed
File renamed without changes.

.gitignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
/node_modules
33
/packages/**/package-lock.json
44

5-
# ZEIT
6-
.now
5+
# Vercel
6+
.vercel

README.md

+103-55
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
<h1 align=center>ZEIT Now PHP</h1>
1+
<h1 align=center>PHP Runtime for <a href="https://vercel.com">Vercel</h1>
22

33
<p align=center>
4-
Enjoyable & powerful 🐘 PHP Runtime (<a href="https://php.now.sh">php.now.sh</a>) for ZEIT Now.
4+
Enjoyable & powerful 🐘 PHP Runtime (<a href="https://php.vercel.app">php.vercel.app</a>) for Vercel platform.
5+
<a href="https://vercel.com/new/project?template=https://github.com/juicyfx/vercel-examples/tree/master/php"><img src="https://vercel.com/button"></a>
56
</p>
67

78
<p align=center>
8-
🕹 <a href="https://f3l1x.io">f3l1x.io</a> | 💻 <a href="https://github.com/f3l1x">f3l1x</a> | 🐦 <a href="https://twitter.com/xf3l1x">@xf3l1x</a>
9-
</p>
10-
11-
<p align=center>
12-
<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>
13-
<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>
9+
<a href="https://www.npmjs.com/package/vercel-php"><img src="https://badgen.net/npm/v/vercel-php"></a>
10+
<a href="https://www.npmjs.com/package/vercel-php"><img src="https://badgen.net/npm/dt/vercel-php"></a>
11+
<a href="https://www.npmjs.com/package/vercel-php"><img src="https://badgen.net/github/status/juicyfx/vercel-php/master"></a>
1412
</p>
1513

1614
<p align=center>
@@ -21,24 +19,63 @@ Enjoyable & powerful 🐘 PHP Runtime (<a href="https://php.now.sh">php.now.sh</
2119
<a href="https://github.com/phalcon"><img src="https://github.com/phalcon.png" width="128"></a>
2220
</p>
2321

24-
<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>
22+
<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>
23+
24+
-----
25+
26+
<p align=center>
27+
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>
28+
</p>
2529

2630
-----
2731

28-
## 🐣 Versions
32+
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.
33+
34+
Most simple example project is this one, using following project structure.
35+
36+
```sh
37+
project
38+
├── api
39+
│ └── index.php
40+
└── now.json
41+
```
42+
43+
First file `api/index.php` is entrypoint of our application. It should be placed in **api** folder, it's very standard location for Vercel.
44+
45+
```php
46+
<?php
47+
phpinfo();
48+
```
49+
50+
Second file `now.json` is pure gold here. Setup your project with configuration like this and voila. That's all.
51+
52+
```json
53+
{
54+
"functions": {
55+
"api/*.php": {
56+
"runtime": "[email protected]"
57+
}
58+
}
59+
}
60+
```
61+
62+
Last thing you have to do is call `now`. If you are more interested take a look at features and usage.
2963

30-
| | Pkg | Tag | Stability | Info |
31-
|----|---------|--------------|-------------|--------------------------|
32-
|| now-php | latest | production | Rock-solid stable. |
33-
| 🔥 | now-php | canary | testing | For early-adopters. |
34-
| ⚠️ | now-php | experimental | development | Testing and high danger. |
64+
```
65+
# Install it globally
66+
npm i -g now
3567
36-
> Need to know how things are changing? Here is [changelog](./CHANGELOG.md).
68+
# Log in
69+
now login
70+
71+
# Let's fly
72+
now
73+
```
3774

3875
## 🤗 Features
3976

4077
- **Architecture**: PHP development server (🚀 fast enough)
41-
- **PHP version**: 7.4.4
78+
- **PHP version**: 7.4.7
4279
- **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
4380
- **Speed**: cold ~250ms / warm ~5ms
4481
- **Memory**: ~90mb
@@ -48,15 +85,24 @@ Enjoyable & powerful 🐘 PHP Runtime (<a href="https://php.now.sh">php.now.sh</
4885
4986
## ⚙️ Usage
5087

51-
Take a look at [ZEIT's](https://zeit.co) blogpost about [`Serverless Functions`](https://zeit.co/blog/customizing-serverless-functions).
88+
Take a look at [Vercel's](https://vercel.com) blogpost about [`Serverless Functions`](https://vercel.com/blog/customizing-serverless-functions).
5289

5390
You should define `functions` property in `now.json` and list PHP files directly or using wildcard (*).
5491

5592
```json
5693
{
5794
"functions": {
5895
"api/*.php": {
59-
"runtime": "[email protected]"
96+
"runtime": "[email protected]"
97+
},
98+
99+
// Can be list directly also
100+
101+
"api/one.php": {
102+
"runtime": "[email protected]"
103+
},
104+
"api/two.php": {
105+
"runtime": "[email protected]"
60106
}
61107
}
62108
}
@@ -68,7 +114,7 @@ If you need to show index page define `routes` properly.
68114
{
69115
"functions": {
70116
"api/index.php": {
71-
"runtime": "now-php@0.0.10"
117+
"runtime": "vercel-php@0.1.0"
72118
}
73119
},
74120
"routes": [
@@ -77,50 +123,51 @@ If you need to show index page define `routes` properly.
77123
}
78124
```
79125

80-
Additional function properties are `memory`, `maxDuration`.
126+
Additional function properties are `memory`, `maxDuration`. Learn more about [functions](https://vercel.com/docs/configuration#project/functions).
81127

82128
```json
83129
{
84130
"functions": {
85131
"api/*.php": {
86-
"runtime": "now-php@0.0.10",
132+
"runtime": "vercel-php@0.1.0",
87133
"memory": 3008,
88134
"maxDuration": 500
89135
}
90136
}
91137
}
92138
```
93139

94-
**Click & Go**
95-
96-
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/new/project?template=https://github.com/juicyfx/now-examples/tree/master/php)
97-
98140
## 👨‍💻`now dev`
99141

100142
For running `now dev` properly, you need to have PHP installed on your computer, [learn more](errors/now-dev-no-local-php.md).
143+
But it's PHP and as you know PHP has built-in development server. It works out of box.
144+
145+
```
146+
php -S localhost:8000 api/index.php
147+
```
101148

102149
## 👀 Demo
103150

104-
- official - https://php.now.sh/
105-
- phpinfo - https://php.jfx.cz/
106-
- extensions - https://php.jfx.cz/ext/
107-
- ini - https://php.jfx.cz/ini/
108-
- JSON API - https://php.jfx.cz/api/users.php
109-
- test - https://php.jfx.cz/test.php
151+
- official - https://php.vercel.app/
152+
- phpinfo - https://phpshow.vercel.app/
153+
- extensions - https://phpshow.vercel.app/ext/
154+
- ini - https://phpshow.vercel.app/ini/
155+
- JSON API - https://phpshow.vercel.app/api/users.php
156+
- test - https://phpshow.vercel.app/test.php
110157

111158
![](docs/phpinfo.png)
112159

113160
## 🎯Examples
114161

115-
- [PHP - fast & simple](https://github.com/juicyfx/now-examples/tree/master/php/)
116-
- [Composer - install dependencies](https://github.com/juicyfx/now-examples/tree/master/php-composer/)
117-
- [Framework - Lumen](https://github.com/juicyfx/now-examples/tree/master/php-framework-lumen/)
118-
- [Framework - Nette](https://github.com/juicyfx/now-examples/tree/master/php-framework-nette/)
119-
- [Framework - Slim](https://github.com/juicyfx/now-examples/tree/master/php-framework-slim/)
120-
- [Framework - Symfony - Microservice](https://github.com/juicyfx/now-examples/tree/master/php-framework-symfony-microservice/)
121-
- [Framework - Phalcon](https://github.com/juicyfx/now-examples/tree/master/php-framework-phalcon/)
162+
- [PHP - fast & simple](https://github.com/juicyfx/vercel-examples/tree/master/php/)
163+
- [Composer - install dependencies](https://github.com/juicyfx/vercel-examples/tree/master/php-composer/)
164+
- [Framework - Lumen](https://github.com/juicyfx/vercel-examples/tree/master/php-framework-lumen/)
165+
- [Framework - Nette](https://github.com/juicyfx/vercel-examples/tree/master/php-framework-nette/)
166+
- [Framework - Slim](https://github.com/juicyfx/vercel-examples/tree/master/php-framework-slim/)
167+
- [Framework - Symfony - Microservice](https://github.com/juicyfx/vercel-examples/tree/master/php-framework-symfony-microservice/)
168+
- [Framework - Phalcon](https://github.com/juicyfx/vercel-examples/tree/master/php-framework-phalcon/)
122169

123-
Browse [more examples](https://github.com/juicyfx/now-examples). 👀
170+
Browse [more examples](https://github.com/juicyfx/vercel-examples). 👀
124171

125172
## 📜 Resources
126173

@@ -133,25 +180,26 @@ Browse [more examples](https://github.com/juicyfx/now-examples). 👀
133180

134181
## 🚧 Roadmap
135182

136-
- next-gen PHP runtime ✅
183+
**WIP**
184+
185+
- customize php.ini
186+
- composer.json scripts
187+
188+
**Done**
189+
190+
- next-gen PHP runtime
137191
- Composer
138-
- config.composer: true ✅
139-
- composer.json detection ✅
140-
- zero config ✅
141-
- `now dev`
142-
- rewrite to typescript ✅
143-
- setup CI ✅
144-
- configure php.ini 🚧
145-
- using `builds.config`
146-
- using `build.env` 🚧
147-
- PHP versions
148-
- 7.4 ✅ (used)
149-
- 7.3 ✅
150-
- 7.2 ✅
192+
- config.composer: true
193+
- composer.json detection
194+
- zero config
195+
- `now dev`
196+
- typescript codebase
197+
- github workflows (CI)
198+
- PHP 7.4
151199

152200
**Help wanted**
153201

154-
- create many examples (majority frameworks and other use-cases)
202+
- create examples using vercel-php
155203

156204
## 👨🏻‍💻CHANGELOG
157205

errors/now-dev-no-local-php.md

+16-8
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
# It looks like you don't have PHP on your machine.
22

3-
#### Why This Error Occurred
3+
**Why This Error Occurred**
4+
45
You ran `now dev` on a machine where PHP is not installed.
56
For the time being, this runtime requires a local PHP installation to run the runtime locally.
67

7-
#### Possible Ways to Fix It
8+
**Possible Ways to Fix It**
89

9-
##### Install PHP to your computer
10+
1. Install PHP to your computer
1011

1112
**OSX**
1213

1314
```
14-
brew install php@7.3
15+
brew install php@7.4
1516
```
1617

1718
**Ubuntu**
@@ -21,7 +22,7 @@ apt-get -y install apt-transport-https lsb-release ca-certificates
2122
wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
2223
sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
2324
apt-get update
24-
apt-get install php7.3-cli php7.3-cgi php7.3-json php7.3-curl php7.3-mbstring
25+
apt-get install php7.4-cli php7.4-cgi php7.4-json php7.4-curl php7.4-mbstring
2526
```
2627

2728
**Fedora**
@@ -30,10 +31,17 @@ apt-get install php7.3-cli php7.3-cgi php7.3-json php7.3-curl php7.3-mbstring
3031
yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
3132
yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
3233
yum install yum-utils
33-
yum-config-manager --enable remi-php73
34+
yum-config-manager --enable remi-php74
3435
yum update
35-
yum install php73-cli php73-cgi php73-json php73-curl php73-mbstring
36+
yum install php74-cli php74-cgi php74-json php74-curl php74-mbstring
3637
```
3738

38-
##### Check that php is in the path
39+
2. Start PHP built-in Development Server
40+
41+
```sh
42+
php -S localhost:8000 api/index.php
43+
```
44+
45+
**Check that php is in the path**
46+
3947
If you do have installed PHP but still get this error, check that PHP executable is added to the PATH environment variable.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "now-php-monorepo",
2+
"name": "vercel-php-monorepo",
33
"scripts": {
44
"test-unit": "jest --config unit.jest.config.js"
55
},

packages/php/README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# now-php
1+
# vercel-php
22

33
1. Create `api/index.php`.
44

@@ -7,18 +7,18 @@
77
phpinfo();
88
```
99

10-
1. Create `now.json`
10+
2. Create `now.json`
1111

1212
```json
1313
{
1414
"functions": {
1515
"api/index.php": {
16-
"runtime": "now-php@0.0.9"
16+
"runtime": "vercel-php@0.1.0"
1717
}
1818
}
1919
}
2020
```
2121

22-
3. Call `now` and see magic.
22+
3. Call `vercel`, `vc` or `now` and see magic.
2323

24-
4. Discover more in documentation at [Github repository](https://github.com/juicyfx/now-php).
24+
4. Discover more in documentation at [Github repository](https://github.com/juicyfx/vercel-php).

packages/php/package.json

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
{
2-
"name": "now-php",
3-
"description": "PHP ZEIT Now Runtime",
4-
"version": "0.0.10",
2+
"name": "vercel-php",
3+
"description": "Vercel PHP runtime",
4+
"version": "0.1.0",
55
"license": "MIT",
66
"main": "./dist/index.js",
7-
"homepage": "https://github.com/juicyfx/now-php",
7+
"homepage": "https://github.com/juicyfx/vercel-php",
88
"repository": {
99
"type": "git",
10-
"url": "https://github.com/juicyfx/now-php.git"
10+
"url": "https://github.com/juicyfx/vercel-php.git"
1111
},
1212
"keywords": [
13+
"vercel",
1314
"zeit",
1415
"now",
1516
"php",
@@ -24,17 +25,16 @@
2425
"prepublishOnly": "tsc"
2526
},
2627
"files": [
27-
"dist",
28-
"lib"
28+
"dist"
2929
],
3030
"dependencies": {
31-
"@now-php/lib-74": "latest"
31+
"@libphp/amazon-linux-2-v74": "^0.0.6"
3232
},
3333
"devDependencies": {
34-
"@now/build-utils": "^0.9.4",
35-
"@types/glob": "^7.1.1",
36-
"@types/node": "^10.0.0",
37-
"jest": "^24.8.0",
38-
"typescript": "^3.5.3"
34+
"@vercel/build-utils": "^2.4.0",
35+
"@types/glob": "^7.1.2",
36+
"@types/node": "^12.12.47",
37+
"jest": "^26.0.1",
38+
"typescript": "^3.9.5"
3939
}
4040
}

0 commit comments

Comments
 (0)