Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

增加vercel部署支持 #369

Open
lopins opened this issue Oct 6, 2024 · 2 comments
Open

增加vercel部署支持 #369

lopins opened this issue Oct 6, 2024 · 2 comments

Comments

@lopins
Copy link

lopins commented Oct 6, 2024

No description provided.

@wdssmq
Copy link
Contributor

wdssmq commented Oct 6, 2024

没听说过 vercel 能跑 PHP →_→

@lopins
Copy link
Author

lopins commented Oct 6, 2024

可以的,php5-php8都可以

  • 通过vercel.json自定义php版本

[email protected] - PHP 8.1.x
[email protected] - PHP 8.0.x #默认
[email protected] - PHP 7.4.x

  • vercel.json
{
    "functions": {
      "api/*.php": {
        "runtime": "[email protected]"
      }
    },
    "routes": [
      { "src": "/(.*)",  "dest": "/api/index.php" }
    ]
  }
  • /api/index.php
<?php
$file= __DIR__ . '/..'.$_SERVER["PHP_SELF"];

if(file_exists($file))
{
   return false;
}
else
{
    require_once __DIR__ . '/../index.php';
}
#echo $_SERVER["PHP_SELF"];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants