Problems activating your account? Send notification email to: [email protected]
Host4Fun Budget VPS Hosting
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tutorial] Deploy git to vercel.
#1
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

composer create-project laravel/laravel laravelapp

Make Updates to or customise to it.

create these files in your root directory

Create this file
api/index.php
.vercelignore
vercel.json

Please note there is a dot file.

Now add these codes to their files

api/index.php

PHP Code: (Select All)
<?php

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

.vercelignore

PHP Code: (Select All)
/vendor 

vercel.json
PHP Code: (Select All)
{
 
   "version"2,
 
   "functions": {
 
       "api/index.php": { "runtime""[email protected]}
 
   },
 
   "routes": [{
 
       "src""/(.*)",
 
       "dest""/api/index.php"
 
   }],
 
   "env": {
 
       "APP_ENV""production",
 
       "APP_DEBUG""true",
 
       "APP_URL""https://yourproductionurl.com",

 
       "APP_CONFIG_CACHE""/tmp/config.php",
 
       "APP_EVENTS_CACHE""/tmp/events.php",
 
       "APP_PACKAGES_CACHE""/tmp/packages.php",
 
       "APP_ROUTES_CACHE""/tmp/routes.php",
 
       "APP_SERVICES_CACHE""/tmp/services.php",
 
       "VIEW_COMPILED_PATH""/tmp",

 
       "CACHE_DRIVER""array",
 
       "LOG_CHANNEL""stderr",
 
       "SESSION_DRIVER""cookie"
 
   }


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

project > settings > git > Connected Git Repository



Now with every push, your site will auto-deploy.

Now you need to add apps environment variables


project > settings > git > Environment Variables


From your command line inside the local dev app run
php artisan key:generate --show

This will create a key,(and display) for your app and add these lines as env in vercel

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.

DB_CONNECTION=mysql
DB_HOST=**
DB_PORT=3306
DB_DATABASE=****
DB_USERNAME=**
DB_PASSWORD=**

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.
Reply
#2
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-lara...3917cfc914
Reply
 


Forum Jump:


Users browsing this thread: 1 Guest(s)

Sponsors: VirMach - Host4Fun - CubeData - Evolution-Host - HostDare - Hyper Expert - Shadow Hosting - Bladenode - Hostlease - RackNerd - ReadyDedis - Limitless Hosting


About Post4VPS

Post4VPS is a forum/destiny where you can Delploy Your Free VPSs just by the Power of Posts.

We Provide VPSs of many locations like Germany,US,Canada,France,London,etc.

We also Provide VPSs of Both Linux and Windows OS.