How to integrate zend framework in an existing website - zend-framework

I'm currently learning Zend Framework and now I am looking for a way to integrate it into an existing website. This website is coded in an extremely complex spaghetti way, and I am hoping that it will be easier to read by integrating it into Zend and slowly refactor it. How could i run legacy code and the zend framework + mod_rewrites side by side?
Greetings,
Bas

Since you don't give any information on how your current site is structured, there's absolutely no way to answer this question.
Some guidelines though : make sure you first tackle routing, you could probably solve this by including your current scripts in the relevant controller actions. After routing is ok, you can have a look at rewriting the interactions so you use ZF's Zend_Request/Response and afterwards start integrating other Zend Framework functionality (ie. Zend_Acl/Zend_Auth for user permissions and authentication).
BTW It might be a lot easier to start from scratch and do a clean rewrite, picking up pieces of existing code as you go...

Related

Is it necessary to learn Zend Framework before learning Magento?

i am newbie in Magento and wants to learn Magento effectively. i know Maegnto is based on zendframe work. i have not worked in Zend framework before.
Is it necessary to learn Zend Framework before learning Magento ??
It is not necessarily required to learn the Zend Framework before.
But it sure helps if you understand the general paradigm of Model View Controller (MVC) to get a better grasp of the system.
While Magento relies heavily on the Zend Framework, it does things its own way in many aspects, so if you want to learn Magento, I would recommend diving right into learning Magento and learning Zend framework on the way where appropriate.
Good in depth tutorials to get started as a developer are:
http://www.magentocommerce.com/knowledge-base/entry/magento-for-dev-part-1-introduction-to-magento
No.
While it would be helpful, I've practically learnt Magento from not knowing anything beyond Python and C#. Programming knowledge and HTML/CSS knowledge is useful, but you don't need to know the in's and out's of the framework to be able to use it.

Migrating from one PHP framework to another

I'm working with a web company that's approaching a point where it will likely need re-think the product as a V2 - due to outgrowing some of its V1 foundations and principles that have been built into virtually everything, from the data model to the user interfaces. For various reasons, this evolution might involve a migration from CakePHP (with which the V1 has been built) to Symfony or Zend.
I would like to ask for some experienced views on how people might have managed a transition like this for a website that has significant traffic and generates revenue. I don't want to open up a discussion on the pro's & con's of different PHP frameworks, or why this migration might be needed. Rather, I would be very interested in hearing whether there are some practical alternatives to essentially building a V2 from scratch alongside the V1 for a couple of months - and locking up precious coding time for the duration of this intense period. An example of such an alternative might be migrating an app in parts over a longer period of time.
I'd be grateful for any views from people who might have managed or been involved in such transitions.
Thanks in advance.
Symfony makes it very easy to break out of the framework at almost every level in the process, making it easy to integrate with other frameworks. Here's how I would do this:
Set up and install Symfony.
Put the existing CakePHP project inside of Symfony as a plugin.
Set the plugin to have a catch-all route that takes the parameters and processes it as a Cake PHP request. Now you have all your CakePHP pages working in Symfony. This is probably the trickiest step and may involve resolving some autoloading or other collision issues.
You can now selectively migrate CakePHP models, controllers, and views.
A major benefit of this approach is that it lets you maintain an agile development process. You can port little bits of the website at a time all the way through and test them as you go.
If you will be moving to Zend, you can start using Zend Classes one-by-one to help you with basic tasks. You can very well use any model class with ZF. So only think that will need that 'big bang' action will be the controllers/views. In fact you can also integrate your existing views with ZF. But I think that'S an overkill and it will not last very long...
So - wrapped up
switch to zend classes for basic tasks like RSS generation, emails, validation, etc. That will help you in the next step.
make the big bang action and switch (m)VC to ZF, leave models
switch models to something more Zend-ish

Zend Framework - Ruby on Rails has a screencast showing how to code a blog in 15 minutes. Does ZF have a similar screencast?

