vercel-community / php

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

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

downloaded index.php instead of load the app

reregin opened this issue Β· comments

hi, i'm a total beginner and i want to deploy my laravel app on vercel. i was planning to connect it to Oracle ATP to use it as the database. but i'm totally stuck on the vercel. when i open the website, it downloaded the index.php instead of load the app.

this is how my project looks like

project
β”œβ”€β”€ .vercel
β”‚   β”œβ”€β”€ ...
β”œβ”€β”€ .vercelignore
β”œβ”€β”€ api
β”‚   └── index.php
...
β”œβ”€β”€ public
β”‚   β”œβ”€β”€ .htaccess
β”‚   β”œβ”€β”€ favicon.ico
β”‚   β”œβ”€β”€ index.php
β”‚   └── robots.txt
...
β”œβ”€β”€ vercel.json
└── vite.config.js

i already included functions and routes on my vercel.json like this:

"functions": {
        "api/*.php": {
            "runtime": "vercel-php@0.6.0"
        }
    },
    "routes": [
        {
          "src": "/(.*)",
          "dest": "/api/index.php"
        }
    ],

and i point the /api/index.php to my original index.php like this:

<?php

// Forward Vercel requests to normal index.php
require __DIR__ . '/../public/index.php';

but it just downloaded the /api/index.php instead. do anyone has any ideas what happened? and are they more informations that i could give to help?

it's seems like the htaccess issue,
have you tried to remove the htaccess firest?

what do you mean by htaccess firest?

I have this same issue for vanilla PHP with no build or framework. I don't know what to do again. In my case, I don't have any .htaccess file

vercel.json

{
  "functions": {
    "api/*.php": {
      "runtime": "vercel-php@0.6.1"
    }
  }
}

api/index.php

<?php

// Forward Vercel requests to normal index.php
require __DIR__ . '../index.php';

Here is my project structure

project
└── api
     └── index.php
└── css
└── fonts
└── images
└── js
└── index.php
└── other_php_pages.php
└── vercel.json

@solamichealolawale Can you show me repository and public vercel URL?

I was fixing other bug, now it's time for your app. :-)