DaveRandom/Resume

What is this autoload.php?

David263 opened this issue · 3 comments

Thank you for this useful library, which I haven't tried yet.

Don't understand the example code require __DIR__ . '/../vendor/autoload.php';. What is this autoload.php? Is it necessary? What does it do? Where is this code? Where is it called? Who is the 'vendor'? Where is it documented? Why no comment in the example code?

kpion commented

@David263

require __DIR__ . '/../vendor/autoload.php'; is associated with the “composer” project, which is a dependency management system for PHP projects. [Here is an elegant tutorial in my opinion: https://www.codementor.io/@jadjoubran/php-tutorial-getting-started-with-composer-8sbn6fb6t

At first, it may seem a bit overwhelming, but know that Composer has been used for a long time in most slightly larger projects (whether based on Symfony or Laravel or no framework at all).

So it's worth learning it, not only because of this particular package ("Resume");

Reading the first few sentences of this tutorial convinces me that I would never, ever want to use Composer. Obviously, as with other dependency systems, it will inflate almost any program into monumental size, with most of the auto-included dependencies being for minor or useless functionality.

I write my own PHP programs, based on my own reusable components, to create programs whose code is minimal and highly functional, with debugging primitives in every program. You can't get that kind of result by checking your brain at the door and blindly using a Named System that Does Everything for You. Good (bug-free) software doesn't lend itself well to deliberate mindlessness.

I'm currently finishing up a website that is based on simple and effective techniques, leveraging the inherent global nature of function calls. Its reusable pieces work because of a simple versioning scheme. Autoload? I just have a Require or Include inside of a function, calling the function to load the code. Dependencies? I have so few that debugging my own errors is a breeze. I happily choose not to use npm, Composer, or Chocolatey, just my own code, which does what its comments describe. That is my choice, and I know what my programs do.

kpion commented

I completely agree... I often create websites with very few dependencies, alongside projects based on frameworks. Just a few 'require' statements are perfectly sufficient in this case.

I also dislike that "magic" which does too much for us. Because when something breaks or you need to modify that "magic" a bit, it starts to become a hindrance at that point.

Nevertheless, for large projects with a lot of dependencies, it would be hard to do without Dependency Managers.

p.s. This specific package ("Resume") doesn't use any other libraries. So, composer require daverandom/resume would only copy what you see in the "src" subdirectory of this project - so you wouldn't get have this: https://www.reddit.com/media?url=https%3A%2F%2Fi.redd.it%2Ftfugj4n3l6ez.png :)