Sign inSign up

trenchsoftware/php-smarty

By trenchsoftware

•Updated almost 9 years ago

PHP / Apache / Smarty

Image
2

583

trenchsoftware/php-smarty repository overview

⁠Start developing a PHP / Apache / Smarty application.

Do you want to learn how to develop PHP applications using Smarty template library https://www.smarty.net⁠ Now TrenchSoftware brings this to you via Docker. You can test a PHP Smarty Application in a few minutes following this simple instruction.

To get started you need to set up the following folder structure

  • /src -- /src/index.php
  • /smarty/
  • /cache/
  • /configs/
  • /templates/ -- /templates/index.tpl
  • /templates_c/

Now run the following command where #srcfolder# is the target folder for your project you wish to edit. This MUST follow the folder layout shown above.

⁠Code Setup

You will need to create the PHP index file that loads Smarty and the template index.tml

⁠index.php
<?php
require('/usr/local/lib/php/Smarty/Smarty.class.php');
$smarty = new Smarty();

$smarty->setTemplateDir('./smarty/templates');
$smarty->setCompileDir('./smarty/templates_c');
$smarty->setCacheDir('./smarty/cache');
$smarty->setConfigDir('./smarty/configs');

$smarty->assign('name', 'Trench Software');
$smarty->display('index.tpl');
⁠index.tpl
<html>
  <head>
    <title>{$name}</title>
  </head>
  <body>
    Hello from, {$name}!
  </body>
</html>

⁠View your Work

run the following command

$ docker run -p 8080:80 -v #srcfolder#:/var/www/html trenchsoftware/php-smarty

You can now go to http://127.0.0.1:8080⁠ to see your work.

Tag summary

Content type

Image

Digest

Size

176.3 MB

Last updated

almost 9 years ago

docker pull trenchsoftware/php-smarty