/ laravel

Laravel & Voyager Quick Setup

I am currently working on a side project that hopefully will render this post useless in the near future, but, for the time being, this is a simple copy & paste recipe for anybody who wants to setup a quick Voyager enabled Laravel site on their machine.

I presume that whomever is reading this, at least has the basics setup and can run Laravel on their computer. I am running on a Mac, but, this should work on any *nix like command line interface.

Start a new Laravel Project

Run this command on the terminal:

laravel new ProjectName

Enable Voyager

Jump into the directory and load in Voyager:

cd ProjectName
composer require tcg/voyager

Create a database

Enter mysql:

mysql -u root -p

Fill out your password when requested and then, when in Mysql prompt:

create database ProjectNameDB;
exit;

Fix your .env file

Using laravel new allows you to already have a .env file partially setup, all you have to do is edit the file and fix your database details:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=ProjectNameDB
DB_USERNAME=root
DB_PASSWORD=password

Look for the section above and fill out accordingly

Install Voyager

Now you are setup to install Voyager:

php artisan voyager:install

Create admin user

Finally, we need to create out admin user to access Voyager, we will create the standard user for Voyager which is admin@admin.com

php artisan voyager:admin admin@admin.com --create

Answer the questions that follow and you are home free.

(optional) Valet link your site

Valet is a great way to get your sites up and running on your box. It allows you to have an internal domain to avoid you from fiddling around with your /etc/hosts file and messing around with boring Apache or Nginx config files.

If you are not familiar with it, have a look here and be changed. If you don't care for that, then just ignore the rest of this blog post and enjoy a happy development.

valet link projectname

By default that will create a projectname.test site on your local machine. I've had some trouble using the .test extension so I've changed mine to .work

This can be done by running this command:

valet domain work

From now on, all your local domains will be .work

Finally, if you need to run your site on HTTPS (which I would always say is a good idea), you can easily do this with valet by running:

valet secure

(please note that I am running all these commands form my project root)

Finally, if you've come this far, remember to edit you .env file so that you point your laravel to your new domain:

APP_URL=https://projectname.work

Search for this and update it accordingly.

Gregory Brown

Gregory Brown

Baker, cake designer, cook and just by chance, a full featured developer that is passionate about technology.

Read More