2017 © Pedro Peláez
 

library php-loremipsum

Lorem ipsum generator in PHP without dependencies

image

joshtronic/php-loremipsum

Lorem ipsum generator in PHP without dependencies

  • Tuesday, January 9, 2018
  • by joshtronic
  • Repository
  • 9 Watchers
  • 72 Stars
  • 84,368 Installations
  • PHP
  • 8 Dependents
  • 0 Suggesters
  • 15 Forks
  • 0 Open issues
  • 6 Versions
  • 27 % Grown

The README.md

php-loremipsum

Build Status Coverage Status Total Downloads, (*1)

Lorem ipsum generator in PHP without dependencies. Compatible with PHP 5.3+., (*2)

Become a Patron, (*3)

Installation

The preferred installation method is via composer. First add the following to your composer.json:, (*4)

"require": {
    "joshtronic/php-loremipsum": "dev-master"
}

Then run composer update., (*5)

Usage

Getting Started

$lipsum = new joshtronic\LoremIpsum();

Generating Words

echo '1 word: '  . $lipsum->word();
echo '5 words: ' . $lipsum->words(5);

Generating Sentences

echo '1 sentence: '  . $lipsum->sentence();
echo '5 sentences: ' . $lipsum->sentences(5);

Generating Paragraphs

echo '1 paragraph: '  . $lipsum->paragraph();
echo '5 paragraphs: ' . $lipsum->paragraphs(5);

Wrapping Text with HTML Tags

If you would like to wrap the generated text with a tag, pass it as the second parameter:, (*6)

echo $lipsum->paragraphs(3, 'p');

// Generates: 

Lorem ipsum..., (*7)

..., (*8)

..., (*9)

Multiple tags can also be specified:, (*10)

echo $lipsum->sentences(3, ['article', 'p']);

// Generates: <article>

..., (*11)

</article><article>

..., (*12)

</article><article>

..., (*13)

</article>

And you can back reference using $1:, (*14)

echo $lipsum->words(3, '<li><a href="$1">$1</a></li>');

// Generates: <li><a href="...">...</a></li><li><a href="...">...</a></li><li><a href="...">...</a></li>

Return as an Array

Perhaps you want an array instead of a string:, (*15)

print_r($lipsum->wordsArray(5));
print_r($lipsum->sentencesArray(5));
print_r($lipsum->paragraphsArray(5));

You can still wrap with markup when returning an array:, (*16)

print_r($lipsum->wordsArray(5, 'li'));

Assumptions

The first string generated will always start with the traditional "Lorem ipsum dolor sit amet, consectetur adipiscing elit". Subsequent strings may contain those words but will not explicitly start with them., (*17)

Contributing

Suggestions and bug reports are always welcome, but karma points are earned for pull requests., (*18)

Unit tests are required for all contributions. You can run the test suite from the tests directory simply by running phpunit ., (*19)

Credits

php-loremipsum was originally inspired by badcow/lorem-ipsum with a goal of being a dependency free lorem ipsum generator with flexible generation options., (*20)

License

MIT, (*21)

The Versions

09/01 2018

dev-development

dev-development https://github.com/joshtronic/php-loremipsum

Lorem ipsum generator in PHP without dependencies

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

generator lorem ipsum

09/01 2018

dev-master

9999999-dev https://github.com/joshtronic/php-loremipsum

Lorem ipsum generator in PHP without dependencies

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

generator lorem ipsum

09/01 2018

1.0.3

1.0.3.0 https://github.com/joshtronic/php-loremipsum

Lorem ipsum generator in PHP without dependencies

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

generator lorem ipsum

29/05 2017

1.0.2

1.0.2.0 https://github.com/joshtronic/php-loremipsum

Lorem ipsum generator in PHP without dependencies

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

generator lorem ipsum

09/06 2016

1.0.1

1.0.1.0 https://github.com/joshtronic/php-loremipsum

Lorem ipsum generator in PHP without dependencies

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

generator lorem ipsum

13/09 2014

1.0.0

1.0.0.0 https://github.com/joshtronic/php-loremipsum

Lorem ipsum generator in PHP without dependencies

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

generator lorem ipsum