1. Go to this page and download the library: Download mtownsend/read-time 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/ */
mtownsend / read-time example snippets
/*
* Package Service Providers...
*/
Mtownsend\ReadTime\Providers\ReadTimeServiceProvider::class,
return [
/*
* Whether or not minute/second should be abbreviated as min/sec
*/
'abbreviate_time_measurements' => false,
/*
* Omit seconds from being displayed in the read time estimate
*/
'omit_seconds' => true,
/*
* Whether or not only the time should be displayed
*/
'time_only' => false,
/*
* The average words per minute reading time
*/
'words_per_minute' => 230,
];
use Mtownsend\ReadTime\ReadTime;
$readTime = (new ReadTime($content))->get();
use Mtownsend\ReadTime\ReadTime;
$readTime = (new ReadTime($content, $omitSeconds = true, $abbreviated = false, $wordsPerMinute = 230))->get();
// or
$readTime = (new ReadTime($content))
->omitSeconds()
->abbreviated()
->wpm($wordsPerMinute)
->get();
use Mtownsend\ReadTime\ReadTime;
$readTime = (new ReadTime([$content, $moreContent, $evenMoreContent]))->get();