https://github.com/leepownall/read-time
Simple package for displaying read time
https://github.com/leepownall/read-time
laravel read-time
Last synced: 4 months ago
JSON representation
Simple package for displaying read time
- Host: GitHub
- URL: https://github.com/leepownall/read-time
- Owner: leepownall
- License: mit
- Created: 2023-10-29T20:25:27.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-07-28T17:43:30.000Z (10 months ago)
- Last Synced: 2025-07-28T19:31:20.694Z (10 months ago)
- Topics: laravel, read-time
- Language: PHP
- Homepage:
- Size: 58.6 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
# Read Time
[](https://packagist.org/packages/pownall/read-time)
[](https://github.com/leepownall/read-time/actions/workflows/run-tests.yml)
[](https://packagist.org/packages/pownall/read-time)
Simple package for displaying read time.
## Installation
You can install the package via composer:
```bash
composer require leepownall/read-time
```
## Usage
### Using `get()`
```php
$readTime = new Pownall\ReadTime\ReadTime('Hello, world!');
$readTime->get();
```
### Using `__toString()`
```php
$readTime = new Pownall\ReadTime\ReadTime('Hello, world!');
echo $readTime;
```
### Using blade directive
```php
@readtime('Hello, world!')
```
### Pass in `wordsPerMinute`
```php
$readTime = new Pownall\ReadTime\ReadTime('Hello, world!', 300);
```
```php
@readtime('Hello, world!', 300)
```
## Output
It uses Carbon under the hood, specifically `forHumans` on the `CarbonInterval`.
The output looks like
```php
2 hours 4 minutes
```
### Config
Default `wordsPerMinute` is 200. You can override this by passing it in, or publish the config and override there.
`php artisan vendor:publish --tag=readtime-config`
## Testing
```bash
composer test
```
## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
## Contributing
Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.
## Security Vulnerabilities
Please review [our security policy](../../security/policy) on how to report security vulnerabilities.
## Credits
- [Lee Pownall](https://github.com/leepownall)
- [All Contributors](../../contributors)
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.