How can Smarty 3 be Used with Zend Framework 2? - php

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:
Is outdated (e.g. Zend Framework 1)
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:
In what directory/folder (using a fully qualified path), I should unzip the Smarty-3.1.12 package?
What class(es) I need to create, what exactly do they need to contain, and where should they be stored?
What files need to be modified, and how, to make Smarty available for viewing within my module(s)?
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)?

There is quite good module SmartyModule
Definitely use composer to install it, it makes your life much easier :-)
And sample application

Related

Zend mail code in my php code?

I've got some php code handling emails (not self written) which I want to integrate in my own self written system. In it, two Classes are used:
Zend_Mail_Storage_Pop3($params)
Zend_Mail_Storage_Imap($params)
I've heard of Zend before, but as far as I know it is some kind of full fledged php framework, not something I really what to incorporate in my system just to be able to use these two classes. So I downloaded Zend from the github page, but I can't even find those classes in there.
So my questions are:
Am I able (and if so, how?) to just use these two classes from Zend?
If not, is there an alternative to these two classes which are preferably very easy to use?
All tips are welcome!
It's hard to answer this question without knowing exactly what you want to do (you've just said what classes you think might achieve that goal), but hopefully I can point you in the right direction.
Zend Framework is a full PHP framework, but it was built as a collection of libraries, and to a certain extent you can just cherry pick individual components and only use those. The two classes you listed were from Zend Framework 1. What you downloaded from Github was Zend Framework 2, which is why you can't find them, but ZF2 does have equivalents.
Although you could download ZF1 and get your existing code to work, what I'd suggest you do instead is add just the ZF2 Mail component to your app using Composer. Then start here: http://framework.zend.com/manual/2.3/en/modules/zend.mail.read.html for the docs for the equivalent classes for what I'm guessing you're trying to do.

May I use zend framework together with php files not using it

I am now working in a team to build a website using php. Told that Zend framework can be fairly convenient, I hope to use it to write the pages. However, some of the members in the team did not use the framework in their previous works. I do not know whether there will be any possible problems if their works are used together with mine? So I wonder whether it is possible for us to use Zend frameworks for part of the website while other members of the team do not use this framework to build the rest of the website? Thank you.
i not really sure to undersand your question
but it's look complicated to use ZF for a part of the site, and PHP for the other. However, it's possible. You can, with a .htaccess say that an URL is not define by ZF (i ever used it for a blog attached on a ZF site)
Don't hesitate to comment for any other answer
It depends on how you are splitting up the work. Zend Framework is modular so you are not tied into using the whole framework. You can just select the components you need. I would advise that you use one framework for your application startup and routing at least. Merging these part would be a hassle to maintain imo.

How to independently use single Zend Framework component like XML-RPC or REST?

Zend framework is well known for loosely coupled components.
I would like to use XML-RPC from zend framework, is there any dependency for XML-RPC? Like if I had taken out XML-RPC folder off Zend Framework Library and try to instantiate RPC object, would it throw error?
Where can I find the proper way of separating component from the framework?
Thanks
I wrote a tool which takes ZF components and their dependencies so you can easily take just one (or several) component from ZF.
http://epic.codeutopia.net/pack/
It doesn't have the latest ZF release 1.11 (because I'm lazy), but 1.10.6 should work just fine.
You should never split single components off a framework or library independent from Zend Framework, or any other. Especially when using PHP there is also no performance reason, because with PHPs autoloading functionality it will always just include the files, which are requested.
You should literally be able to copy the XmlRpc folder from your copy of Zend Framework and use it in your own projects. The only dependency that I can see is in XmlRpc/Exception.php as it requires a file in the root directory of Zend/ (Exception.php) you could simply copy this file along with the XmlRpc folder keeping the directory structure the same and it should work....
My first question is why you would want to do that in the first place. It means that every time you upgrade Zend Framework you now need add a bunch of tooling to manage the removal of some components. One of the purposes of using a framework is so you don't have to manage a bunch of code. Removing parts of a framework is a step backwards IMHO. Disk space is cheap. Network transfer is cheap. If you are going to remove parts of a framework you should have a REALLY, REALLY good reason to do it.

Use Zend Framework components without the actual framework?

I was wondering if anyone knew how to use some components of the Zend Framework without having to actually use the framework. For example, I would like to use their Zend_Validate components, but don't want the overhead of the framework as it's a small one-page script.
Can this be easily done, and if so, are there guides/tutorials on how to accomplish it?
Zend framework components are intentionally designed to be loosely couple from the framework itself.
The component structure of Zend
Framework is somewhat unique; each
component is designed with few
dependencies on other components. This
loosely coupled architecture allows
developers to use components
individually. We often call this a
"use-at-will" design. [from here]
Here's a tool for pulling out specific components and their dependencies to use in your application.
I've just grabbed the whole Zend package, and used pieces of it. It always seems I end up using more of it as time goes on, so I keep it up to date even if I'm not using some of the MVC stuff in one project or another. Holding on to the whole thing makes you not have to worry about the dependencies (and how they might change down the road).
Zend framework components while being loosely couple are still coupled. If you would to use Zend_Mail component for example - that would actually also require:
Zend_Mime
Zend_Exception
Zend_Validation
Zend_Validation will be loaded for the mere reason of validating email address domain.
So - best bet would be to include entire Zend library. By pulling only several components - you'll soon end up in "dependency hell" especially as API changes (though that doesn't happen too often).
Also - starting from version 2.0 you must use some auto-loader to load Zend components as all require calls will be removed from PHP classes.

Beginning Zend Framework

I've read a couple of Related questions by the site, but can't find what I'm looking for.
After having done normal PHP without much extra(by which I mean a templating system) for a year now, I feel like trying Zend. Simply because it's the biggest name. I wanna try CakePHP too later.
I've been looking into the examples, but these are all inline-code examples.
In learning PHP, I've used a template system, in order to keep the PHP and the HTML completely separated. Is this possible with the Zend Framework, or should I use a template system alongside it?
Also, what's the deal with executing several .bat files? Is there really so much work in setting up folder-structures with the correct files in them should you did it manually?
Zend Framework is a quite good solution to use as separate modules or complete package as well. You can use only it's templater system (but it's not so super) or you can put on a whole system using Zend_Application, Zend_Controller, Zend_Db, Zend_View, etc.
The .bat (or .sh) file is for the Zend_Tool. It's an experimental command line tool to build modules and applications easier.
I guess you can use zend's built in template solution that comes with Zend View, roll your own, or even integrate something like Smarty. At the end of day, its your call. Zend is fairly flexible in terms of which of its component you want to use and which you don't.
frankly for me these components do the most of work and i dont think i will need more than
(Zend_view , Zend layout , Zend navigation ,Zend breadcrumb)
it's most likely to keep the PHP and the HTML completely separated
about zend tool : its just tool to make Zend development much easier
I highly recommend you take a look at the online tutorial found here. It's a step by step walk through the framework showing you the basics of how you'd build a small Zend Framework app, and shows you how to integrate things like access control, interface with the database, etc. It's written in really understandable language with great source code included.
As for the batch files, you may want to download a demo copy of Zend Studio. It allows you to create a ZF project and does all of the setup for you without requiring you to mess with the command line.
Good luck!
I highly recommend you must first understand the basic directory tree of Zend Framework including all setup needed and familiarization with bootstrapping and setting configurations with a .ini file.

Categories