PHP code example of wardenyarn / loripsum

1. Go to this page and download the library: Download wardenyarn/loripsum 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/ */

    

wardenyarn / loripsum example snippets


use Wardenyarn\Loripsum\Loremipsum;
use Wardenyarn\Loripsum\Enums\Option;

$lorem = new LoremIpsum();

$result = $lorem
    ->with([
        Option::HEADERS,
        Option::UNORDERED_LIST,
        Option::BLOCKQUOTE,
    ])
    ->long()
    ->paragraphs(10)
    ->withImages() // insert random images from placeholder.com
    ->html(); // html with 10 long paragraphs with headings (h1-h6), unordered lists and blockquotes

// OR

$lorem->random($max_paragraphs = 10)->html(); // html with randomly applied options and size

Wardenyarn\Loripsum\Enums\Option::AVAILABLE_OPTIONS; // Array of available options

use Wardenyarn\Loripsum\Loremipsum;
use Wardenyarn\Loripsum\Enums\Option;

$lorem = new LoremIpsum();

$result = $lorem
    ->with([
        Option::DECORATE,
        Option::LINK,
        Option::UNORDERED_LIST,
        ...
    ])
    ->html();

Wardenyarn\Loripsum\Enums\Size::AVAILABLE_SIZES; // Array of available sizes

use Wardenyarn\Loripsum\Loremipsum;
use Wardenyarn\Loripsum\Enums\Size;

$lorem = new LoremIpsum();

$result = $lorem
    ->short()
    ->medium()
    ->long()
    ->verylong()
    // OR
    ->size(Size::SHORT)
    ->html();

use Wardenyarn\Loripsum\Loremipsum;

$lorem = new LoremIpsum();

$result = $lorem
    ->withImages() // insert random images from placeholder.com
    ->imageChance(60) // Probability percent of inserting image after DOM node; Default: 30%
    ->html();

$result = $lorem
    ->withImages(['/src/1.jpg', '/src/2.jpg']) // Will use given images first
    ->html();

use Wardenyarn\Loripsum\Loremipsum;

$lorem = new LoremIpsum();

$result = $lorem
    ->notPrude() // Will use potentially offensive Latin words 
    ->html();

$result = $lorem
    ->allcaps() // Will uppercase all output
    ->html();

$result = $lorem->plaintext(); // Will strip tags

use Wardenyarn\Loripsum\WithLoremIpsum;

class Example
{
    use WithLoremIpsum;

    function factory()
    {
        return [
            'body' = $this->loremIpsum() // returns an instance of Wardenyarn\Loripsum\Loremipsum
                ->random()
                ->html(),
            ...
        ]
    }
}