I developed a small library for internal use within my company and some of our clients. This library was developed on a PHP 7 environment.
It has been installed and used successfully on my colleagues' computers and some of my clients severs running PHP 7 (including 7.0 and 7.1). Recently I came across a client on a shared hosting platform running PHP 5.6, and composer could download and install the package without any errors, but does not autoload the classes, for example:
<?php
include "vendor/autoload.php";
use MyVendor\MyPackage\Client\ClientObject;
$client = new ClientObject();
// PHP 7 : OK
// PHP 5 : PHP Fatal Error: Cannot find class MyVendor\MyPackage\Client\.....
Runs fine on PHP 7 environments but not PHP 5. I thought it could be the shared hosting but I spun up a PHP 5 VM on my machine and verified that the autoloading does not work as well.
I inspected the vendor/composer directory and found that the files are exactly the same. The autoloading only fails for my package and not its dependencies such as GuzzleHttp, so it's proabbly something wrong with my package but I don't know what to look out for.
Addendum Directory structure for my package, when installed by composer:
- MyVendor
| - MyPackage
| | - src
| | | - client
| | | | - ClientObject.php
| | | - (other files and folders)
| | - composer.json
Autoloader defined in composer.json as "psr-4" : { "MyVendor\\MyPackage\\" : "src/" }
