How can Smarty 3 be Used with Zend Framework 2?
Asked Answered
E

1

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)?

Envoy answered 12/11, 2012 at 13:52 Comment(0)
D
8

There is quite good module SmartyModule

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

And sample application

Destructible answered 12/11, 2012 at 14:37 Comment(8)
Awesome! Will try this shortly and accept this answer if it works!Envoy
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!Envoy
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?Envoy
Yes sample application is indeed modified "Zend Skeleton". I tried it and was working fine, but ZfcTwig - github.com/ZF-Commons/ZfcTwig - which is module for Twig, somehow suits me better. I find Twig more intuitive then Smarty.Destructible
I'm not familiar with Twig, but I'll be sure to check it out. :-)Envoy
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.Envoy
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()".Envoy
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.Envoy

© 2022 - 2024 — McMap. All rights reserved.