GithubHelp home page GithubHelp logo

vercel-community / php Goto Github PK

View Code? Open in Web Editor NEW
1.1K 22.0 235.0 109.68 MB

🐘 PHP Runtime for β–² Vercel Serverless Functions (support 7.4-8.3)

Home Page: https://php.vercel.app

License: MIT License

Makefile 0.95% JavaScript 9.52% TypeScript 70.94% PHP 18.46% Hack 0.02% HTML 0.11%
php lambda vercel runtime aws serverless

php's People

Contributors

agdholo avatar andybitz avatar dependabot[bot] avatar dominikvisek avatar eiriksm avatar f3l1x avatar itsgoingd avatar nettum avatar nosovk avatar quiibz avatar robertdrakedennis avatar styfle avatar ties-v avatar tootallnate avatar tuckerwhitehouse avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php's Issues

[node 8] BAD_GATEWAY Code: NO_STATUS_CODE_FROM_FUNCTION

Hello,
I am trying to deploy a php file.
and it builds fine (I think). But whenever I try to access it, the website gives me a 502 error with the following text : 502: BAD_GATEWAY Code: NO_STATUS_CODE_FROM_FUNCTION
I've checked the logs and it seems to be an error when it tries to load a shared library (error while loading shared libraries: libcrypt.so.1: cannot open shared object file: No such file or directory)

but I'm at a complete loss as to why this has only started to happen today. as it worked fine yesterday. :/

any help would be greatly appreciated.

Entire project is sent to each builder

Bug report

Description

It appears that all files in the now Vercel project root (where .vercel and/or now.json are kept) are being sent to the builder for each Serverless Function. It's causing my builds to fail, as my repo as a whole is well over the Lambda max of 50MB, even though each Serverless function is well below that.

My understanding is that each Serverless Function should, by default, include only its own .php file, plus any matching files explicitly specified in that function's includeFiles in now.json.

The example at the repo above is nearly identical to the vercel-examples/php example, just with a 100MB nonsense zip file added to the root directory. It fails to build because Error: The Serverless Function "api/index.php" is 127.22mb which exceeds the maximum size limit of 50mb. Learn More: https://vercel.link/serverless-function-size.

OctoberCMS deployment error

OctoberCMS deployment error, error details are as follows:

