4 ms·
Exactly what I came here to say. You don't sprinkle URLs throughout your codebase, as the OP apparently assumes one would normally do. You create a single clas
by theli0nheart 5y ago
Exactly what I came here to say.
You don't sprinkle URLs throughout your codebase, as the OP apparently assumes one would normally do. You create a single class (or something similar) which abstracts the API calls. If the endpoint changes, you change it in one place.
I honestly don't see how this solution makes this easier. If anything, I feel like it makes things more complicated and harder to understand.
- dhbanes 5y agoThe endpoint URL should probably be stored in the environmental variable file.
- theli0nheart 5y ago> The endpoint URL should probably be stored in the environmental variable file. As I mentioned, if the endpoint changes, you change it in one place. Storing your endpoint URLs in an env file is your personal preference, but that's all. Should has no place here. It doesn't matter whether it's an environmental variable file, a YAML configuration, a JSON file, or a secure remote KV-store. Barring low water marks, it doesn't really matter where you store your configuration—just make sure to store it in one place.
- that_guy_iain 5y agoTo be fair it does seem to fit the way I think Laravel applications are built.