6

I used PHP5 a long time ago and am presently trying to refresh my knowledge and augment it with knowledge of Zend Framework 2 and Smarty 3 for a possible project.

I'm currently trying to figure out how to use Smarty 3 as a replacement/supplement to Zend Framework 2.

Everything I can find through Google on this topic either:

  1. Is outdated (e.g. Zend Framework 1)
  2. Assumes I have a more intimate working knowledge about both Zend and Smarty than I actually do.

Can someone please explain to me as though I were 9, using the Zend Skeleton Application as my starting point:

  1. In what directory/folder (using a fully qualified path), I should unzip the Smarty-3.1.12 package?

  2. What class(es) I need to create, what exactly do they need to contain, and where should they be stored?

  3. What files need to be modified, and how, to make Smarty available for viewing within my module(s)?

  4. With reference to the above created classes, how can/should these be used from A-Z (e.g. including within appropriate classes, assigning values, creating outputs)?

hakre
  • 193,403
  • 52
  • 435
  • 836
Brian Kessler
  • 2,187
  • 6
  • 28
  • 58

1 Answers1

8

There is quite good module SmartyModule

Definitely use composer to install it, it makes your life much easier :-)

And sample application

Zdenek Machek
  • 1,758
  • 1
  • 20
  • 30
  • Awesome! Will try this shortly and accept this answer if it works! – Brian Kessler Nov 12 '12 at 19:55
  • 1
    BTW, if you might suggest how composer might be used to install it, that would make my life easier too... Two years ago I never heard of composer and now it seems to come up in almost every discussion of PHP! – Brian Kessler Nov 12 '12 at 19:57
  • The "sample application" seems to be the "Zend Skeleton"... If I understand correctly, this is a fork which adds/utilized Smarty support? And not the same one I've already been toying with? – Brian Kessler Nov 12 '12 at 20:08
  • Yes sample application is indeed modified "Zend Skeleton". I tried it and was working fine, but ZfcTwig - https://github.com/ZF-Commons/ZfcTwig - which is module for Twig, somehow suits me better. I find Twig more intuitive then Smarty. – Zdenek Machek Nov 12 '12 at 21:47
  • I'm not familiar with Twig, but I'll be sure to check it out. :-) – Brian Kessler Nov 13 '12 at 08:53
  • Unfortunately, Zend Framework has "been re-factored" since the Zend Skeleton was forked and SmartyModule developed. I think I was able to debug the Zend Skeleton, but SmartyModule requires Zend\Module\Consumer which doesn't seem to exist any longer (or at least not such that I can readily find and debug the SmartyModule code). It's amazing Zend Framework is so popular when it seems to so completely inconsistent between versions as to make so much documentation, discussion, and development entirely useless. – Brian Kessler Nov 13 '12 at 10:01
  • If anyone else is trying to get this solution to work, at the very least (1) You will need to copy init_autoloader.php from the master Zend Skeleton into this fork; and then add require 'init_autoloader.php'; to the top of public/index.php (2) Within index.php also: Change all references to Zend\Module\Manager\Listener to Zend\ModuleManager\Listener and replace "events()" with "getEventManager()". – Brian Kessler Nov 13 '12 at 10:06
  • Correction: the above only _partially_ debugs the modified skeleton as the skeleton still looks for "Zend\Module\Consumer\AutoloaderProvider" which no longer seems to exist... which I think is not necessarily a problem with SmartyModule, except that perhaps integrating Smarty requires some sort of equivalent since I find another attempt at integrating the two which also seems to rely on this. – Brian Kessler Nov 13 '12 at 10:42