Transcript
English (Auto-generated)
Okay little friends. So now that we've created our phoenix project, one thing I want to note that um you know, in every project you will likely have dependencies, I mean to say the least. You will at least need to have the libraries of phoenix itself as dependencies. So you could actually um run your project dependencies in phoenix project goes into the mix file. So you see here is this mix that the excess, if you remember any excess our elixir script files meaning that it compiled but you could use them to run Also, if you recall basically Mix is the tool for managing your projects, you could use it to create tasks to run tasks to actually start the project to start with. If you recall when we started the project we used Mix and Mix is going to be our friend throughout developing with phoenix because it's gonna make it handy for us to do many things such as running the project um migrating the database to, you know, to very common things but there are many others like the one I'm going to show you here which is installing dependencies. Now, if you go to this mix that the excess, you will notice that the rays, this private function that's called depth for dependencies. So it's a list of two poles and each tuple is composed of an atom which is the name of the library that you would like to import into your application and then this version right here. Okay, um as a reminder here, this basically means that it will accept version one .6. Where x is six for more. So this one will accept anything that is six or more at the very last digit. This is what this tilde greater than means the other ones are kind of self explanatory here. So for example this floki Gem sorry not gem library, I confuse it with ruby, it means that we want a version that's greater than 0.30 point zero. Um when you do not actually all of them actually specify the still decorator than which is the most common one because usually the last digit in versioning, if if you're using this approach of vestal versioning it's called is to use the last digit for batch changes, meaning it's usually a minor change. That's a security fix or a minor bug fix or so on. It's not like a major change to the library that you're using so you know, I won't go through all of them here, we'll encounter those. Um as we build our project, it was to say this is the phoenix um library itself, we're using phoenix 1.6 point six or greater than this number. So it could be 1.6 point seven and so on by the way, um to install your dependencies, it should have prompted you. I mean I've I've already erased the screen but should have prompted you to install dependencies but if you've exited that screen you could always just run mixed depths but get and that will install the latest dependencies. So you fetch dependencies, you can run, Makes the steps not get it's okay. Um So you I mean in case you're not familiar with this approach is it's very similar by the way to the approach that many modern frameworks follow, which means once you install it, the very first time, it will actually lock that library to a particular version that matches the specifications here and it will lock it in the case of phoenix to this mix dot log. So to know the exact version, because like I was I was saying here before with the mixed the excess, this will accept phoenix 1.6 point six, but it will also accept 1.6 point seven or 1.6 point eight and so on. So how do we know what version do we have exactly? Well, the way to know it is to look into your mix dot lock. So mix. actually tell you what version do we have? So in this particular case we actually have the exact version of 1.6.6 Which means that even if version 1.6.8 comes up for instance and somebody clones your project, it will Still only use 1.6.6 because it's locked your project to that version unless you explicitly ask it to upgrade it to a normal and this is a really good feature because you want everybody on the project to be on the same version. Even if it's a minor one with a minor change. All right. So um let me actually go through a few of these to tell you at least. So I won't go through all of them. But you know, phoenix is basically the library we're using. Ecto is the library we're going to use to build schemas to connect with the database. We're going to be using a sequel based database. Specifically Postgres. That's why you see by default we have this act a sequel and we have Postgres. Um you know, Jason is basically to to do Jason and so on. So if you need um you know, a new library to be added, you could simply added to the list right here. So for instance, let's say I need a library to do http requests, which is a common thing to do in most web applications. Um no one I like is called Tesla. So Tesla elixir. So um if you open up to get help for this particular one, it will actually tell you how you could install it. So it says here people that version And then version 1.4. Um and it says you could you could have optional recommended adapters and so on. So for instance, if I want to install um Tesla could simply just add it right here To the uh this 1 um uh to the list under the dependencies. The depths you notice here, my V. S code shows all red because this dependency hasn't been installed. I'm using a library called Elixir LS, which I would recommend you installed if you don't have it. So maybe here, I recommend that you use elixir LS if you are using V. S code, I'm not sure if it's available in other editors. If you're using another editor, you could check if it has something similar. Lexus LS gives you a lot of nice features. It allows you to navigate code. It gives you something like here where, for instance, it showed me red lines when I don't have the dependencies installed, which again is a good segue to say, well let's go ahead and install this. So make steps to get. So it did actually recognize that we've added a new library here called Tesla. So it's installed it. And now these red lines have gone again, I'll remove it for now. I don't need, I don't need I don't need it right at the moment. Uh So let me just remove it. This was just more to illustrate uh the idea um there's other things in this mixed file um at the very top here, there is some information about the project, um like the app name the version and so on, and the elixir version for instance, uh there will be other things as well, such as the tasks in the LDCS and whatnot. So we'll encounter those in a future lesson, um but at least for now we've learned how to um add dependencies to our phoenix project. By the way, I will be adding notes for each lesson right here in this notes folder, so I'll be adding new markdown files every lesson. So if you ever want to refer, you forget the command or something, you can always go back and refer to this notes folder right here. Thank you for joining in and I'll see you in the next lesson.