https://github.com/writecrow/lorem_gutenberg
Generate English-language filler text from Project Gutenberg
https://github.com/writecrow/lorem_gutenberg
gutenberg lorem-ipsum lorem-ipsum-generator php-library
Last synced: 10 months ago
JSON representation
Generate English-language filler text from Project Gutenberg
- Host: GitHub
- URL: https://github.com/writecrow/lorem_gutenberg
- Owner: writecrow
- License: mit
- Created: 2017-05-01T00:35:01.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-05-10T01:49:38.000Z (over 5 years ago)
- Last Synced: 2025-02-28T03:01:07.268Z (10 months ago)
- Topics: gutenberg, lorem-ipsum, lorem-ipsum-generator, php-library
- Language: PHP
- Homepage: https://lorem-gutenberg.markfullmer.com/demo
- Size: 2.78 MB
- Stars: 1
- Watchers: 5
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Lorem Gutenberg
[](https://circleci.com/gh/writecrow/lorem_gutenberg)
A PHP library for generating random text, sourced from various authors in
Project Gutenberg.

## Usage in an application
The included `/index.php` file contains a generation form demo.
Make your code aware of the LoremGutenberg class via your favorite method (e.g.,
`use` or `require`)
Then pass a string of text into the class:
```php
$text = LoremGutenberg::generate();
echo $text;
// Will return an excerpt of random length (1-10 sentences) from a random author.
$text = LoremGutenberg::generate(array('author' => 'austen'));
echo $text;
// Will return an excerpt of random length (1-10 sentences) from Jane Austen.
$text = LoremGutenberg::generate(array('author' => 'hardy', 'sentences' => 3));
echo $text;
// Will return an excerpt of 3 sentences from Thomas Hardy.
```
## Usage as an API
The file in `/api` demonstrates how GET parameters in a URL can be passed to LoremGutenberg. For example, `https://my-api.org/api/?author=hardy&sentences=2` will return 2 sentences' worth of LoremGutenberg from Thomas Hardy.
### Parameters
| Name | Description | Example |
| ------------- | ------------- | ------------- |
| `author` | If absent, a random author will be used | hardy |
| `sentences` | If absent, a number from 1-10 will be used | 2 |
### Sameple valid API queries
- `/api/?author=hardy&sentences=2`
- `/api/?author=hardy`
- `/api/?sentences=2`
- `/api/`
## What authors are available?
As of this writing, LoremGutenberg references texts from the following authors:
```php
public static $authors = [
'austen' => 'Jane Austen',
'hardy' => 'Thomas Hardy',
'lawrence' => 'D.H. Lawrence',
'wharton' => 'Edith Wharton',
];
```
## Testing
Unit Tests can be run (after ```composer install```) by executing ```vendor/bin/phpunit```