Use vercel/php runtime to run Laravel on Vercel Serverless Functions.
Copy these files to your project:
- vercel.json: Some required configs to run Laravel in serverless function.
- server.php: File that starts the app and it routes the assets.
- .vercelignore (Optional): Sets files and folders that should be ignored from the deployment process.
You can run additional commands during the Vercel build process by adding them to the "vercel" script in composer.json file.
If you need a more complex build system, you can use Github Actions to build and use vercel deploy
cli command. (Don't forget to disable git auto-deployments in the project settings)
Note
By default, vercel/php does not include the built assets to production source. The server.php file contains an logic to force to do this.
The vercel.json file contains some env variables necessary to run Laravel but you can change them, add more or define others in the project settings in Vercel dashboard.