Skip to content
This repository was archived by the owner on Oct 21, 2021. It is now read-only.

Commit 6f4319d

Browse files
author
Oxford
authored
Merge pull request #2 from ox-harris/v2.0.0
V2.0.0
2 parents e07b367 + b79e073 commit 6f4319d

File tree

6 files changed

+1743
-1960
lines changed

6 files changed

+1743
-1960
lines changed

README.md

Lines changed: 20 additions & 185 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,8 @@
11
# PHPFront
2-
*Well-Engineered for Templating. Uses no template syntaxes!* [ox-harris.github.io/phpfront](https://ox-harris.github.io/phpfront)
32

4-
-----------------------------------------------
3+
PHPFront will help you read/write content on HTML templates from within your PHP application, read/write on attributes, traverse up/down the full document, manipulate - create, repeat, import, relocate, replace, remove - elements dynamically, produce a clean HTML output that represents your entire application. This is server-side rendering.
54

6-
PHPFront is a fully-featured template engine for PHP.
7-
It facilitates the globally-held standard of code separation in application building.
8-
It helps you dynamically render application content on templates without mixing application codes (PHP) with presentation codes (HTML).
9-
10-
* This code separation brings about cleaner and more maintainable code - the same reason why you do not mix CSS styles with HTML.
11-
* And on the critical side, you avoid all the security issues associated with using PHP codes on HTML templates.
12-
13-
Furthermore, PHPFront brings all the ease and fun to your code, and a whole lot of new possibilities!
14-
15-
**Compare PHPFront with Smarty and other Text-based Template Engines**
16-
17-
* No template syntaxes - not even one. PHPFront is DOM-based not text-based.
18-
* Requires no proprietary syntaxes, PHP codes, or the .tpl extension on templates.
19-
* Built around familiar standards and conventions: PHP, HTML, CSS, XPATH.
5+
It implements the JQuery API with its powerful CSS3 selectors and chainable methods. It is well-tested and greatly optimized for use in websites and other PHP-based applications; built with love to bring all the ease and fun to your code, and a whole lot of new possibilities!
206

217
# Installation
228
## Requirement
@@ -59,19 +45,6 @@ Then in your app.php:
5945
```php
6046
$PHPFront = new PHPFront;
6147
```
62-
63-
* Now we can start assigning content to the respective elements in the template using PHPFront’s `assign()` function
64-
65-
```php
66-
// For document title (title)
67-
$PHPFront->assign(‘title’, ‘This is document title’);
68-
69-
// For page heading 1 (h1)
70-
$PHPFront->assign(‘h1’, ‘Hello World!’);
71-
72-
// For page paragraph (p)
73-
$PHPFront->assign(‘p’, ‘Here is my first PHPFront project’);
74-
```
7548

7649
* Now, we hand PHPFront the template to use - our template.html page
7750
```php
@@ -81,7 +54,24 @@ Then in your app.php:
8154
// Where ‘path-to-template is your actual path to where you stored template.html
8255
$PHPFront->setTemplate(‘path-to-template/template.html’);
8356
```
57+
58+
* Now we can start reading and writing content on respective elements in the template with CSS3 selectors
59+
60+
```php
61+
// For document title (title)
62+
$PHPFront->find(‘title’)->html(‘This is document title’);
63+
64+
// For page heading 1 (h1)
65+
$PHPFront->find(‘h1’)->html(‘Hello World!’);
66+
67+
// For page paragraph (p)
68+
$PHPFront->find(‘p’)->html(‘Here is my first PHPFront project’)->addClass('rounded-corners')->css('color', 'gray');
8469

70+
// Load a HTML fragment into a DIV and manipulate its content
71+
$PHPFront->find('#container')->load(__DIR__.'/templates/table.html')->find('tr:even')->css('background-color', 'whitesmoke')
72+
->parents('table')->attr('id', 'employee-table')->append('<tr><td>342</td><td>John Doe</td></tr>');
73+
```
74+
8575
* Finally, we render our page using PHPFront’s render() function
8676
```php
8777
$PHPFront->render();
@@ -92,7 +82,7 @@ And that’s it! Preview your app.php in a browser and experience the PHPFront's
9282
----------------
9383

9484
# Documentation
95-
https://ox-harris.github.io/phpfront/documentation/
85+
https://ox-harris.github.io/phpfront/documentation/ (FOR phpFront v1.0.0)
9686

9787
# Feedback
9888
All bugs, feature requests, pull requests, feedback, etc., are welcome. [Create an issue](https://github.com/ox-harris/phpfront/issues).
@@ -111,158 +101,3 @@ http://www.facebook.com/PeeHPFront
111101
GPL-3.0 - See LICENSE
112102

113103

114-
----------------
115-
116-
# Usage Comparison with Smarty
117-
118-
### Samrty - (adapted from smarty.net):
119-
120-
#### The php
121-
```php
122-
include('Smarty.class.php');
123-
124-
// create object
125-
$smarty = new Smarty;
126-
127-
// assign some content. This would typically come from
128-
// a database or other source, but we'll use static
129-
// values for the purpose of this example.
130-
$smarty->assign('name', 'george smith');
131-
$smarty->assign('address', '45th & Harris');
132-
133-
// display it
134-
$smarty->display('index.tpl');
135-
```
136-
137-
#### The template - before
138-
139-
```html
140-
<html>
141-
<head>
142-
<title>Info</title>
143-
</head>
144-
<body>
145-
146-
<pre>
147-
User Information:
148-
Name: {$name}
149-
Address: {$address}
150-
</pre>
151-
152-
</body>
153-
</html>
154-
```
155-
156-
#### The template - after
157-
158-
```html
159-
<html>
160-
<head>
161-
<title>Info</title>
162-
</head>
163-
<body>
164-
165-
<pre>
166-
User Information:
167-
Name: george smith
168-
Address: 45th &amp; Harris
169-
</pre>
170-
171-
</body>
172-
</html>
173-
```
174-
175-
### PHPFront:
176-
177-
#### The php
178-
179-
```php
180-
include('PHPFront/lib/PHPFront.php');
181-
182-
// create object
183-
$PHPFront = new PHPFront;
184-
185-
// assign some content. This would typically come from
186-
// a database or other source, but we'll use static
187-
// values for the purpose of this example.
188-
$PHPFront->assign('#name::after', 'george smith');
189-
$PHPFront->assign('#address::after', '45th & Harris');
190-
191-
// display it
192-
$PHPFront->setTemplate('index.html');
193-
$PHPFront->render();
194-
```
195-
196-
#### The template - before
197-
198-
```html
199-
<html>
200-
<head>
201-
<title>Info</title>
202-
</head>
203-
<body>
204-
205-
<pre>
206-
User Information:
207-
<span id="name">Name: </span>
208-
<span id="address">Address: </span>
209-
</pre>
210-
211-
</body>
212-
</html>
213-
```
214-
215-
#### The template - after
216-
217-
```html
218-
<html>
219-
<head>
220-
<title>Info</title>
221-
</head>
222-
<body>
223-
224-
<pre>
225-
User Information:
226-
<span id="name">Name: george smith</span>
227-
<span id="address">Address: 45th &amp; Harris</span>
228-
</pre>
229-
230-
</body>
231-
</html>
232-
```
233-
----------------
234-
235-
## The similarities
236-
* Instantiating with the 'new' keyword - same.
237-
* Assigning data to named elements in the markup - same.
238-
* Displaying - Smarty: `display()`; PHPFront: `render()`.
239-
240-
## The differences (lest you think they're the same all the way):
241-
242-
Smarty
243-
244-
* A smarty template is not a standard HTML markup. But a mix of HTML and Smarty's own tags and syntaxes.
245-
* `Smarty::assign()` assigns data to template variables, and you pick up those variables on the template to manually render or loop over.
246-
* A Smarty template file has the file extension .tpl. not .html
247-
* You must learn PHP, HTML and Smarty syntaxes to work with Smarty.
248-
249-
PHPFront
250-
251-
* Any valid HTML markup is a template! And valid HTML markup is valid anywhere - with or without the PHPFront Engine!
252-
* `PHPFront::assign()` assigns data directly to elements in a template. No extra overhead of editing the template using template syntaxes to render or loop over.
253-
* Template file extension is rightly .html
254-
* PHPFront requires no other language. (You've learned PHP and HTML already! And that's all! That's the standard.)
255-
256-
Furthermore, if you know CSS, you can even target template elements by
257-
258-
id: `$PHPFront->assign('#element', $data)`,
259-
260-
Class: (`$PHPFront->assign('.element', $data)`,
261-
262-
Attribute: `$PHPFront->assign('element[attr]', $data)`.
263-
264-
And if you're a pro, find anything on the UI with XPATH query:
265-
266-
XPATH: `$PHPFront->assign('xpath:parent/child', $data)`.
267-
268-
You should by now see the possibilities! See the [official documentation](https://ox-harris.github.io/phpfront/documentation/), and tutorials!

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"classmap": [
2323
"lib/PHPFront.php",
2424
"lib/PHPFrontDom.php",
25+
"lib/PHPFrontElement.php"
2526
"lib/PHPFrontNodeList.php"
2627
]
2728
}

0 commit comments

Comments
 (0)