11:55:57.022  Retrieving list of deployment files...
11:55:59.059  Downloading 8613 deployment files...
11:56:36.179  Installing build runtime...
11:56:39.304  Build runtime installed: 3125.472ms
11:56:39.641  Looking up build cache...
11:56:39.679  Build cache not found
11:56:44.229  FetchError: request to https://dmmcy0pwk6bqi.cloudfront.net/72fa93338474b73727a4d70b0c643da5286a38f8 failed, reason: getaddrinfo EBUSY dmmcy0pwk6bqi.cloudfront.net
11:56:44.229      at ClientRequest.<anonymous> (/var/task/sandbox-worker.js:85863:11)
11:56:44.229      at ClientRequest.emit (events.js:310:20)
11:56:44.229      at ClientRequest.EventEmitter.emit (domain.js:482:12)
11:56:44.229      at TLSSocket.socketErrorListener (_http_client.js:426:9)
11:56:44.229      at TLSSocket.emit (events.js:310:20)
11:56:44.229      at TLSSocket.EventEmitter.emit (domain.js:482:12)
11:56:44.230      at emitErrorNT (internal/streams/destroy.js:92:8)
11:56:44.230      at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
11:56:44.230      at processTicksAndRejections (internal/process/task_queues.js:84:21) {
11:56:44.230    message: 'request to https://dmmcy0pwk6bqi.cloudfront.net/72fa93338474b73727a4d70b0c643da5286a38f8 failed, reason: getaddrinfo EBUSY dmmcy0pwk6bqi.cloudfront.net',
11:56:44.230    type: 'system',
11:56:44.230    errno: 'EBUSY',
11:56:44.230    code: 'EBUSY'
11:56:44.230  }
11:56:44.238  [bld_i9i60y1sk] [now] retrying to patch after FetchError: request to https://api-pdx1.vercel.com/v2/now/deployments/dpl_AnxCrBTB9XtBFm8Ews4ZZvGB9rju/builds/bld_i9i60y1sk failed, reason: getaddrinfo EBUSY api-pdx1.vercel.com
11:56:44.238      at ClientRequest.<anonymous> (/var/task/sandbox-worker.js:4408:11)
11:56:44.238      at ClientRequest.emit (events.js:310:20)
11:56:44.238      at ClientRequest.EventEmitter.emit (domain.js:482:12)
11:56:44.238      at TLSSocket.socketErrorListener (_http_client.js:426:9)
11:56:44.238      at TLSSocket.emit (events.js:310:20)
11:56:44.238      at TLSSocket.EventEmitter.emit (domain.js:482:12)
11:56:44.238      at emitErrorNT (internal/streams/destroy.js:92:8)
11:56:44.238      at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
11:56:44.238      at processTicksAndRejections (internal/process/task_queues.js:84:21) {
11:56:44.238    message: 'request to https://api-pdx1.vercel.com/v2/now/deployments/dpl_AnxCrBTB9XtBFm8Ews4ZZvGB9rju/builds/bld_i9i60y1sk failed, reason: getaddrinfo EBUSY api-pdx1.vercel.com',
11:56:44.239    type: 'system',
11:56:44.239    errno: 'EBUSY',
11:56:44.239    code: 'EBUSY'
11:56:44.239  }
11:56:45.241  [bld_i9i60y1sk] [now] retrying to patch after FetchError: request to https://api-pdx1.vercel.com/v2/now/deployments/dpl_AnxCrBTB9XtBFm8Ews4ZZvGB9rju/builds/bld_i9i60y1sk failed, reason: getaddrinfo EBUSY api-pdx1.vercel.com
11:56:45.241      at ClientRequest.<anonymous> (/var/task/sandbox-worker.js:4408:11)
11:56:45.241      at ClientRequest.emit (events.js:310:20)
11:56:45.241      at ClientRequest.EventEmitter.emit (domain.js:482:12)
11:56:45.241      at TLSSocket.socketErrorListener (_http_client.js:426:9)
11:56:45.241      at TLSSocket.emit (events.js:310:20)
11:56:45.241      at TLSSocket.EventEmitter.emit (domain.js:482:12)
11:56:45.241      at emitErrorNT (internal/streams/destroy.js:92:8)
11:56:45.241      at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
11:56:45.241      at processTicksAndRejections (internal/process/task_queues.js:84:21) {
11:56:45.241    message: 'request to https://api-pdx1.vercel.com/v2/now/deployments/dpl_AnxCrBTB9XtBFm8Ews4ZZvGB9rju/builds/bld_i9i60y1sk failed, reason: getaddrinfo EBUSY api-pdx1.vercel.com',
11:56:45.241    type: 'system',
11:56:45.242    errno: 'EBUSY',
11:56:45.242    code: 'EBUSY'
11:56:45.242  }
11:56:47.244  [bld_i9i60y1sk] [now] retrying to patch after FetchError: request to https://api-pdx1.vercel.com/v2/now/deployments/dpl_AnxCrBTB9XtBFm8Ews4ZZvGB9rju/builds/bld_i9i60y1sk failed, reason: getaddrinfo EBUSY api-pdx1.vercel.com
11:56:47.244      at ClientRequest.<anonymous> (/var/task/sandbox-worker.js:4408:11)
11:56:47.244      at ClientRequest.emit (events.js:310:20)
11:56:47.244      at ClientRequest.EventEmitter.emit (domain.js:482:12)
11:56:47.244      at TLSSocket.socketErrorListener (_http_client.js:426:9)
11:56:47.244      at TLSSocket.emit (events.js:310:20)
11:56:47.244      at TLSSocket.EventEmitter.emit (domain.js:482:12)
11:56:47.244      at emitErrorNT (internal/streams/destroy.js:92:8)
11:56:47.244      at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
11:56:47.244      at processTicksAndRejections (internal/process/task_queues.js:84:21) {
11:56:47.244    message: 'request to https://api-pdx1.vercel.com/v2/now/deployments/dpl_AnxCrBTB9XtBFm8Ews4ZZvGB9rju/builds/bld_i9i60y1sk failed, reason: getaddrinfo EBUSY api-pdx1.vercel.com',
11:56:47.244    type: 'system',
11:56:47.244    errno: 'EBUSY',
11:56:47.244    code: 'EBUSY'
11:56:47.244  }
11:56:51.247  FetchError: request to https://api-pdx1.vercel.com/v2/now/deployments/dpl_AnxCrBTB9XtBFm8Ews4ZZvGB9rju/builds/bld_i9i60y1sk failed, reason: getaddrinfo EBUSY api-pdx1.vercel.com
11:56:51.247      at ClientRequest.<anonymous> (/var/task/sandbox-worker.js:4408:11)
11:56:51.247      at ClientRequest.emit (events.js:310:20)
11:56:51.247      at ClientRequest.EventEmitter.emit (domain.js:482:12)
11:56:51.247      at TLSSocket.socketErrorListener (_http_client.js:426:9)
11:56:51.247      at TLSSocket.emit (events.js:310:20)
11:56:51.247      at TLSSocket.EventEmitter.emit (domain.js:482:12)
11:56:51.247      at emitErrorNT (internal/streams/destroy.js:92:8)
11:56:51.247      at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
11:56:51.247      at processTicksAndRejections (internal/process/task_queues.js:84:21) {
11:56:51.247    message: 'request to https://api-pdx1.vercel.com/v2/now/deployments/dpl_AnxCrBTB9XtBFm8Ews4ZZvGB9rju/builds/bld_i9i60y1sk failed, reason: getaddrinfo EBUSY api-pdx1.vercel.com',
11:56:51.247    type: 'system',
11:56:51.247    errno: 'EBUSY',
11:56:51.247    code: 'EBUSY'
11:56:51.247  }
11:56:51.248  [bld_i9i60y1sk] [now] retrying to patch after FetchError: request to https://api-pdx1.vercel.com/v2/now/deployments/dpl_AnxCrBTB9XtBFm8Ews4ZZvGB9rju/builds/bld_i9i60y1sk failed, reason: getaddrinfo EBUSY api-pdx1.vercel.com
11:56:51.248      at ClientRequest.<anonymous> (/var/task/sandbox-worker.js:4408:11)
11:56:51.248      at ClientRequest.emit (events.js:310:20)
11:56:51.248      at ClientRequest.EventEmitter.emit (domain.js:482:12)
11:56:51.248      at TLSSocket.socketErrorListener (_http_client.js:426:9)
11:56:51.248      at TLSSocket.emit (events.js:310:20)
11:56:51.248      at TLSSocket.EventEmitter.emit (domain.js:482:12)
11:56:51.248      at emitErrorNT (internal/streams/destroy.js:92:8)
11:56:51.248      at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
11:56:51.248      at processTicksAndRejections (internal/process/task_queues.js:84:21) {
11:56:51.248    message: 'request to https://api-pdx1.vercel.com/v2/now/deployments/dpl_AnxCrBTB9XtBFm8Ews4ZZvGB9rju/builds/bld_i9i60y1sk failed, reason: getaddrinfo EBUSY api-pdx1.vercel.com',
11:56:51.248    type: 'system',
11:56:51.248    errno: 'EBUSY',
11:56:51.248    code: 'EBUSY'
11:56:51.248  }
11:56:52.249  [bld_i9i60y1sk] [now] retrying to patch after FetchError: request to https://api-pdx1.vercel.com/v2/now/deployments/dpl_AnxCrBTB9XtBFm8Ews4ZZvGB9rju/builds/bld_i9i60y1sk failed, reason: getaddrinfo EBUSY api-pdx1.vercel.com
11:56:52.249      at ClientRequest.<anonymous> (/var/task/sandbox-worker.js:4408:11)
11:56:52.249      at ClientRequest.emit (events.js:310:20)
11:56:52.249      at ClientRequest.EventEmitter.emit (domain.js:482:12)
11:56:52.249      at TLSSocket.socketErrorListener (_http_client.js:426:9)
11:56:52.249      at TLSSocket.emit (events.js:310:20)
11:56:52.249      at TLSSocket.EventEmitter.emit (domain.js:482:12)
11:56:52.249      at emitErrorNT (internal/streams/destroy.js:92:8)
11:56:52.249      at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
11:56:52.249      at processTicksAndRejections (internal/process/task_queues.js:84:21) {
11:56:52.249    message: 'request to https://api-pdx1.vercel.com/v2/now/deployments/dpl_AnxCrBTB9XtBFm8Ews4ZZvGB9rju/builds/bld_i9i60y1sk failed, reason: getaddrinfo EBUSY api-pdx1.vercel.com',
11:56:52.249    type: 'system',
11:56:52.249    errno: 'EBUSY',
11:56:52.249    code: 'EBUSY'
11:56:52.249  }
11:56:54.251  [bld_i9i60y1sk] [now] retrying to patch after FetchError: request to https://api-pdx1.vercel.com/v2/now/deployments/dpl_AnxCrBTB9XtBFm8Ews4ZZvGB9rju/builds/bld_i9i60y1sk failed, reason: getaddrinfo EBUSY api-pdx1.vercel.com
11:56:54.251      at ClientRequest.<anonymous> (/var/task/sandbox-worker.js:4408:11)
11:56:54.251      at ClientRequest.emit (events.js:310:20)
11:56:54.251      at ClientRequest.EventEmitter.emit (domain.js:482:12)
11:56:54.251      at TLSSocket.socketErrorListener (_http_client.js:426:9)
11:56:54.251      at TLSSocket.emit (events.js:310:20)
11:56:54.251      at TLSSocket.EventEmitter.emit (domain.js:482:12)
11:56:54.251      at emitErrorNT (internal/streams/destroy.js:92:8)
11:56:54.251      at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
11:56:54.251      at processTicksAndRejections (internal/process/task_queues.js:84:21) {
11:56:54.251    message: 'request to https://api-pdx1.vercel.com/v2/now/deployments/dpl_AnxCrBTB9XtBFm8Ews4ZZvGB9rju/builds/bld_i9i60y1sk failed, reason: getaddrinfo EBUSY api-pdx1.vercel.com',
11:56:54.251    type: 'system',
11:56:54.251    errno: 'EBUSY',
11:56:54.251    code: 'EBUSY'
11:56:54.251  }
11:56:58.255  worker main FetchError: request to https://api-pdx1.vercel.com/v2/now/deployments/dpl_AnxCrBTB9XtBFm8Ews4ZZvGB9rju/builds/bld_i9i60y1sk failed, reason: getaddrinfo EBUSY api-pdx1.vercel.com
11:56:58.255      at ClientRequest.<anonymous> (/var/task/sandbox-worker.js:4408:11)
11:56:58.255      at ClientRequest.emit (events.js:310:20)
11:56:58.255      at ClientRequest.EventEmitter.emit (domain.js:482:12)
11:56:58.255      at TLSSocket.socketErrorListener (_http_client.js:426:9)
11:56:58.255      at TLSSocket.emit (events.js:310:20)
11:56:58.255      at TLSSocket.EventEmitter.emit (domain.js:482:12)
11:56:58.255      at emitErrorNT (internal/streams/destroy.js:92:8)
11:56:58.255      at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
11:56:58.255      at processTicksAndRejections (internal/process/task_queues.js:84:21) {
11:56:58.255    message: 'request to https://api-pdx1.vercel.com/v2/now/deployments/dpl_AnxCrBTB9XtBFm8Ews4ZZvGB9rju/builds/bld_i9i60y1sk failed, reason: getaddrinfo EBUSY api-pdx1.vercel.com',
11:56:58.256    type: 'system',
11:56:58.256    errno: 'EBUSY',
11:56:58.256    code: 'EBUSY'
11:56:58.256  }
11:56:59.587  Done with "api/index.php"

