News for hackers. Stuff that matters.
Re:What, why and how of PHP Composer by tylerjwilk00 on Thursday June 14, 2018 @03:45PM (#17314748)
You won't even notice it.

Everything you already have will continue to work fine. All you have to do is include the autoloader somewhere in your code path.

An example assuming you already installed composer on the machine into your /bin or similar directory.

# add a new dependency:

  composer require guzzlehttp/guzzle
# this dependency will now be in the vendor directory

  ls ./vendor
# update your apps entry point (ie: frontcontroller.php):

  // require composer's autoloader
  require ('vendor/autoload.php');
# autoload will now find any dependencies you add via composer

  // create guzzle client
  $client = new \GuzzleHttp\Client();
# another tip, if you already have a bunch of class files some where (ie: myapp/src/classes , myapp/src/models ) You can include class paths via composer.json

      "autoload": {
          "classmap": ["classes/", "models/", "MyClass.php"]
      }
You can now remove any hard-coded include or require statements.

There is a lot more things you can do with it but this is the most basic example.

Re:What, why and how of PHP Composer by krapp on Thursday June 14, 2018 @05:02PM (#17315323)
>There is a lot more things you can do with it but this is the most basic example.

One useful feature is custom commands[0].

[0]https://getcomposer.org/doc/articles/scripts.md#writing-cust...

Also, regarding autoloading, I find that once you get used to the structure of PSR-4, adding files to a PSR-4 namespace[1] and just having autoloading work is incredibly helpful. The only pain point is dealing with namespaces everywhere.

[1]https://getcomposer.org/doc/04-schema.md#psr-4