Skip composer PHP requirement

I’ve found the option: composer install –ignore-platform-reqs Ignore platform requirements (php & ext- packages). Alternative: Specify your projects’ PHP version You can skip the platform checks by configuring composer.json#/config/platform/php with the PHP version to use. Composer will fetch packages based on that configured PHP version then. So when you need to tell Composer the PHP … Read more

PHP adding custom namespace using autoloader from composer

You actually don’t need custom autoloader, you can use PSR-4. Update your autoload section in composer.json: “autoload”: { “psr-4”: { “Classes\\Weather\\”: “Classes/CronJobs/Weather” } } To explain: it’s {“Namespace\\\”: “directory to be found in”} Don’t forget to run composer dump-autoload to update Composer cache. Then you can use it like this: include(LIBRARY .’autoload.php’); $weather = new … Read more

Using Composer’s Autoload

Every package should be responsible for autoloading itself, what are you trying to achieve with autoloading classes that are out of the package you define? One workaround if it’s for your application itself is to add a namespace to the loader instance, something like this: <?php $loader = require ‘vendor/autoload.php’; $loader->add(‘AppName’, __DIR__.’/../src/’);