Deploy Laravel (w/ Laravel Mix) Web App in 5 Min on Heroku.

Debjit Biswas
2 min readApr 18, 2022

--

I am using this LinkAce fork in this tutorial. All other Laravel Default should run as-is. For more installation please follow my Other Guide

I was installing an open-source project on Heroku and found Laravel Mix is not working.

So I have time in hand and make it work. It is pretty simple and no prior knowledge is needed. Follow the steps.

I am using free hobby dyno and pgsql for the database.

Step 1

Update builder pack from Settings > Builderpacks with these two

  1. heroku/nodejs
  2. heroku/php

Note order is necessary for a successful build, drag your Nodejs to the top if PHP already exists.

Step 2

Update package.json file. Add these lines inside your script section.

 “postinstall”: “npm run production”,

Here is my whole script looks like

"scripts": {
"postinstall": "npm run production",
"dev": "npm run development",
"development": "mix",
"watch": "mix watch",
"watch-poll": "mix watch -- --watch-options-poll=1000",
"hot": "mix watch --hot",
"prod": "npm run production",
"production": "mix --production",
"test": "npm run production"
}

Step 3

Add Procfile to your app

web: vendor/bin/heroku-php-apache2 public/

Step 4. Update your “Config Vars” for deployments

YARN_PRODUCTION : False

Now deploy your app and your laravel mix will run, have fun.

The software I have tested is working with this method is:

LinkAce

For LinkAce you must run these two command from the Heroku terminal to start and use my repo it will bypass the installation file.

php artisan migrate
php artisan registeruser

Reference

--

--

Debjit Biswas

I am a Web Developer. I love to do experiments and share my journey with you. Please follow me for more posts. Go to https://debjit.in for more info.