Loading Adonis project with Laravel Valet

Hi All!
I have been working with Laravel and love using the Valet tool to quickly spin up local projects. I have installed my first AdonisJs project in my parked Valet directory but I wasn’t able to load the site like laravel projects. Would I need to adjust the ports in my Adonis .env file or is this not possible to do?

Right now my Adonis .env file has the port looking for PORT=3333. I tried setting it to 80 but still nothing when I went to theprojectname.test.

I am not sure how Valet works, so first you have to tell us that. Also, Laravel is PHP and AdonisJs is Node.js, so I don’t think, that PHP tools can works with Node.js application

I believe Valet starts up an Nginx server and uses the folder name to create url. So if I had a folder project1 it would create the url project1.test and link it to the folder. I cant see why this wouldn’t work for Adonis.

valet uses caddy, not nginx, but the same general principle applies.

Valet, however, is heavily intended to be used in front of PHP projects. So while you probably could write a custom driver to work with non php projects, you’d really be better off just manually configuring dnsmasq and optionally (though not strictly necessary) caddy/nginx/etc to reverse proxy a bunch of vhosts, which… at the end of the day is all valet really does.

It just abstracts away the manual config. You could, incidentally, just as easily acomplish it with MAMP or WAMP, and set up the appropriate http server config to point at your desired localhost:[port] for whatever app you’re wanting to respond on port 80.

Personally, I don’t see it as any sort of significant issue to go to the trouble so that I don’t have to provide a port number in the address bar, which is all that’d really give you :slight_smile:

It probably would be fairly trivial to replicate the functionality of laravel valet in node, specifically for node projects… dunno that the effort is really worth it though.

1 Like

Thank you so much for the information! I was wondering how Valet worked and was having a hard time finding out online.
Seeing as it sounds like a lot of work I will most definitely just use the localhost and port number.


The real “magic” behind laravel valet is the ability to use a fake top level domain (.localhost or whatever) and reference your local stuff as foo.localhost without having to go manually put entries into your hosts file and so forth…

you can accomplish the same by manually installing dnsmasq.

That of course is just one piece of the puzzle, because all it’ll accomplish is allowing [whatever-you-want].localhost domains to point to your local IP… then you’d also need the other parts, caddy to serve vhosts on that top level domain, in the case of node apps reverse proxying specific ports, in the case of php, pointing at the main entry point of the php application with php-fpm or whatnot…

If you absolutely must access your app without specifying a port, and with a custom domain, you could bind to port 80, and execute the adonis app with superuser privileges so that you can bind to port 80, and then add an entry in your hosts file (/etc/hosts on mac & linux, c:\Windows\System32\Drivers\etc\hosts on Windows) mapping your desired faux domain to your local machine, or anything in the 127.x.x.1 subnet, really…     localhost     myfakedomain.local 

Then assuming you have something handling port 80 on your local machine, and that something is what you want it to be, you can just hit http://myfakedomain.local in your browser, no port number, nothing else required.

Valet is nifty, and really handy especially if developing many applications simultaneously, but at the end of the day, it’s just managing some config so you don’t have to do so manually, if it’s really useful, it wouldn’t be difficult to replicate without valet. In my experience though, it’s almost always easier to just specify the port number directly in the browser and point at http://localhost:[port] :wink:

1 Like