Session usage

Question

So I'm experimenting with vercel and I'm wondering if session usage is supposed to work (since it's serverless?)

So far, it seems to work but I get something a bit strange

Using the following code

session_start();

$counter = $_SESSION['counter'] ?? 0;
$counter++;
$_SESSION['counter'] = $counter;

echo "counter is $counter";

I got an increment of 1 on my local webserver, but an increment of 2 of my test application running on vercel. No idea why. More generally I'm wondering what happens to temporary files (uploaded files? session files?) when running the php backend.

I know it's a bit outside of vercel-php itself but I'm guessing I may not the only one askying myself these questions?

Can't enable POST requests for api route

Bug report

  • Version: 0.1.1
  • URL: No
  • Repository: No

Description

When I try to POST to /submit-form, I get a 405 Method not allowed from Vercel, even though I specified the methods in the config. This makes it impossible to submit forms.

Here is my vercel.json:

{
  "functions": {
    "api/index.php": {
      "runtime": "[email protected]"
    }
  },
  "routes": [
    {
      "src": "/(.*)\\.(.*)$",
      "dest": "src/$1.$2"
    },
    {
      "src": "/(.*)",
      "methods": ["POST", "GET"],
      "dest": "/api/index.php"
    }
  ]
}

To repro, you can use something like curl:

https://your-app.vercel.app/submit -X POST
...
<html>    <head>        <title>Method not allowed</title>
        <style>
            body{
                margin:0;
                padding:30px;
                font:12px/1.5 Helvetica,Arial,Verdana,sans-serif;
            }
            h1{
                margin:0;
                font-size:48px;
                font-weight:normal;
                line-height:48px;
            }
        </style>
    </head>
    <body>
        <h1>Method not allowed</h1>
        <p>Method not allowed. Must be one of: <strong>GET</strong></p>
    </body>

php: error while loading shared libraries: libtinfo.so.6

Really nice project!

I will try to deploy with now my slim api projet.

now.json

{
    "functions": {
      "public/*.php": {
        "runtime": "[email protected]"
      }
    }
  }

composer.json

{
    "require": {
        "php": "^7.3",
        "slim/slim": "^4.3",
        "slim/psr7": "^0.6.0",
        "vlucas/phpdotenv": "^4.0"
    }
}

I got this error log on my now instance :

05:34:54 PM | Downloading 234 deployment files...
-- | --
05:35:07 PM | Installing build runtime...
05:35:10 PM | Build runtime installed: 2752.461ms
05:35:11 PM | Looking up build cache...
05:35:12 PM | 🐘 Installing Composer deps.
05:35:12 PM | php: error while loading shared libraries: libtinfo.so.6: cannot open shared object file: No such file or directory
05:35:12 PM | Error: Exited with 127
05:35:12 PM | at ChildProcess.child.on (/zeit/fa5b89e012ce722c/.build-utils/.builder/node_modules/now-php/dist/utils.js:151:24)
05:35:12 PM | at emitTwo (events.js:126:13)
05:35:12 PM | at ChildProcess.emit (events.js:214:7)
05:35:12 PM | at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
05:35:12 PM | worker exited with code 1 and signal null
05:35:12 PM | done
05:35:13 PM | Installing build runtime...
05:35:14 PM | Build runtime installed: 491.000ms
05:35:14 PM | Looking up build cache...
05:35:16 PM | 🐘 Installing Composer deps.
05:35:16 PM | php: error while loading shared libraries: libtinfo.so.6: cannot open shared object file: No such file or directory
05:35:16 PM | Error: Exited with 127
05:35:16 PM | at ChildProcess.child.on (/zeit/fa5b89e012ce722c/.build-utils/.builder/node_modules/now-php/dist/utils.js:151:24)
05:35:16 PM | at emitTwo (events.js:126:13)
05:35:16 PM | at ChildProcess.emit (events.js:214:7)
05:35:16 PM | at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
05:35:16 PM | worker exited with code 1 and signal null
05:35:16 PM | done
05:35:16 PM | Installing build runtime...
05:35:17 PM | Build runtime installed: 518.264ms
05:35:17 PM | Looking up build cache...
05:35:19 PM | 🐘 Installing Composer deps.
05:35:19 PM | php: error while loading shared libraries: libtinfo.so.6: cannot open shared object file: No such file or directory
05:35:19 PM | Error: Exited with 127
05:35:19 PM | at ChildProcess.child.on (/zeit/fa5b89e012ce722c/.build-utils/.builder/node_modules/now-php/dist/utils.js:151:24)
05:35:19 PM | at emitTwo (events.js:126:13)
05:35:19 PM | at ChildProcess.emit (events.js:214:7)
05:35:19 PM | at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
05:35:19 PM | worker exited with code 1 and signal null
05:35:19 PM | done
05:35:20 PM | Installing build runtime...
05:35:20 PM | Build runtime installed: 408.707ms
05:35:21 PM | Looking up build cache...
05:35:22 PM | 🐘 Installing Composer deps.
05:35:23 PM | php: error while loading shared libraries: libtinfo.so.6: cannot open shared object file: No such file or directory
05:35:23 PM | Error: Exited with 127
05:35:23 PM | at ChildProcess.child.on (/zeit/fa5b89e012ce722c/.build-utils/.builder/node_modules/now-php/dist/utils.js:151:24)
05:35:23 PM | at emitTwo (events.js:126:13)
05:35:23 PM | at ChildProcess.emit (events.js:214:7)
05:35:23 PM | at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
05:35:23 PM | worker exited with code 1 and signal null
05:35:23 PM | done
05:35:23 PM | Installing build runtime...
05:35:23 PM | Build runtime installed: 415.674ms
05:35:24 PM | Looking up build cache...
05:35:26 PM | 🐘 Installing Composer deps.
05:35:26 PM | php: error while loading shared libraries: libtinfo.so.6: cannot open shared object file: No such file or directory
05:35:26 PM | Error: Exited with 127
05:35:26 PM | at ChildProcess.child.on (/zeit/fa5b89e012ce722c/.build-utils/.builder/node_modules/now-php/dist/utils.js:151:24)
05:35:26 PM | at emitTwo (events.js:126:13)
05:35:26 PM | at ChildProcess.emit (events.js:214:7)
05:35:26 PM | at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
05:35:26 PM | worker exited with code 1 and signal null
05:35:28 PM | done

Any tips?

SQLite DB

Hi, is it possible to use SQLite3 database on this version? I tried creating a demo sqlite.db but it doesn't work. Even a simple "connection" test doesn't work or maybe I forgot something?

Trying to check SQLite version.
$dbh = new PDO('sqlite::memory:'); print_r("SQLite version " . $dbh->query('select sqlite_version()')->fetch()[0]); $dbh = null;

Fatal error: Uncaught Error: Call to a member function querySingle() on null in /var/task/user/api/index.php:27 Stack trace: #0 {main} thrown in /var/task/user/api/index.php on line 27

Thanks!

Add a local PHP configuration example

Question

Could you add an example of how to configure now-php to work with now dev? On this page it says "check that PHP executable is added to the PATH environment variable". I'm guessing this means create a .env file and put something like PATH=/⁨usr⁩/local⁩/⁨Cellar/[email protected]⁩/⁨7.3.15⁩/⁨bin⁩/php in it. Is that right? I tried that and also tried using the path from my .bash_profile, with no luck.

[question] Is vercel-php (now-php) production ready?

Forgive my lack of knowledge in php/serverless, you mentioned that the mode is "PHP development server" which gets a flag on php documentation for not being production friendly. Is this normal as it's a now/serverless architecture and all the server load is managed by Now. Can you please shed some light on this?

Thank you!

[question] how to enable php-mcrypt?

I need support to enable php-mcrypt on now-php
I get an error when use mcrypt
Fatal error: Uncaught Error: Call to undefined function mcrypt_module_open()

Thank you for support.

Is Vercel's .env CLI compatible with vercel-php?

Question

Are the vercel env commands usable for the vercel-php runtime? I want to store some secrets that are encrypted through Vercel. They are stored in my gitignored .env file. Can I access this in PHP?

How can I install GD?

How can I remove the error:

Fatal error: Uncaught Error: Call to undefined function imagecreatefrompng() in /var/task/user/api/image.php:8 Stack trace: #0 {main} thrown in /var/task/user/api/image.php on line 8

help plz(

ZEIT -> Vercel

  • rename now-php to vercel-php?
  • rename repositories
  • change texts

MongoDB extension

Feature Request

Hi! Is there any chance we could get the MongoDB extension?

I'm using Laravel and MongoDB but unfortunately the extension is not installed. Cheers!

accessing php as part of the build

Question

As part of my build process I run npm run production which compiles all my javascript, however a step in my build executes a php script. This seems to fail on ZEIT since php doesn't appear to be available. Currently this means I need to pre-compile my assets and skip zeits build step.

Is there a way to expose php to my npm build scripts? or alternatively, is there a way to run my npm build scripts as part of the now-php build step?

Long-term Roadmap

Near-by

  • PHP 8.2

Future

  • now dev (vol2)
  • More examples

Done

  1. next-gen PHP builder
  2. Composer
  3. config.composer: true
  4. composer.json detection
  5. zero config
  6. now dev (vol1)
  7. rewrite to typescript
  8. custom php.ini [#11, #17]
  9. pipe stdout/stderr to logs
  10. basic tests
  11. more demos [#19, #20, #21]
  12. PHP 7.3.12
  13. builder => runtime (v3)
  14. PHP 7.4
  15. Amazon Linux 2
  16. Separate examples to solo repo (https://github.com/juicyfx/now-examples)
  17. Compile more PHP extensions
  18. Rename now-php to vercel-php
  19. Override php.ini
  20. Run composer scripts [#81]
  21. Better concurrency on PHP 7.4+ (use env PHP_CLI_SERVER_WORKERS=2)
  22. PHP 8.0
  23. PHP 8.1

Feel free to suggest any feature you like.

Examples for lambdas in Vercel (ZEIT Now)?

Do you have any examples for how to run lambdas in Zeit Now?
I've tried placing scripts in the api/ directory but keep getting a not found page - the one that PHP renders, not Zeit's one.

Environment-variable does not change

First of all, thanks for your work with this, it's really great πŸ™‚
I have a question about environments, which is not really clear to me.

This is my PHP-file:

<?php

var_dump(getenv('foo'));

phpinfo();

I deploy it with now.json:

{
  "version": 2,
  "name": "test",
  "builds": [
    {
      "src": "index.php",
      "use": "now-php"
    }
  ],
  "env": {
    "foo": "foo"
  }
}

Thats works as expected and I see string foo dumped with getenv().

But if I change env foo in now.json to something else and redeploy it, the value of foo is still foo. It does not change.

Mabe it's a general problem with now...

Some PHP extension load failed

Question

use version 0.0.9, when i open build log in now, seems some php extension load failed

2020-01-28T06:47:36.062Z  Looking up build cache...
2020-01-28T06:47:36.149Z  Build cache found [119.51 kB, 188 files]
2020-01-28T06:47:36.149Z  Build cache unpacked: 87.213ms
2020-01-28T06:47:36.579Z  Running builder.exports.build...
2020-01-28T06:47:36.669Z  🐘 Installing Composer deps.
2020-01-28T06:47:36.680Z  PHP Warning:  PHP Startup: Unable to load dynamic library 'gd' (tried: /zeit/51622c6ed2bac4d4/.build-utils/.builder/node_modules/@now-php/lib-73/native/php/modules/gd (/zeit/51622c6ed2bac4d4/.build-utils/.builder/node_modules/@now-php/lib-73/native/php/modules/gd: cannot open shared object file: No such file or directory), /zeit/51622c6ed2bac4d4/.build-utils/.builder/node_modules/@now-php/lib-73/native/php/modules/gd.so (libfreetype.so.6: cannot open shared object file: No such file or directory)) in Unknown on line 0
2020-01-28T06:47:36.684Z  PHP Warning:  PHP Startup: Unable to load dynamic library 'xsl' (tried: /zeit/51622c6ed2bac4d4/.build-utils/.builder/node_modules/@now-php/lib-73/native/php/modules/xsl (/zeit/51622c6ed2bac4d4/.build-utils/.builder/node_modules/@now-php/lib-73/native/php/modules/xsl: cannot open shared object file: No such file or directory), /zeit/51622c6ed2bac4d4/.build-utils/.builder/node_modules/@now-php/lib-73/native/php/modules/xsl.so (libexslt.so.0: cannot open shared object file: No such file or directory)) in Unknown on line 0
2020-01-28T06:47:36.691Z  PHP Warning:  Cannot load module 'phalcon' because required module 'psr' is not loaded in Unknown on line 0
2020-01-28T06:47:36.851Z  [2.9MiB/0.01s] Loading composer repositories with package information
2020-01-28T06:47:36.854Z  [3.1MiB/0.01s] Installing dependencies from lock file
2020-01-28T06:47:36.864Z  [3.3MiB/0.02s] Nothing to install or update
2020-01-28T06:47:36.865Z  [3.1MiB/0.02s] Generating autoload files
2020-01-28T06:47:36.866Z  [3.1MiB/0.02s] Memory usage: 3.13MiB (peak: 3.73MiB), time: 0.02s
2020-01-28T06:47:36.871Z  🐘 Installing Composer deps OK.

deployed wordpress with now-php

I deployed wordpress with now-php. When running, it shows too many redirects.
image
My now.json is

{
  "version": 2,
  "builds": [
    { "src": "index.php", "use": "now-php" },
    { "src": ".htaccess", "use": "@now/static" }
  ],
  "routes": [
    { "src": "/(.*)", "dest": "index.php" } 
  ],
  "regions": ["icn1"]
}

Kirby support: possible conflict with Kirby go() function and swoole extension go() function.

Bug report

Description

The PHP error is

Fatal error: Cannot redeclare go() in /var/task/user/kirby/config/helpers.php on line 222

We can not figure out the source of the original go() function that kirby is conflicting with. We've discovered many different forms of using PHP reflection to try and find the source with no luck - https://stackoverflow.com/questions/7026690/reconstruct-get-code-of-php-function - and posting our own question - https://stackoverflow.com/questions/64867808/get-function-definition-in-string-form-in-php

The only hint that we found is that the PHP extension swoole has a go() function that sounds like it may be the conflict (https://github.com/getkirby-v2/kirby/issues/643) however all of our attempts to disable that extension have failed, like overriding the php.ini config. Is there a way to not include that with vercel-php? maybe a past version that doesn't have it? or any other ideas?

Thanks in advance.

now dev on windows

Bug report

  • Version: 0.0.9

Description

I'm trying to use now dev on windows but i get these messages

> Ready! Available at http://localhost:3000
> Building [email protected]:api/index.php

        It looks like you don't have PHP on your machine.
        Learn more about how to run now dev on your machine.
        https://err.sh/juicyfx/now-php/now-dev-no-local-php

when visiting the url, i get vendor errors like this

Warning: require_once(C:\Users\myusername\AppData\Local\Temp\zeit-fun-0a347cf3b4463\user\api/../vendor/autoload.php): failed to open stream: No such file or directory in C:\Users\myusername\AppData\Local\Temp\zeit-fun-0a347cf3b4463\user\api\index.php on line 7

is windows supported ? nothing is mentionned in the url now-dev-no-local-php about windows. It seems to work more or less since I'm seeing a warning message, so maybe it's easy to fix.

Does not support includeFiles and excludeFiles glob patterns, which Vercel requires

Bug report

Description

Vercel requires a function's includeFiles and excludeFiles to be a single glob string.

vercel-php expects an array, or a string. But it trips on many glob matching patterns.

There are two abutting issues:

  1. A now.jsonvercel.json file with an array in includeFiles or excludeFiles fails validation and refuses to deploy, even though that's what's recommended in vercel-php's documentation.
Error! Invalid now.json - `functions['api/index.php'].excludeFiles` Invalid request: `functions['api/index.php'].excludeFiles` should be string..
  1. vercel-php seems to trip on many non-trivial glob patterns (basically anything that's beyond a string ending in * or **). It will deploy, but with the following behavior:

On the first GET request, the request times out with a Vercel 502 NO_RESPONSE_FROM_FUNCTION error.
image

Vercel logs show the following:

🐘 Spawning: PHP Built-In Server at /var/task/user (document root) and /var/task/user/api/index.php (router)
2020-08-07T15:41:38.840Z	d9691f0f-b896-4a65-8b9e-2182919131a0	ERROR	🐘STDERR: Directory /var/task/user does not exist.
🐘 PHP Built-In Server process closed code 1 and signal null
2020-08-07T15:41:43.570Z	d9691f0f-b896-4a65-8b9e-2182919131a0	ERROR	Invoke Error 	{"errorType":"Error","errorMessage":"connect ECONNREFUSED 127.0.0.1:8000","code":"ECONNREFUSED","errno":"ECONNREFUSED","syscall":"connect","address":"127.0.0.1","port":8000,"stack":["Error: connect ECONNREFUSED 127.0.0.1:8000","    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16)"]}

On all subsequent requests, PHP returns PHP Built-In Server HTTP error: Error: connect ECONNREFUSED 127.0.0.1:8000.

image

Vercel logs show:

🐘 Accessing juicyfx-php-test-nl5ugs3i9.vercel.app/api/index.php
🐘 Querying /api/index.php
2020-08-07T15:43:47.070Z	bf4f302d-3817-4f32-b291-e81deaf3274f	ERROR	🐘 PHP Built-In Server HTTP errored Error: connect ECONNREFUSED 127.0.0.1:8000
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16) {
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 8000
}

My temporary workaround is to use a single string with a simple glob pattern that vercel-php does seem to do okay with; in my case: excludeFiles: projects/**.

Glob patterns I've encountered this issue with:
!(file)
(fileA|fileB) (doesn't error, but appears to get parsed as a single exact filename, rather than a glob pattern)
**/*

Customizing php.ini

Will there be support for php.ini customization? I'm specifically looking to set session handler to redis store. Thank you.

URL rewrite feature

Hi,
Is there a "demo/example" on how to add URL "rewrite rule"?
Is Vercel PHP uses NGINX or APACHE?

Thank you

php with vercel

not sure what im doing wrong while following the steps listed

Here's a 3 min video of what i'm doing and the error im getting... im new to php and github, can someone please let me know where i go wrong?
https://youtu.be/_XMPR79AOgA

update sqlite

Feature Request

I'm considering deploying an app with a sqlite database that will be bundled during deployment. I see that the current sqlite library is quite old (3.7.17 released in 2013)

There has been quite a lot of changes since then. Is it possible to update the version of this library to a more recent one?

Not sure if I need any of the changes, but it makes me wonder :)

Composer scripts output not being saved

Bug report

Description

Composer scripts run perfectly (thanks!)

        "vercel": [
            "npm install",
            "npm  run prod"
        ]

However the build output (js/css) isn't available after the build is complete. If it helps, I'm using laravel mix

21:03:07.975 | > cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
21:03:20.083 | DONE  Compiled successfully in 10120ms3:03:20 AM
21:03:20.087 | Asset       Size  Chunks                    Chunk Names
21:03:20.087 | /css/app.css   8.47 KiB       1  [emitted]         /js/app-server
21:03:20.087 | /js/app-client.js    169 KiB       0  [emitted]         /js/app-client
21:03:20.087 | /js/app-client.js.LICENSE.txt  219 bytes          [emitted]
21:03:20.087 | /js/app-server.js    326 KiB       1  [emitted]  [big]  /js/app-server
21:03:20.087 | /js/app-server.js.LICENSE.txt  219 bytes          [emitted]
21:03:20.157 | 🐘 Running composer scripts [DONE]
21:03:28.993 | 🐘 Creating lambda
21:03:36.877 | Uploading build outputs...
21:03:40.526 | Build completed. Populating build cache...
21:03:48.266 | Uploading build cache [26.75 MB]...
21:03:48.921 | Build cache uploaded: 662.765ms
21:03:48.931 | Done with "api/index.php"

(apologies for the formatting on that)

however /css/app.css and /js/app-client.js return 404's when the site is loaded (website if I run npm run prod locally and commit the output to git: https://phase-blog-demo.now.sh/)

Extension: pdo_sqlsrv

Question

Hello sir, thanks for your great work, if i want to use now-php with pdo_sqlsrv extension, anyway to configure or not supported?

Access denied for user

Bug report

Description

Using the vercel-php runtime, I deployed my API on GoDaddy's domain but through Vercel's servers. As it is an API, I am trying to connect to one of my GoDaddy MySQL databases. I get the following error:

Warning: mysqli_connect(): (HY000/1045): Access denied for user 'secondissea'@'ec2-13-57-11-140.us-west-1.compute.amazonaws.com' (using password: YES) in ------------

'secondisea' is my database username, and this works locally, because I whitelisted on GoDaddy. After the '@' I am using is Vercel's hosting server. And this entire thing is a PHP error when I am trying to connect to the database.

How do I get rid of this error? Since vercel-php is made for API endpoints, there has to be a solution.

[now dev] Installed packages in `vendor`do not exists

At this moment my project has a .nowignore file to prevent the composer vendor directory from uploading to now.

When I run this same project with now dev I get an error because the vendor directory is not found. This makes sense because it is ignored.

This should however be resolved by either:

  • Also run composer install in now dev, but this seems to make it really slow.
  • Also copy the vendor directory during a development run. But how can that be done?

How to run just composer, with no PHP files (composer satis)

Question

I want to publish a private composer satis repository to now.sh

However, the project has no PHP files, I need to run composer install and vendor/bin/satis on now.sh in order to setup satis.

Can I use this project to do that and how would I go about doing that?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.