1. https://github.com/vercel-community/php?tab=readme-ov-file find Vercel Deploy button to auto create git branch and Vercel project. Example project name: test-vercel
  2. git clone the repository
  3. cd to test-vercel then `composer create project laravel/laravel ./example-app
  4. copy all files in example-app to test-vercel
  5. update the api/index.php to
<?php
/**
 * Here is the serverless function entry
 * for deployment with Vercel.
 */
require __DIR__.'/../public/index.php';
  1. Update vercel.json
{
    "builds": [
        { "src": "/api/index.php", "use": "[email protected]" },
        { "src": "/public/**", "use": "@vercel/static" }
    ],
    "routes": [
        {
            "src": "/(css|js)/(.*)",
            "dest": "public/$1/$2"
        },
        {
            "src": "/(.*)",
            "dest": "/api/index.php"
        }
    ]
}
# Remove "functions" : {...} block
  1. Vercel project > Settings > Output Directory = public
  2. Copy laravel .env into vercel’s Environment Variable.
  3. Configure to connect Postgres DB Xata.
  4. Encounter error not able to generate laravel.log. No solution.
  5. If getting deployment error php: error while loading shared libraries: libssl.so.10: cannot open shared object file: No such file or directory just “Redeploy” without Build cache in Vercel.
  6. Vercel’s Laravel API route has to be /api/api/your-api-name/etc example: https://test-vercel-git-main-kl-game-centers-projects.vercel.app/api/api/admin/test?v=1. Due to vercel.json route defined to initial route in api/index.php which only then routes to laravel’s api.php containing api prefix.