Where are you getting the idea that is how it should be from?
EDIT
It just occurred to me what it looks like you’ve done. (seeing “composer” should have made it click before it did) Please correct me if I’m wrong.
You saw the code for a CLI command. i.e. the “$” representing the prompt, which you misinterpreted as being PHP.
AFAIK, packaged files need to be in place before runtime so they can be called in when needed.
Probably a clear example of copy&paste. Typically, that’s what you see when the author of the repo refers to using composer. So really, this is actually a Linux command that’s being “assumed” as a PHP code.
It’s pretty clear already. Use composer to download that library. Once it’s downloaded, all you have to do is require the autoload.php file that gets included in the generated vendor folder.
Much thanks for your reply.
Not pretty clear to me, that’s why I’m here.
How would I use composer to download that library?
And what library?
Thanks again
You have to first install composer which is super easy. Depending on which OS you have, you have to install it respectfully. Composer has step by step guides on their website for it. Once composer is installed. All you need to do is type into the terminal
composer require xmo/client
And that’s it. It’ll download it to the folder you are currently in. Though I am not sure where you got that code from because composer uses packagist.org to download from GitHub. I’ve done a quick search on both packagist and GitHub and I cannot find that library you are attempting to use.
I don’t think it should take 4 devs to tell you how to use the terminal. Really, you don’t even need a live server for this. The only actual thing that’s really needed are the composer files. Once you have them, you don’t even need to use composer again on a live site. You can do this on a local server and use the generated composer files and upload them to your live server.
Composer is just a faster way of including multiple repos without the need to use 50 lines of require. You can also download the repo from GitHub too if the service you are using has a GitHub repo for it. Otherwise, there’s really no legitimate reason to use composer if the service doesn’t include a legitimate repo. This means that it has to exist on packagist because like I said before, composer goes out to packagist and downloads it from there.
That isn’t completely true. You can set-up composer to pull files from anywhere. I’ve targeted github before to get the latest and greatest as well as fork things myself modify and point to my own repo.
If a php library is not a composer package it is probably very low quality. Libraries don’t have to be on package list though.
Dependency management is a fundamental, modern architectural construct. Nearly every language now has some form of dependency management. I would argue it is one of the most important things to learn after syntax. Autoloading also goes along with that.