While I mostly build with WordPress, I’m going to be working with a few projects coming up that will require a more custom application approach. So, I’m (most likely) going to use Laravel. Step one for any project is to get set up locally. If you’re like me, you like keeping things organized and try to keep things from getting redundant.
For local development, this means using one solution as best I can to make getting setup and going on new projects as simple as possible. While I’ve used ScotchBox, VVV and WP Local Docker before, I’m using Local by Flywheel all the time now. It’s easy to get rolling, consistent for our team to use, and if you want to try out something like Laravel or Craft, you can easily sub those frameworks in.
Here’s how I’m doing that with Laravel…
Adding a site to Local
First, you set up a site like you normally would on Local:
- Click that big “+” button
- Give the site a name
- Select the environment your want (the Preferred nginx will work just fine with Laravel)
- Enter your WP username and password (these will be deleted shortly)
- Click add site.
You can also add in an SSL certificate quickly if you like. Is usually do that, since all websites and apps will be secured when launched to production.
Install Laravel and a New Laravel Project
This step requires that you have Composer installed globally on your system. You can find instructions for that here. Do that first.
Once Composer is installed, you can follow the installation instructions to install Laravel globally as well. Those are found here, but the basic command will be:
composer global require laravel/installer
Once you have Larvel installed globally you can do the following:
- From from the Local app, right click on your new Laravel site, and select “Open Site SSH” (you’ll need to run all Laravel commands through SSH as well)
- Delete the current
appfolder (either in your Finder/Explorer window or via command line)
- Then run the following command from the new site directory:
laravel new app
This will create a new Laravel project within the
app directory, and will include the public folder where Local will normally look for it.
At this point, you should be able to click “View Site” in the Local app, and it should show you the Laravel welcome page at htts://laravel.local, for instance.
Connecting the Database
.envfile, you can replace the following credentials (assuming you haven’t changed the default Local by Flywheel settings:
DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=local DB_USERNAME=root DB_PASSWORD=root
The above will connect to the Local DB. If you open your database using SequelPro, you can go in and delete the standard
Finally, you can see your Laravel database with the command:
php artisan migrate
After running this command, you can refresh your database in SequelPro and see the default seeded database.
And just like that, you’re off and running with Laravel on Local by Flywheel!