As discussed in the comments, trying to better understand the problem, the lack of loading the autoload
of Composer file causes PHP to not know how to fetch the classes. Composer makes magic, but not so much. After installation, there should be a vendor
directory in your application, with the project dependencies. Before using them, insert the file autoload
, at the beginning of each file:
<?php
require __DIR__ . '/vendor/autoload.php';
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use Monolog\Handler\FirePHPHandler;
// Create the logger
$logger = new Logger('my_logger');
The vendor/autoload.php
file is the default for Composer, which makes all the magic happen.
Note : autoload
must be included once for each request handled in PHP. That is, if your application requests multiple PHP files, require autoload
must be present in all of them. If it is based on some architecture, such as MVC, where all the requests are handled in just one file, all you have to do is simply put in it to be accessible throughout the project.