WEBVTT

00:00:00.000 --> 00:00:07.999
<v Joel>Welcome to No Compromises. A peek into the mind of two old web devs who have seen some things. This is Joel.

00:00:08.000 --> 00:00:09.999
<v Aaron>And this is Aaron.

00:00:16.000 --> 00:00:23.999
<v Joel>Aaron, thanks for joining me here. I would like to discuss a recent PR in public and just have a chance to debate it a little bit more.

00:00:24.000 --> 00:00:32.999
Because I seem to recall in a code review, I think I was reviewing your pull request, and I didn't really care. Like I didn't think, "Oh, this is terrible."

00:00:33.000 --> 00:00:36.999
But I'm like, "Why did you do this?" And I made an offhand comment, and you're like, "Yeah, I disagree." I'm like, "You know what?

00:00:37.000 --> 00:00:39.999
That'll be a good podcast topic." So here we are.

00:00:40.000 --> 00:00:40.999
<v Aaron>Okay.

00:00:41.000 --> 00:00:52.999
<v Joel>So the scenario to set up what I had observed in the PR that I was commenting on was that you had added a bunch of values to our phpunit.xml file.

00:00:53.000 --> 00:01:00.999
And these were keys that are also specified in the .env.example file, right? And so, it doesn't matter what they're for,

00:01:01.000 --> 00:01:02.999
but they're for talking to an external service.

00:01:03.000 --> 00:01:06.999
<v Aaron>Yeah. Well, and before you go on too far, let's make sure when we say it doesn't matter what they're for.

00:01:07.000 --> 00:01:15.999
The .env locally is filled up of two different things, right? The .env file. It's filled up of workflow control and credentials.

00:01:16.000 --> 00:01:16.999
<v Joel>Okay.

00:01:17.000 --> 00:01:19.999
<v Aaron>So workflow control, I mean, things like is this enabled or is it not enabled?

00:01:20.000 --> 00:01:20.999
<v Joel>Oh, sure.

00:01:21.000 --> 00:01:26.999
<v Aaron>Are we in debug mode? What database do we even... Like, what connection do we pick? Not the credentials, but what connection?

00:01:27.000 --> 00:01:32.999
So it's all workflow. And then there's a second reason for it, which is credentials. Like API keys, passwords, things like that.

00:01:33.000 --> 00:01:33.999
<v Joel>Yeah.

00:01:34.000 --> 00:01:38.999
<v Aaron>So, I just want to make sure that we bring those up because I think that might be the core of some of the things here too.

00:01:39.000 --> 00:01:45.999
<v Joel>Oh, okay. All right, I'm prepared to be wrong about this, but... So these were credentials, right? These were things that you would use

00:01:46.000 --> 00:01:58.999
to talk to another third-party or some other external system. And the ones you had added were actually things I had coded in a previous PR,

00:01:59.000 --> 00:02:07.999
and I did not add them to the phpunit.xml. But then I believe what happened is you were working on this code, your tests were passing,

00:02:08.000 --> 00:02:16.999
then you ran the whole suite, like a good developer, and some tests failed related to these keys that I had done in the previous PR.

00:02:17.000 --> 00:02:22.999
And you're like, "Ah, Joel, blah blah blah," and then you added this to the phpunit.xml, and then your tests passed, and you moved on. Is that?

00:02:23.000 --> 00:02:23.999
<v Aaron>Yep.

00:02:24.000 --> 00:02:32.999
<v Joel>Okay. And my contention was like, "Aaron, whenever somebody adds something to their projects, .env example,

00:02:33.000 --> 00:02:38.999
it is your responsibility as a developer to copy that into your .env," right? Like that's part of-

00:02:39.000 --> 00:02:39.999
<v Aaron>Absolutely.

00:02:40.000 --> 00:02:40.999
<v Joel>You agree with that?

00:02:41.000 --> 00:02:41.999
<v Aaron>Yep, absolutely.

00:02:42.000 --> 00:02:45.999
<v Joel>Okay. Good, then I'm right.

00:02:46.000 --> 00:02:47.999
<v Aaron>No, we didn't go all the way through.

00:02:48.000 --> 00:02:54.999
<v Joel>I'll keep going. All right, so defend yourself and explain it to me because I maybe see where you're going, but-

00:02:55.000 --> 00:02:56.999
<v Aaron>"Okay. Defend yourself."

