Hi Matteo,
Thank you for your feedback. Upon further investigation on error I found the error has been occurring since Valet didn't support Moodle. I found a link to Valet support for Moodle. https://gist.github.com/sandeepgill/8aff4849bdbb4f7ac0aced72496f2183 and that made it work.
Again thank you for your valued feedback