Note: This post has been updated to work with the new version of Local. I’ll try to keep things updated if the development environment changes in the future. (last updated: Feb. 18, 2020)
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…
First, you set up a site like you normally would on Local:
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.
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
Note: You need to run the above command (and all
php artisancommands) from the Local machine. Do do this, in the Local app, right click on your new Laravel site, and select “Open Site Shell”. If you change to the
laravel/appdirectory, you’ll be able to run these commands.
Once you have Larvel installed globally you can do the following:
cd ../..most likely) .
appfolder (either in your Finder/Explorer window or via command line)
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. If you’re getting a 502, 404, or some other error, you may need to restart the server:
.envfile, you can replace the following credentials (assuming you haven’t changed the default Local by Flywheel settings:
DB_CONNECTION=mysql DB_HOST=localhost DB_PORT=3306 DB_SOCKET="/Users/yourusername/Library/Application Support/Local/run/lkIEkdiowIEkmd/mysql/mysqld.sock" 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 seed your Laravel database with the command:
php artisan migrate
And just like that, you’re off and running with Laravel on Local by Flywheel!