00:02:57.000 --> 00:03:04.999
<v Joel>Let me say this. If you had copied that .env example to your .env, your tests would have passed. Correct?

00:03:05.000 --> 00:03:13.999
<v Aaron>Yeah, your tests in my suite would have passed if I copied the .env.example files or line over that I honestly forgot. Did not notice.

00:03:14.000 --> 00:03:14.999
<v Joel>Okay.

00:03:15.000 --> 00:03:15.999
<v Aaron>Correct.

00:03:16.000 --> 00:03:16.999
<v Joel>All right, so-

00:03:17.000 --> 00:03:20.999
<v Aaron>But now I'm going to take it over now here because I'm glad I didn't.

00:03:21.000 --> 00:03:26.999
I'm glad I didn't do that because that is the reason I still agree with what I did. And the reason is because-

00:03:27.000 --> 00:03:27.999
<v Joel>Of course you do.

00:03:28.000 --> 00:03:29.999
<v Aaron>Well, yeah, because we talk about... remember it was credentials.

00:03:30.000 --> 00:03:30.999
<v Joel>Yes.

00:03:31.000 --> 00:03:36.999
<v Aaron>So, when we work with Stripe, we put in something in our phpunit.xml. We're like, "Stripe key do not use."

00:03:37.000 --> 00:03:37.999
<v Joel>Right.

00:03:38.000 --> 00:03:44.999
<v Aaron>So we know that there's a key in there and it hits. I don't remember what was in your .env.example, but maybe it was like, "Do not use,"

00:03:45.000 --> 00:03:51.999
or maybe it was like some credentials that would have worked for yours, or whatever. Well, I don't know what they were, but even if I had copied them over,

00:03:52.000 --> 00:03:58.999
it would have probably hidden the fact that I wanted to at least zero out the API key credential or something like that.

00:03:59.000 --> 00:04:06.999
And if there wasn't an API key or credential, then at least the hostname. Because I want to make sure my tests never accidentally use my .env locally

00:04:07.000 --> 00:04:11.999
to load up my test development .environment and hit things third-party.

00:04:12.000 --> 00:04:12.999
<v Joel>Sure.

00:04:13.000 --> 00:04:19.999
<v Aaron>So, while I should have copied over to .env.example, the fact that I didn't showed me that there was tests that would hit those. Whether or not they

00:04:20.000 --> 00:04:28.999
would actually call out I don't know, but they were dying because they were missing those keys. So I put them there to basically say that I wanted to stop this.

00:04:29.000 --> 00:04:35.999
Now, when I think about it, I think I did it wrong in another way. And I'll tell you how so that you can feel happy here.

00:04:36.000 --> 00:04:36.999
<v Joel>Thank you.

00:04:37.000 --> 00:04:38.999
<v Aaron>There was like four or five keys. What I should have done-

00:04:39.000 --> 00:04:41.999
<v Joel>I'm looking at it, there are seven.

00:04:42.000 --> 00:04:48.999
<v Aaron>Whatever. So, what I should have done is copy over from the .env.example from my local copy when I first noticed it.

00:04:49.000 --> 00:04:56.999
That's what I should have done. Then I should have added in one key to make sure that they could never hit the external world in the phpunit.xml

00:04:57.000 --> 00:05:06.999
<v Joel>All right. So, I'm going to push back a little bit. Because I agree in principle with everything you said, but I think it might not completely have

00:05:07.000 --> 00:05:15.999
been the way you're describing it. Because there was, let's call the service... Let's say Stripe because Stripe is something people know about.

00:05:16.000 --> 00:05:26.999
So, I had a key in there called Stripe Host that was some invalid URL blah blah blah. Stripe isn't really a great example because this-

00:05:27.000 --> 00:05:34.999
<v Aaron>But it doesn't matter. Third party, like insurance company. We're hitting insurance company, and you had a URL for insurance company API, right?

00:05:35.000 --> 00:05:45.999
<v Joel>Yeah. Okay, so all of the keys in here, the ones that you added, that I did not choose to put in the phpunit.xml, were not credentials.

00:05:46.000 --> 00:05:52.999
They were like port numbers, and they were like configuration. Like, this is the location ID It's going to look up.

00:05:53.000 --> 00:05:53.999
<v Aaron>Yeah, absolutely.

00:05:54.000 --> 00:05:55.999
<v Joel>But you still feel like that is something that-

