I’m new to Composer and currently working on a plain PHP project. However, I’m struggling to load a Composer package into my project. I’ve tried researching, but I’m still uncertain about the steps required to include the package. Could someone guide me on how to include Composer packages in plain PHP projects?
If you check their documentation, you can see, the package can be installed with the following command
composer require mantas-done/subtitles
Like any other package, this command will automatically create a composer.json file and download all the package files into a vendor directory in your project.
Now simply add the autoload.php in your project.
require_once 'vendor/autoload.php';
This line will include Composer’s autoloader, allowing you to access the package’s classes and functions effortlessly.
You will find the rest of the documentation in the github page.
// add namespace
use \Done\Subtitles\Subtitles;
Subtitles::convert('subtitles.srt', 'subtitles.vtt');