Skip to content

Commit 86acdc6

Browse files
committed
Fix composer lock issue and add property example
1 parent 3f9ee4b commit 86acdc6

File tree

3 files changed

+77
-18
lines changed

3 files changed

+77
-18
lines changed

README.md

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,32 @@
1414
</p>
1515

1616
## About
17-
PHPMarkup is a markup processor based on the [LHTML](https://github.com/Ouxsoft/LHTML) standard written in PHP.
17+
PHPMarkup is a lightweight markup processor standard written in PHP.
1818
It facilitates the extraction of markup into a data structure, orchestrated manipulation of said structure, and output as
19-
(optimized) markup.
19+
(optimized) markup and uses the [LHTML](https://github.com/Ouxsoft/LHTML) standard.
2020

2121
### Instructions
2222
Create a PHPMarkup Element to instruct DOMElement processing.
2323
```php
2424
/**
25-
* Class SayHello
26-
* DomElement process class
25+
* Class MessagesElement
2726
*/
28-
class SayHello extends Ouxsoft\PHPMarkup\Element
27+
class MessagesElement extends Ouxsoft\PHPMarkup\Element
2928
{
30-
/**
31-
* @return string
32-
*/
29+
private $messages;
30+
31+
public function onLoad() : void
32+
{
33+
$this->messages = $this->db->query('SELECT `msg` FROM `messages`;');
34+
}
35+
3336
public function onRender(): string
3437
{
35-
return 'Hello, ' . $this->getArgByName('who') . $this->innerText();
38+
$out = '';
39+
foreach($this->messages as $row){
40+
$out .= $row['msg'] . $this->getArgByName('delimiter');
41+
}
42+
return $out;
3643
}
3744
}
3845
```
@@ -42,18 +49,17 @@ Process a DOM using the class created.
4249
```php
4350
use Ouxsoft\PHPMarkup\Factory\ProcessorFactory;
4451

45-
// Instantiate Processor and configure to parse output buffer
4652
$processor = ProcessorFactory::getInstance();
47-
$processor->addElement(['xpath' => '//greetings', 'class_name' => 'SayHello']);
53+
$processor->addElement(['xpath' => '//messages', 'class_name' => 'MessagesElement']);
54+
$processor->addRoutine(['method' => 'onLoad']);
4855
$processor->addRoutine(['method' => 'onRender', 'execute' => 'RETURN_CALL']);
56+
$processor->addProperty('db', new PDO('sqlite:/example.db'));
4957
$processor->parseBuffer();
50-
51-
// Displays "Hello, World!" when rendered by Browser
5258
?>
5359
<html lang="en">
54-
<greetings>
55-
<arg name="who">World</arg>!
56-
</greetings>
60+
<messages>
61+
<arg name="delimiter">;</arg>
62+
</messages>
5763
</html>
5864
```
5965

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"ext-libxml": "*",
2424
"laminas/laminas-config": "3.4.0",
2525
"laminas/laminas-validator": "2.14.4",
26-
"pimple/pimple": "v3.4.0"
26+
"pimple/pimple": "v3.3.1"
2727
},
2828
"require-dev": {
2929
"friendsofphp/php-cs-fixer": "^v2.18.6",

composer.lock

Lines changed: 54 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)