Laravel Valet TDL per project- is it possible?

Published 5 months ago by vladimir

Is it possible to use Valet TDL per project? Saying that i mean if i have ~/Sites/Blog and ~/Sites/Todo and i want to have blog.dev and todo.app

Is that possible?

goatshark

This probably defeats your purpose, but at first glance, if you are willing to keep them in separate base directories, you might be able to look at ~/.valet/conf.json . . . maybe add another entry in there. I haven't tried this....yet.

vladimir

it seems that its globally configured when i am looking at that json

{
    "domain": "dev",
    "paths": [
        "/Users/vladimir/Projects"
    ]
}

if there was:

{
    "domain": {
        "name" : "dev",
            "paths": [
            "/Users/vladimir/Projects"
        ]
    }

}

Then i think would be worth of trying. I dont see in first case who i could assign new domain/path. I tried adding one more record but it brokes existing and valet is not working.

Snapey
Snapey
5 months ago (579,905 XP)

assuming you mean tld not tdl

why does it matter, your sites should be developed agnostic of the domain name?

vladimir

Thanks for the comment but it's useless. Why bother to comment?

willvincent

It's not useless at all. He asked (and you didn't answer)

WHY do you feel you need to do this?

What actually useful purpose would this serve?

It's entirely outside of the scope of what valet aims to accomplish, so expecting valet to support it seems somewhat foolish to me, really...

Now.. that said. You could drop an nginx server config file into ~/.valet/Nginx configure the entry in your hosts file /etc/hosts and restart nginx to force it to work. But without rewriting valet's code you're unlikely to get it to work in any sort of automated manner, nor should it really as -- like @Snapey alluded to, there's no real value there -- the site should be agnostic of what domain it lives at, aside maybe from something in the site's config or .env files.

Chris1904

Because if we knew your reasoning we could think of an alternative as well. Why not answer his question instead of giving a sassy answer?

vladimir

alright, the company i am working for has everything depending on the domain name and its local.xxx.com stage.xxx.com etc... Other projects i am working on could go with .dev He did not ask the reason, he actually did, with mentioning that my sites should be developed agnostic of the domain name. How they should or not should be is not always on developer to decide you would agree? I am not answering questions like that. If he would asked as @Chris1904 did i would gladly provide the answer as i did now, cause i understand why he is asking me, without giving me advise that my site should be developed like this or that. I am not asking how my sites should be developed as you probably noticed. I am asking pretty clear and need help. So one more time, i have no influence on how site is developed, i am coding together with 50 other developers on project and i would like to get rid of vagrant and to use valet.

vladimir

Yeah site is not developed on Laravel, and heavily depends on env files. That is why i would like to know if its possible to have valet to serve .dev and .com or any other tld at the same time. I dont see why is entirely of the scope of what valet aims to accomplish. @willvincent as i get it Valet is a simple one step get ready dev enviroment on mac. It works with several poplar framework and it can be customized to serve any tld. But as i understand its only one tld per time. Which i dont see why would be wrong having it to serve multiple tld at time? What in that of scope? I dont see it

willvincent

@vladimir Right, valet is only designed to handle a single tld, because in 99% of cases that's all anyone should need.

However, just because it's limited that way does not mean you cannot leverage the same infrastructure, nginx, php, and mysql that valet uses. The nginx config loads virtualhost config from ~/.valet/Nginx so all you'd need to do is add config file(s) there, and then define your host names in the hosts file.. as you'd do with a normal MAMP setup... as I said. ;)

Your only other option, with valet, would be that you might be able to force it to work with custom valet drivers, the api allows for mutating the uri, which you might be able to leverage to alter the domain...

Honestly though, if you're working with a team that large you should be using vagrant, or docker or something otherwise the chances of running into "it works on my machine" issues is extremely likely. With a team that size you definitely want to ensure everyone has as close to identical environments as possible. In a perfect world your dev environment should always match that of the production environment -- in terms of specific versions of each piece of the stack, plugins enabled, memory allotted, etc. Tools like vagrant and docker make such things pretty painless across large teams. Avoid/ignore them at your own peril I guess. :)

Snapey
Snapey
5 months ago (579,905 XP)

Don't forget its not just about the nginx config

More importantly, it needs dnsmasq to intercept the domain and route it to localhost (*.dev in most cases).

But hey, Why bother comment ?

vladimir

@Snapey i apologize for my harsh comment. I misunderstand your intention and missed to see what is behind your comment. Tho, you are right that how it should not be developed, and i could not agree more. But as i said, its not always on developer to decide the course. Thank you. @willvincent thank you for a time and long explanation of your thoughts on this. Just to say, we do work with Vagrant, but As you know, Valet will spend much less resources and i want to see how it would be. For me personally its a just line of learning by trying to make something crossed my mind, and listening to other respectable people opinions.

willvincent

@vladimir if vagrant is too resource heavy for you, you really ought to take a look at docker.

vladimir

@willvincent I am heavy docker user as well for other projects. But as i said, its not me who decides what and how things will developed and deployed. Thanks for the advise tho :)

Sign In or create a forum account to participate in this discussion.