Prerequisites :
- Php and Laravel knowledge
- Heroku user account
- Heroku toolbet (Heroku CLI)
- Git
Create the project
Any way you like, get your Laravel application initialized.
laravel new laravel-heroku
cd laravel-heroku
Add your Procfile
As per the documentation, By default, Heroku serves the files from the root index. So to tell Heroku to serve the app from public/
directory, you have to make a Procfile
.
web: vendor/bin/heroku-php-apache2 public/
Initialize the git repo
OK, our code is ready to go. Let's get it into git.
git init
git add .
git commit -m "Initial commit"
Create the Heroku app
Since you have the Heroku Toolbelt installed, you can create and modify your apps directly from the command line.
heroku create
output:
± heroku create
Creating app... !
▸ Invalid credentials provided.
heroku: Press any key to open up the browser to login or q to exit:
Logging in... done
Logged in as me@email.com
Creating app... done, ⬢ app-name-here
https://app-name-here.herokuapp.com/ | https://git.heroku.com/app-name-here.git
Add an APP_KEY
Generate a new key:
php artisan key:generate --show
Copy the output of that, and then run this command:
heroku config:set APP_KEY=the_key_you_copied_here
output:
Setting config vars and restarting ⬢ app-name-here... done, v3
APP_KEY: the_key_you_copied_here
Deploy your code to the Heroku app
With Heroku, you push new code to your site by pushing to the heroku git remote.
git push heroku master
output:
----> Launching... done, v3
http://app-name-here.herokuapp.com/ deployed to Heroku
Now it is deployed on heroku. And your laravel app is on http://app-name-here.herokuapp.com/
url.
Reference
Top comments (0)