ouxsoft / phpmarkup
A Processor for Markup written in PHP. Allows extraction of Markup into a data structure, orchestrated nested manipulation of said structure, and output as (optimized) Markup.
Fund package maintenance!
hxtree
www.paypal.me/hxtree
github.com/sponsors/hxtree
Installs: 3 882
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 1
Open Issues: 9
Requires
- php: >=7.3
- ext-dom: *
- ext-json: *
- ext-libxml: *
- laminas/laminas-config: ^3.4.0
- laminas/laminas-validator: ^2.14.4
- pimple/pimple: ^v3.3.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^v3.1.0
- phpbench/phpbench: ^1.1
- phpstan/phpstan: ^0.12.99
- phpunit/phpunit: ^9
- dev-master
- v4.3.2
- v4.3.1
- v4.3.0
- v4.2.6
- v4.2.5
- v4.2.4
- v4.2.3
- v4.2.2
- v4.2.1
- v4.2.0.x-dev
- v4.2.0
- v4.0.2
- v4.0.1
- v4.0.0
- dev-snyk-fix-553ebdc51fd700c18c7179f4b559915a
- dev-snyk-fix-73b72b41965c650ab38845a5755c19d8
- dev-snyk-fix-beff05858b64696107ef02f93cebb3e3
- dev-snyk-fix-21d8194e94d8c2ddecdccf842033b1ef
- dev-snyk-fix-23c7bfc06b9d581474a39460e3fbb386
- dev-snyk-fix-15328710eabd97075b5b80e058539622
- dev-snyk-fix-e1f0951d23f1f2c8b093c2bb30fee0a9
- dev-snyk-fix-b0e76bf33b008194177d9f9cc106a48e
- dev-hxtree/example
This package is auto-updated.
Last update: 2024-12-16 07:40:48 UTC
README
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.