Zend framework techniques - model-view-controller

I am trying to migrate to zend framework. Should each webpage be a Controller or an action.
What is the advantage of having multiple actions. Can they talk to each other? and whats the best use of Action helpers and View helpers.
Please guide me on how to start on the framework.. thanks

You can use a new controller for each page or define multiple actions on the same controller to render your pages. I choose to use defferent action from the same controller to display variuos pages. Using multiple action on the same controller allows you to put some code in che constructor of the controller that is executed for each action. For example i have a controller for all the pulic pages of a website and a new controller for those pages that are reserved to registered users. In the constructor for the controller dedicated to registered user i do the check for authentication.

You should check that page about MVC applications, It's not precisely related to Zend. But you seems to be asking what a MVC Design Pattern is.

You got to create a controller for each of your site's pages. If any page interacts with db, you should also create model for that page. Also you should create view for each of your page.
If you have no idea about MVC, you can read this:
MVC

Those links are from Zend Framework manual.
Do not afraid and click - read the Introduction chapters - you will have all answers. ;-)
View helpers
Action helpers
Action Controllers

First get a sound understand of MVC Framework:
Understanding MVC Architecture from its Origin (part I)
http://learnnewprogramming.com/blog/understanding-mvc-architecture/

Related

What specifically is the Model, View, and the Controller in a MEAN Stack app?

So I've been reading/viewing a variety of tutorials about MVC. I am most familiar with building MEAN stack apps, and but am now a little confused on how I thought the MVC worked.
From my understanding in a MEAN stack app the MVC is like: the view is HTML/CSS, the Model is JavaScript(Data and logic of storage objects), and the Controller includes the Controllers, Factories, and Services? (This is where I'm mostly confused). But then I saw a tutorial that explained the whole client side to be the View, the server was the Controller, and the database was the Model.
Does this mean the MVC pattern can be applied to the front and back end of an application? If so, then a MEAN stack app has two MVCs?
As I understand it, usually the MVC pattern only applied to the front end of an application.
May be this website can help you more : https://evincedev.com/blog/mean-stack-architecture/
Angular doesn't have MVC architecture. It follows MVVM (Model View ViewModel) architecture. Usually in MVC a database acts as a Model, Server acts as a Controller and front end is the View.
In Angular Controller is replaced by ViewModel. ViewModel acts as a connection between the View and Model. View is written in html files, Model is usually written in Services, ViewModel is written in Controllers.

Create custom controls in asp mvc 3

I have to create custom controls in ASP.NET MVC 3. Controls like customized buttons which I will put in DLL and reuse in any project.
Do you know a good way or maybe you can give me a good tutorial to do this.
Thanks.
You can't, WebControls are for Web Forms. In asp.net mvc anything view related(html, javascript, css) is decoupled from the controller. The best you can do is to have helpers which are simply extension methods. But something similar to the webcontrols is specific to web forms only.
This post and this should give you an idea
You would need to use Partial Views to re-use code.
http://rachelappel.com/razor/partial-views-in-asp-net-mvc-3-w-the-razor-view-engine/

Static pages in MVC framework?

Where do you guys put your static pages, like "home", in an MVC framework? Do you have a "home" controller? A "pages" controller? Do you create actions for each static page?
I'm using CFWheels now, and I'm trying to figure out the best place to put them.
Edit: Apparently CFWheels doesn't require you to create actions for all your views. So you can just create an empty controller and call the views like actions, but not have to write out the blank functions.
CakePHP (and I guess, Ruby On Rails) has a "pages" controller. There is a routing function which redirects requests to /pages/foo to /pages/display/foo. Similarly, / is redirected to /pages/display/home. The display action looks up the views/pages folder for any file with a matching name and renders that.
At the end of the day, a static page is a view without a model, that was returned based on an action the user requested from your server by hitting particular route. :-)
Yes, technically you could expose the direct location of the view resource to the user and rely on the http daemon to go fetch it and return it. However, that means that the resource URL is now tied not to the semantic of the resource you want to expose, but to actual bits. This means that if you want another representation of that same resource, you have to expose it on a different URL.
So, when you create the structure of your web app, think first about the URLs and the resources you want to expose and then think how to implement each resource.
I put my static pages in the database using a simple CMS with a private admin page.
This way, the clients can make simple changes themselves.
In Wheels, you don't even need to create the controller file.
If you create your view here:
views/about/index.cfm
You don't need to create the controller file at all. Then you should be able to just call this with no problems:
http://www.example.com/about

Does MVC normally have a separate Controller for every View?

I'm just browsing MVC examples so far, and I think I'm getting a handle on it. For my project - an embedded system on ARM9, no Windows/ASP at all - we are considering doing all the UI as MVC. Does MVC also require a strict Tree of all UI Views (one root?)
No, one controller may have different views for different actions.
You can split the controller into a front controller and several actions.
As reference see The MVC Pattern as implemented into Symfony framework.
If your views are parts of a full page you might also use the same view from different controllers. Ie header and footer.
A controller can have many views and partial views. If you take a look at some simple ASP .NET MVC tutorials: http://www.asp.net/mvc/tutorials/mvc-4/getting-started-with-aspnet-mvc4/intro-to-aspnet-mvc-4 you'll learn how this can be done easily.

MVC Pattern in cakephp

Could someone explain me about MVC pattern? How does it help cakephp framework?
MVC stands for Model, View, Controller.
Model = Data (Database tables)
View = HTML, CSS, JavaScript, etc
Controller = Main logic, a contract between Model & View.
In simple and graspable terms,
MVC allows you to develop your applications in a way that your business data and presentation data are separated. With this, a developer and designer can work independently on a MVC app without their work clashing. MVC makes your app avail OOP too.
Have a look at the respective section in the cookbook.

Resources