Skip to content

Latest commit

 

History

History
99 lines (80 loc) · 4.23 KB

README.md

File metadata and controls

99 lines (80 loc) · 4.23 KB

PHPMarkup

CI Code Quality Code Coverage Docs Status

Latest Stable Version PHP Versions Supported License Total Downloads

Installation

Install the latest version:

$ composer require ouxsoft/phpmarkup

Basic Usage

Create an Element class containing DOMElement processing instructions.

<?php

namespace App\Elements;

class Messages extends Ouxsoft\PHPMarkup\Element
{
    private $messages;

    public function onLoad() : void
    {
        $this->messages = $this->db->query('SELECT `msg` FROM `messages`;');
    }

    public function onRender(): string
    {
        $out = '';
        foreach($this->messages as $row){
            $out .= $row['msg'] . $this->getArgByName('delimiter');
        }
        return $out;
    }
}

Configure a Processor to process a DOM using the Element class created.

<?php

use Ouxsoft\PHPMarkup\Factory\ProcessorFactory;
use App\Elements\Messages;

$processor = ProcessorFactory::getInstance();
$processor->addElement(['xpath' => '//messages', 'class_name' => App\Elements\Messages::class]);
$processor->addRoutine(['method' => 'onLoad']);
$processor->addRoutine(['method' => 'onRender', 'execute' => 'RETURN_CALL']);
$processor->addProperty('db', new PDO('sqlite:/example.db'));
$processor->parseBuffer();
?>
<html lang="en">
    <messages>
        <arg name="delimiter">;</arg>
    </messages>
</html>

About

PHPMarkup is a lightweight markup processor written in PHP. It facilitates the extraction of markup into a data structure, orchestrated manipulation of said structure, and output as (optimized) markup. It is based on the LHTML standard.

Documentation

Author

Matthew Heroux
See also the list of contributors who participated in this project.

Contributing

PHPMarkup is an open source project. If you find a problem or want to discuss new features or improvements please create an issue, and/or if possible create a pull request. Easily contribute using test docker image.

License

PHPMarkup is licensed under the MIT License - see the LICENSE file for details.

Acknowledgement

Thanks to Andy Beak for providing code reviews. Thanks to Bob Crowley for providing Project Management advising. Thanks to Aswin Vijayakumar for their useful comments. Thanks to Alexander Romanovich of White Whale Web Services for his work on the free class XPHP. All of have led to changes to this implementation.