00:05:56.000 --> 00:06:00.999
<v Aaron>No, those are workflows. Those are configuration or workflow. That's what I'm saying. I would have copied over

00:06:01.000 --> 00:06:04.999
all seven from that example to my .env.

00:06:05.000 --> 00:06:05.999
<v Joel>Okay.

00:06:06.000 --> 00:06:14.999
<v Aaron>Then I should put one .env in PHPunit.XML, finding that host and making sure was something crazy. Because remember, we might use this locally,

00:06:15.000 --> 00:06:23.999
and so locally the .env we might actually make a real host. So, if we don't put something in phpunit.XML to make it a fake host and one of our tests runs,

00:06:24.000 --> 00:06:25.999
it'll hit that real host.

00:06:26.000 --> 00:06:29.999
<v Joel>Okay. I did have the hostname in there already as fake, so I was right.

00:06:30.000 --> 00:06:36.999
<v Aaron>Right. But what if I wanted to use it in real life locally in my-

00:06:37.000 --> 00:06:37.999
<v Joel>Okay.

00:06:38.000 --> 00:06:41.999
<v Aaron>That's what I keep saying. It's like when I configure those properly, it would be working for my development environment,

00:06:42.000 --> 00:06:44.999
and I run my tests. And if a test was configured to hit that, it would hit that.

00:06:45.000 --> 00:06:53.999
<v Joel>Well, but just to clarify. I'm saying I did put the one entry in phpunit.xml that talks, that's the hostname.

00:06:54.000 --> 00:06:56.999
All the other things were configuration, the host name was already there.

00:06:57.000 --> 00:07:01.999
<v Aaron>Oh, did you? Oh, I missed that then. You should have pushed back harder then.

00:07:02.000 --> 00:07:08.999
<v Joel>Okay. No, that's fair. But I think this... I'm going to take away from this. I don't care if anybody else is benefiting from this right now,

00:07:09.000 --> 00:07:16.999
but I never really thought about the distinction that you drew between configuration/workflow and credentials.

00:07:17.000 --> 00:07:23.999
And credentials would include things like the hostname. Like, the way you talk to the outside world is-

00:07:24.000 --> 00:07:24.999
<v Aaron>Yeah.

00:07:25.000 --> 00:07:30.999
<v Joel>Yeah, okay. All right, I feel like we both had good points, but I'm going to say I won.

00:07:31.000 --> 00:07:32.999
<v Aaron>I'm definitely right. Cool.

00:07:38.000 --> 00:07:43.999
You know, it's funny that like things go in sort of cycles, you know. You notice that with trends,

00:07:44.000 --> 00:07:47.999
clothes, design, interior design, houses, all that kind of stuff, right?

00:07:48.000 --> 00:07:48.999
<v Joel>Mm-hmm (affirmative).

00:07:49.000 --> 00:07:56.999
<v Aaron>And I never really thought about the cycles of entertainment because it always just seemed like our entertainment sort of moved forward.

00:07:57.000 --> 00:08:03.999
But then I started thinking like, "No, it does a cycle too." And something hit me the other day that is just actually hilarious, and I don't know if anyone else

00:08:04.000 --> 00:08:13.999
finds it hilarious. But I'm just going to say the statement, and then you can agree or disagree. YouTube music is just basically MTV again.

00:08:14.000 --> 00:08:15.999
<v Joel>Okay. Yeah.

00:08:16.000 --> 00:08:24.999
<v Aaron>Because all it is is... I've seen this now, people in a generation different than mine, younger, will play YouTube music either in their other

00:08:25.000 --> 00:08:33.999
screen or even like minimize. And it's a music video with the music. I'm like, you're basically watching MTV again. And by the way, don't get me started on

00:08:34.000 --> 00:08:39.999
just being a guy who is stuck in the past thinking about data bandwidth and all that kind of stuff. You just want the audio, so why are you sending the video?

00:08:40.000 --> 00:08:44.999
Ah. But anyway, yeah, just MTV again. It's interesting how those things circle.

00:08:49.000 --> 00:08:51.999
So, as we kind of learned in this podcast, you can do something right and

00:08:52.000 --> 00:08:59.999
wrong all at the same time. It's sort of opinion, but is it opinion? I don't really know, but a lot of that stuff will come out during a code review.

00:09:00.000 --> 00:09:09.999
<v Joel>Code review, that's something we could help your team with. If you'd like Aaron and I to review your code, head over to masteringlaravel.io/codereview.