Ruby on Rails has a screencast presentation they use to promote their framework that shows how to code a basic weblog system in 15 minutes with RoR. Does the Zend PHP Framework have a similar screencast/presentation/whatever demonstrating something similar? It doesn't have to be a blog specifically, but I would definitely like to find a presentation that shows some rapid application development using ZF.
Where I'm coming from: I have been programming on and off for years now. I started out with QBASIC waaaaay back in the day making little programs (text adventure games, screensavers, simple little things). I then moved to C++ but never really did anything too impressive with it. Since then (probably 5 years or so now) I have started to use C# for my desktop development and PHP for my web development. I've made some pretty cool tools here and there, but am certainly not a professional programmer by any stretch of the term as it has always simply been a hobby of mine.
Right now I have two major web applications that I will start work on shortly. (Like tomorrow, or later tonight ideally.. :) ) Both will be database-driven apps that will require user registration, the ability to manipulate data that is specific to their account (their posts, listings, user account details, etc), amongst other things.
Currently I am evaluating different frameworks to help me develop these web apps more quickly. I've been looking at, and have heard good things about Ruby on Rails. Hulu and YellowPages.com using it is an obvious endorsement - Of course, I have heard about the scalability issues that it potentially has; but that shouldn't be an issue with what I am working on. I don't expect millions of users per day for either project.
I am also seriously looking at the Zend Framework for my needs because I already have some experience with PHP. Ideally I would like to find a ZF screencast that shows an app being written quickly so that I have a roughly equal comparison between the two options I am exploring and can see first-hand how things get done in both.
That said - I am not opposed to considering frameworks other than RoR or ZF. The only research I've done on the subject has been over the past couple of days so I am quite certain that there are other excellent options out there that I've not even looked at - or heard of. Of course, it'd be awesome if there is a rapid app dev presentation that I can watch for whatever else is suggested.
So - Suggestions? Links to good screencasts that show rapid application development in other frameworks? Are there other PHP frameworks that I should be considering? (Ones that are easy to deploy would be ideal, so I don't have to purchase a dedicated server that I have full control over. I'd like to keep my hosting costs down assuming that it's reasonable)
Thanks in advance!
-Sootah
You can checkout ZendCasts.com
However, when deciding between ZF and RoR, you should be aware that they are very different from each other. RoR is a full stack with integrated ORM built on AR and a rather rigid structure. It's powerful and there is lots of magic inside and I'd say it's RAD capabilities are above ZF due to rake being more powerful than Zend_Tool
ZF, on the other hand, is first and foremost a loosely coupled component library with a use-at-will architecture for maximum flexibility. You can use it's components together, but you don't have to. While it does feature convention over configuration, ZF doesn't take you by the hand too much. It expects you know how to walk. Also ZF has no full fledged ORM and no AR, but you can very much integrate Doctrine or Propel or whatever library you like to use.
You often hear folks new to ZF complain about it is hard to get into it, simply because they expect ZF to work like RoR or Symfony or Cake, e.g. a full stack framework
EDIT:
Cake aims to be a port of RoR to PHP. It is built around ActiveRecord. Like CI < v2, it is backwards compatible with PHP4, which means it doesn't fully utilize the OOP capabilities you get in PHP5. I'd say both are easier to get in than ZF though.
This is a common question on SO.
I posted some valuable links in my response to this post
If you Google for such tutorials, look for Zend Application or Zend Tool, not ZF.
The difference between the other frameworks and Zend Framework is that Zend Framework is rather a general purpose framework, not application framework (not only for MVC, HTTP). E.g. Google uses ZF to provide access to their services.
You may easily use Symfony or CodeIgnitier with Zend Framework together.
BTW, To be precise, tutorials you ask are not blogs, but just a simple CRUD controllers. You may use Wordpress to create blog in 15 minutes, (then customize it) but not a PHP Framework.

AJAX or a server side framework?

I am working with a friend on building a web site, in general this web site will be a custom web app along with a very custom social network type of thing..
Currently I have a mock-up site that uses simple PHP with AJAX and JSON and JQUERY and I love how it works, I love the way it all fits together.
But for a mock-up I did not implement any of the Social Network design patterns such as a login, rating, groups etc..
This brought me to a higher level of decision making requirement, I need to decide if I want to develop all this functionality by hand or use some kind of a framework.
I spent this entire day researching, and it would seem that using Drupal and such frameworks will make the Social Network part easy (overlooking the customization requirement for now..) but will make client side Web App development less so.
I found some other frameworks that are more developer friendly (customizable) such as Zend and Symfony etc.. but these seem to take allot of the power from the client and implement it in the server side, to me this seems a waste (and an unjustified performance bottleneck) ..
Finally I found Aptana Jaxer framework that seems to think the same way I feel.
That said it seems a bit under-developed, I didn't find modules for a social network and the community around it seems thin.. (searching Jaxer in StackOverflow returns few results)
So other then making server side DB comm a bit simpler it does not help me greatly..
My requirements are a good facility to develop web apps on while containing all the user centric logic usually used for social networks in advance.
What would you recommend?
EDIT:
OK, lats fine tune this question, after considering this abit further, is there a good down loadable source of a social network site in PHP that I can work around in building my web app? (I really like using JQUERY AJAX JSON etc..)
if you want to develop a social networking site from scratch, i recommend using zend-framework as a server side framework and jquery as a client side framework.
they have a lot of library which you can use such as zend_auth,zend_acl for user authentication system and Zend_Search_Lucene for search facilities and zend_gdata for youtube videos and so on.
but you can also use one of the several social networking engines available out there.
here is a link:
http://www.best-php-scripts.com/social_networking.htm
I think it depends on the goal your trying to achieve.
Personally, I tend to like to keep things simple and to decouple complex
things in smaller components, so it's easy to stay in control when you'll
incrementally add new features.
Ajax or a server-side framework ? I'd say that they're not necessary overlapping
each others. However some (server-side) frameworks tends to wrap everything in a
single zipped package to make things easier for beginners. I personally don't
like this avenue because it will make your web app dependable on this framework.
Thus, nothing prevents you to use one client-side framework for the presentation
logic and another one for server-side/business logic.
Hth,
Etienne

Difficulties when learning Zend Framework 1.8

I am a newbie of Zend Framework.
I downloaded the Zend Framework and then followed the official quickstart tutorial to build a very simple registration form. But after that, I find very hard to learn different elements of Zend Framework.
Many tutorials mention frontController and registerAutoload() in the bootstrap file. However, it seems that I can't see it again in the code in version 1.8 (both in the official quickstart tutorial and Getting Started with Zend Framework 1.8). Many tutorials contain the old version of code and it seems very different in v1.8.
I start with writing registration form with password confirmation. I read the official document and find the custom validator for password confirmation. It just puts the class there and doesn't mention how I can use it. I don't know where I should put this file and I can't find any hints in Google. The "class not found" error always makes me sick (I've tried addPrefixElement, set_include_path but they don't work).
User registration, email activation, login, access control are very common tasks. But I don't even find a piece of sample code in v1.8 that I can run in my machine. I am very frustrated about Zend Framework.
Does anyone give me some advices?
I have also just started learning the zend framework. I also find alot of old tutorials that make learning confusing and hard,
but there are some resources that I find help in learning the zend framework:
http://www.zendcasts.com/ - they have tutorials on ZF1.8 already, like Bootstrapping using Zend_Application, etc.
Some useful blogs that might help:
http://weierophinney.net/matthew/
http://www.thomasweidner.com/flatpress/index.php
http://smartycode.com/zf/
http://codeutopia.net/blog/
Forums to ask your questions:
http://www.nabble.com/Zend-Framework-Community-f16154.html - alot of ZF developers seem to be here to answer your questions :) much more than the official Zend Forums below ...
http://forums.zend.com/viewforum.php?f=69
As to class not found, I think you didn't autoload?
http://framework.zend.com/manual/en/zend.loader.autoloader-resource.html
Parts of Zend Framework have changed slightly in the 1.8 release but everything should be backwards compatible so all code example written using the 1.* release series should still work with little or no modification. The main areas that are different are
Zend Loader (related to register_autoload) which now has several improvements related to performance and some slight differences in its API (with a PHP warning if you use the old way). I wouldn't worry about this too much as a beginner - just follow the tutorial or continue to use include/require statements until you become annoyed with adding them all the time!
Zend Application which basically allows you to create your set-up and initialisation code with less fuss. Again, you don't have to use it and you can happily write a manual bootstrap class to get you used to how the framework is put together.
With regards to getting started I would highly recommend getting your head around the Zend Controller component, particularly the front controller part and this diagram.
For authentication look at Zend Auth, for e-mail see Zend Mail, for access control see Zend Acl and for forms and validation see Zend Form, Zend Validate and Zend Filter. The form and validation components will explain about paths and adding your own custom validators and form elements.
The other area of importance is Zend Db which allows you to persist your data to a database. There is also Zend View which represents the view layer in the MVC stack. In my opinion these are the key components of a basic ZF application. From there you can explore the other components as and when you need them.
Don't forget that the Zend Framework is specifically designed to be loosely coupled and it is very easy to use a different component from another project for a particular task. Sometimes it is necessary to write your own components too. If there is a component you would prefer to use over the Zend component then go ahead and do so.
Honestly, the documentation is very good although it is hard to navigate for beginners. Once you get your head around the core components everything will become a lot clearer.
Also try following this tutorial. It will help explain a lot of the basics.
I recommend these video tutorials pu up by a guy called Alex, he keeps them up to date and releases new ones all the time,they are all relevant to ZF 1.8 and 1.9.
He has even a detailed video tutorial covering ACL, login forms etc. (my first steps with Zend were easier thanks to him!)
http://alex-tech-adventures.com/development/zend-framework.html?start=15
- his site is a bit comfusing but worth the time in figuring it out :)
Cheers
Roman
Some tips:
Here is a nice diagram of the Dispatch process
http://nethands.de/download/zenddispatch_en.pdf
It is much easier to understand ZF if you are experienced in OOP / OOP Design Patterns
When I first stumbled across ZF I had little knowledge of OOP. ZF prompted me to learn OOP which was a very good thing.
Distinguish between the 'magic' of ZF and the actual ZF Architecture
Although I have a good understanding of ZF Classes I still get confused when ZF adds its 'magic' to the mix.
When I say 'magic' I am referring to things like
the default objects loaded and used if none specified, and
url-controllername-filepath-filename inflections / naming conventions.
config settings-to-class-instantiation mappings
ZF is a bit like a crack-dealer in the sense that the 'Getting Started Tutorials' get you hooked straight away. They perform so much magic that it makes you think
.oO(Wow - how simple was that! This framework is cool!)
Then as soon as you start to try to do your own thing - the magic starts to get really confusing.
So - my tactic is to remove as much ZF magic as possible. If you have the option to specify a class to use, or a router to use, then specify it. Don't let Zend do it for you.
Then when something weird is happening you can find the bugs more easily.
Also, if you specify the locations of classes/ paths as (opposed to letting ZF magically inflect paths and find scripts), then you do not have to worry about questions of 'where to put this? , where to put that?' - you just put things where you want them to be and explicitly point ZF to them.
As you get more familiar with ZF you might then want to let it take over and do some magic for you. Only then can you really understand why that magic is convenient.
As Tim Wardle said in another answer - favour require statements over zend loader until you really need it.
If you are a PHP design house that churns out 10 website projects a week, then ZF Magic can be really useful. If you are designing your first ZF app - then 'reducing complexity' is a more important design goal than 're-usability'.
Browse the code
It might seem obvious but one of the best ways to learn about the ZF is to look at the code.
Again the ZF magic can get in the way - I often want to look at a method's arguments to discover what i need to pass in only to discover that it expects an ambiguous 'options array' (not exactly helpful). After a while, though, you start to notice the conventions used in how an 'option key' marries up to a getter/setter method. So, keep looking at the code and familiarising yourself with the 'ZF way'.
I 'ope that 'elps.
The Front Range PHP Users Group website has some presentations on Zend Framework which may be of use.
I have so much sympathy with you Billy. I am a newbie and the confusion between the old way and the new way is almost just too much to handle. Also see here for someone who points out some of the main differences:
http://crossfunctional.wordpress.com/2009/05/
All documentation, particularly Zend's documentation is absolutely horrible. It all assumes that you "know" where to put the snippets they are referring to and how they work together. If I already knew those things, I wouldn't need the documentation. No full example applications with authentication etc. that you can download and modify. I'm seriously regretting putting any time into trying to learning this framework. All examples that I can find are apparently for older versions. I followed one for authentication on youtube that was designed for 1.8 to the letter. It fails to work in 1.9.x. Can't get it to work for the life of me. Completely frustrated with Zend Framework!
Zend Framework has shifted from being a relatively accessible and simple system to a more complex entity. It has gone through a number of rapid developments over the past couple of years which have left a lot of older documentation around.
We have projects that are stuck on Version 1.7.x because the differences between that and the latest version are too great which makes the dev and testing time too expensive.
I like Zend Framework because it has so much depth to it but it is definitely a two edged sword for beginners.
I'd certainly recommend making use of the expertise of other users and search out some simple framework examples. ZF is highly adaptable but you need to try and work from the simplest case possible for your needs.
I think Matthew Weier o'Phinney, (search for 'Phly, boy, phly') is one of the more approachable members of the dev team and has loads of examples and ideas on his website.
Good luck!