I am following an tutorial on how to create a composer develop envoirement. https://www.hostinger.com/tutorials/how-to-install-composer
I followed this but am getting the error 'Class "Timer" not found'.
Steps i took:
Code:
<?php
require __DIR__ . '/vendor/autoload.php';
Timer::start();
// your code
$time = Timer::stop();
var_dump($time);
print Timer::secondsToTimeString($time)
The classes in phpunit/php-timer
are in a namespace called SebastianBergmann\\Timer
. Thus, you must either use the fully qualified class name:
\SebastianBergmann\Timer\Timer::start();
Or specify a use
alias:
use SebastianBergmann\Timer\Timer;
Timer::start();
// ...
Time::stop();
I haven't looked in much detail but note that the docs for this package do not show static usage, so you might have to do:
use SebastianBergmann\Timer\Timer;
$timer = new Timer();
$timer->start();
// ...
$timer->stop();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.