A blog probably of interest only to nerds by John Morton.

27Sep2017

A Check­list When Tran­si­tion­ing from MAMP to Valet

I have used MAMP for local devel­op­ment for a long time. Sev­er­al peo­ple I know through the Craft CMS Slack group have pro­fessed the ben­e­fits of [Lar­avel Valet](https://​lar​avel​.com/​d​o​c​s​/​5​.​5​/​valet Lar­avel Valet doc­u­men­ta­tion’) so I decid­ed to give it a spin as an alter­na­tive to MAMP.

When it comes to Craft CMS there is a built-in dri­ver that allows Valet to serve a Craft site with­out any addi­tion­al con­fig­u­ra­tion. You just place your Craft site in the appro­pri­ate direc­to­ry, set up your data­base con­nec­tion, and it just works.

There is a rea­son for this post though. I did encounter an issue with tran­si­tion­ing a site from MAMP to Valet.

I have typ­i­cal­ly used a direc­to­ry I’ve named pub­lic” as my pub­lic-fac­ing direc­to­ry on Craft sites. In Craft 2, nam­ing that direc­to­ry pub­lic” was the default. In the upgrade to Craft 3 the default pub­lic fac­ing direc­to­ry is no longer pub­lic”; it has been changed to web” instead. Out of famil­iar­i­ty I have kept my Craft 3 sites using pub­lic” as my pub­lic-fac­ing direc­to­ry. The issue is that Lar­avel Valet expectes web” and not pub­lic” and will throw an error if you don’t fol­low the default nam­ing convension.

You could sim­ply write a [cus­tom Valet dri­ver](https://​lar​avel​.com/​d​o​c​s​/​5​.​5​/​v​a​l​e​t​#​c​u​s​t​o​m​-​v​a​l​e​t​-​d​r​ivers Cus­tom Valet Dri­vers doc­u­men­ta­tion’) to spec­i­fy your choice of names but I didn’t want to do this. (If you’re inter­est­ed in doing this, check out this [Craft3ValetDriver.php Gist](https://​gist​.github​.com/​C​h​r​i​s​e​d​m​o​/​a​5​a​a​c​b​219​c​b​5​b​05​a​01613​e​50​f​3​b​4402b Craft3ValetDriver.php by Chris Mous­dale’) by Chris Mousdale.) 

If the Craft 3 default is chang­ing to web” I want­ed to change that as well in my work­ing environment.

The prob­lem this pre­sent­ed though was that it’s more than sim­ply chang­ing the name of one direc­to­ry. That is only the first step. This post is real­ly about what else you need to do to make this change cas­cade through­out the rest of your workflow.

Things to con­sid­er about changing.

In addi­tion to chang­ing the name of your pub­lic-fac­ing direc­to­ry for Valet, there are some oth­er places you need to check as well.

  1. Have you ref­er­enced any­thing in your .git­ig­nore file that is ref­er­enc­ing pub­lic” that you need to change to web”?
  2. In my case I had 2 exter­nal servers, a stag­ing serv­er and a pro­duc­tion serv­er. Both of these servers had to be recon­fig­ured to serve pub­lic-fac­ing files from the new web” direc­to­ry instead of pub­lic”. If you push your new local code to your servers, they need to look in the cor­rect web” direc­to­ry too.
  3. If you use any scripts (like [these](https://​github​.com/​n​y​s​t​u​d​i​o​107​/​c​r​a​f​t​-​s​c​ripts nys­tu­dio107/craft-scripts on Github’)) to auto­mate the back­up of assets on your Craft site they are most like­ly using your pub­lic-fac­ing direc­to­ry name. You need to update these as well.

With those things changed, I was all set. This site’s local dev envi­ron­ment is now using Lar­avel Valet.