PHP code example of psr-discovery / log-implementations
1. Go to this page and download the library: Download psr-discovery/log-implementations library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
psr-discovery / log-implementations example snippets
use PsrDiscovery\Discover;
// Return an instance of the first discovered PSR-3 Log implementation.
$log = Discover::log();
$log->info('Hello World!');
use PsrDiscovery\Discover;
$logs = Discover::logs();
foreach ($logs as $log) {
echo sprintf('Discovered %s v%s', $log->getPackage(), $log->getVersion());
}
use PsrDiscovery\Discover;
$log = Discover::log();
if ($log === null) {
// No suitable Log implementation was discovered.
// Fall back to a default implementation.
$log = new DefaultLog();
}
use PsrDiscovery\Discover;
use PsrDiscovery\Implementations\Psr3\Logs;
// Prefer the a specific implementation of PSR-3 over others.
Logs::prefer('league/container');
// Return an instance of League\Container\Container,
// or the next available from the list of candidates,
// Returns null if none are discovered.
$log = Discover::log();
use PsrDiscovery\Discover;
use PsrDiscovery\Implementations\Psr3\Logs;
// Only discover a specific implementation of PSR-3.
Logs::use('league/container');
// Return an instance of League\Container\Container,
// or null if it is not available.
$log = Discover::log();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.