![]() |
[Tutorial] Deploy git to vercel. - Printable Version +- Post4VPS Forum | Free VPS Provider (https://post4vps.com) +-- Forum: Web Technology & Internet (https://post4vps.com/Forum-Web-Technology-Internet) +--- Forum: Web Development (https://post4vps.com/Forum-Web-Development) +--- Thread: [Tutorial] Deploy git to vercel. (/Thread-Tutorial-Deploy-git-to-vercel) |
[Tutorial] Deploy git to vercel. - debjit - 04-03-2021 I am working on a project on a Blood Donation Diary app. After completing the project I needed to deploy my project to see its behaviour in the live environment. I have limited free option. Here I am sharing how I managed to deploy to vercel with MySQL database support. Vercel is a pass provider. You can deploy non-commercial projects for free here with up to 100GB bandwidth and no storage. To start you need the following things- 1 . Git account 1.a. How to add the remote repo to a local dev environment 2. Vercel Account 3. Remote enabled MySQL database access. Here I am demonstrating how to make work with the laravel app. Create a laravel app using composer Code: composer create-project laravel/laravel laravelapp Make Updates to or customise to it. create these files in your root directory Create this file Code: api/index.php Please note there is a dot file. Now add these codes to their files api/index.php PHP Code: <?php .vercelignore PHP Code: /vendor [font=Monaco, Consolas, Courier, monospace]vercel.json[/font] PHP Code: { Note: you can get all kind of info on the supported framework using this vercel PHP here https://github.com/juicyfx/vercel-php Now create and push to your git. (I am assuming you know how to do that. Google if you can't.) Now you need to create a project into vercel and add a GitHub account with vercel. Now add GitHub repository to your project here Code: project > settings > git > Connected Git Repository Now with every push, your site will auto-deploy. Now you need to add apps environment variables Code: project > settings > git > Environment Variables From your command line inside the local dev app run Code: php artisan key:generate --show This will create a key,(and display) for your app and add these lines as env in vercel Code: APP_KEY = ***** You can add your MySQL details here or just hardcoded to the app, I have found env not so reliable. So I have to hard code it. Please note hard coding to GitHub repo is not recommended and it is exposed. you can do that inside your config/database.php file. Code: DB_CONNECTION=mysql Replace ** with their values. You have to migrate your MySQL database ahead of time because vercel does not provide a terminal. So here is how I did use vercel to check on my development in a production environment. I am using vercel for 2 days now. I will update as I learn more. Have you used this tutorial to get a free hosted website for yourself? please share. I will update with another free PostgreSQL service. RE: [Tutorial] Deploy git to vercel. - debjit - 04-08-2021 So I made an article on medium and it's free to read. So please give it a try if you going to deploy your app on live or production and check how they run. It's more advance than this tutorial. https://debjit012.medium.com/deploy-laravel-on-vercel-with-database-image-storage-and-email-2d3917cfc914 |