PHPFront logo
PHPFront Online Documentation now available! PHPFront is available on Composer: composer require ox-harris/phpfront Contact us to place an ad here...

PHPFront

HTML templates should be codeless - free of any PHP $codes and other syntaxes that are not part of the HTML standards.

  • HTML should be used as is!
  • PHP should do all its magic on the backend, not on the frontend.
  • And all the weird {tags} of those syntax-based template engines are also uncalled for!

So how do you echo or show $variables in HTML without mixing codes?

Very simple! That's why we created PHPFront

  1. On the PHP side, assign those $variables to the HTML elements
  2. On the HTML, just leave the elements untouched!

Really? Show the Code
...
                
include 'PHPFront/lib/PHPFront.php';

// create object
$PHPFront = new PHPFront;

// assign some content. This would typically come from
// a database or other source, but we'll use static
// values for the purpose of this example.
$PHPFront->assign('#name::after', 'george smith');
$PHPFront->assign('#address::after', '45th & Harris');
		  
// set a template to use
$PHPFront->setTemplate('index.html');
// display it
$PHPFront->render();

                
                
<html>

<head>
<title>Info</title>
</head>

<body>

  <pre>
  User Information:            
  <span id="name">Name: </span>
  <span id="address">Address: </span>
  </pre>

</body>

</html>

                
                
<html>

<head>
<title>Info</title>
</head>

<body>

  <pre>
  User Information:
  <span id="name">Name: george smith</span>
  <span id="address">Address: 45th & Harris</span>            
  </pre>

</body>

</html>

                

Compare with
...
                
/**
 * This example was taken from the Smarty website
 */
  
include 'Smarty.php';

// create object
$Smarty = new Smarty;

// assign some content. This would typically come from
// a database or other source, but we'll use static
// values for the purpose of this example.
$Smarty->assign('name', 'george smith');
$Smarty->assign('address', '45th & Harris');
		  
// display it
$Smarty->render('index.tpl');

                
                
<html>

<head>
<title>Info</title>
</head>

<body>

  <pre>
  User Information:            
  Name: {$name}
  Address: {$address}
  </pre>

</body>

</html>

                
                
<html>

<head>
<title>Info</title>
</head>

<body>

  <pre>
  User Information:
  Name: george smith
  Address: 45th & Harris            
  </pre>

</body>

</html>

                
                
/**
 * There is nothing to set up.
 */
  
// assign some content. This would typically come from
// a database or other source, but we'll use static
// values for the purpose of this example.
$name = 'george smith';
$address = '45th & Harris';

                
                
<html>

<head>
<title>Info</title>
</head>

<body>

  <pre>
  User Information:            
  Name: <?php echo $name ?>
  Address: <?php echo $address ?>
  </pre>

</body>

</html>

                
                
<html>

<head>
<title>Info</title>
</head>

<body>

  <pre>
  User Information:
  Name: george smith
  Address: 45th & Harris            
  </pre>

</body>

</html>

                

Wonderful!
But what's wrong with plain PHP?

  • Plain PHP on templates is against the code separation best practice, and this causes so many issues
  • Interestingly, separating PHP from HTML is now much the same as separating CSS from HTML

And, what really is PHPFront?

Syntaxless Template Engine for PHP!

PHPFront is a fully-featured template engine for PHP that uses no template syntax. It facilitates the separation of application code (PHP) from presentation code (HTML). It helps you associate contents from inside your application to elements in a HTML template.

Plus, you can do so many interesting things - when you want to! It is built for everything templating!
And mark our word: everything about PHPFront is within the boundaries of web standards and conventions.




PHPFront - Making the front & back ends meet. Coded with love by Ox-Harris

Sites Using PHPFront

  • This website is first – you would ofcourse expect that.
    - And it was dead simple & fun building with PHPFront!
  • You no doubt want to get your project listed.
    - Send us a mail on phpfront@gmail.com.