2017 © Pedro Peláez
 

library lorem_gutenberg

A PHP library for generating filler text from Project Gutenberg books

image

writecrow/lorem_gutenberg

A PHP library for generating filler text from Project Gutenberg books

  • Thursday, January 11, 2018
  • by markfullmer
  • Repository
  • 1 Watchers
  • 0 Stars
  • 19 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 3 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Lorem Gutenberg

Circle CI, (*1)

A PHP library for generating random text, sourced from various authors in Project Gutenberg., (*2)

Screenshot of Text Generation, (*3)

Usage in an application

The included /index.php file contains a generation form demo., (*4)

Make your code aware of the LoremGutenberg class via your favorite method (e.g., use or require), (*5)

Then pass a string of text into the class:, (*6)

$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., (*7)

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:, (*8)

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, (*9)

The Versions

11/01 2018

dev-master

9999999-dev

A PHP library for generating filler text from Project Gutenberg books

  Sources   Download

MIT

The Development Requires

11/01 2018

1.1

1.1.0.0

A PHP library for generating filler text from Project Gutenberg books

  Sources   Download

MIT

The Development Requires

13/05 2017

1.0

1.0.0.0

A PHP library for generating filler text from Project Gutenberg books

  Sources   Download

MIT

The Development Requires

10/05 2017

dev-woolf

dev-woolf

A PHP library for generating filler text from Project Gutenberg books

  Sources   Download

GPLv2

The Development Requires

by Avatar markfullmer