Powered By
Showing posts with label MVC. Show all posts
Showing posts with label MVC. Show all posts

MVC Directory Structure

View Comments
add to del.icio.us
saved by 0 users
The Directory Structure



I am sure this has great naming convention and we all could understand easily why we are having these folder structure.

application - application specific code
config - database/server configuration
db - database backups
library - framework code
public - application specific js/css/images
scripts - command-line utilities
tmp - temporary data

Once we have our directory structure ready, let us understand a few coding conventions.

Coding Conventions

1. mySQL tables will always be lowercase and plural e.g. items, cars
2. Models will always be singular and first letter capital e.g. Item, Car
3. Controllers will always have “Controller” appended to them. e.g. ItemsController, CarsController
4. Views will have plural name followed by action name as the file. e.g. items/view.php, cars/buy.php

So you know the directory structure of MVC/Zend framework. So now we will start implementing this in real project. Let me explain more detail in next post.

and also there are many other standard frameworks, each one having their own advantages, and zend framework provides great security than anything else we just moving with zend and we will be seeing all the frameworks.

The other frameworks are

Cake PHP
Code Igniter
Symfony
Prado

To know more about zend just check out this

Zend

For more about Php Frameworks please stay with us for some time.

Read More

Example of MVC Architecture

View Comments
add to del.icio.us
saved by 0 users
Example of MVC architecture:

1. When the user Log In on the login page, a request is sent to the servlet handler.

2. The servlet handler dispatches the request to the appropriate control class. In this case, Login control.

3. The Control performs the action requested by the user on the Model; in this case the Login Model.

4. The Model returns a response; in this example, a successful login message.

5. The Control either redirects to another page or returns to the same page with new data since the Model has
been updated. In this case, the Control redirects to the MyPage.

6. The Interpreter gets the HTML for the page requested by the Control from the appropriate View, in this
case the MyPage View

7. The View returns the HTML for the page.

8. The Interpreter sends the HTML for the page back to the browser.

This is what happening while you are using MVC architecture. Isn't it structured and understandable. Am sure your answer is yes. So in coming posts we will develop a simple MVC application using php with the help of ZEND framework.
Read More

Model–View–Controller using ZEND framework

View Comments
add to del.icio.us
saved by 0 users
Model–View–Controller

Model–View–Controller (MVC) is an architectural pattern used in software engineering. Successful use of the pattern isolates business logic from user interface considerations, resulting in an application where it is easier to modify either the visual appearance of the application or the underlying business rules without affecting the other. In MVC, the model represents the information (the data) of the application; the view corresponds to elements of the user interface such as text, checkbox items, and so forth; and the controller manages the communication of data and the business rules used to manipulate the data to and from the model.


The main aim of the MVC architecture is to separate the
business logic and application data from the presentation
data to the user.

Here are the reasons why we should use the MVC design pattern.

1. They are resuable : When the problems recurs, there is
no need to invent a new solution, we just have to follow the
pattern and adapt it as necessary.
2. They are expressive: By using the MVC design pattern
our application becomes more expressive.

1). Model: The model object knows about all the data that
need to be displayed. It is model who is aware about all the
operations that can be applied to transform that object. It
only represents the data of an application. The model
represents enterprise data and the business rules that
govern access to and updates of this data. Model is not
aware about the presentation data and how that data will be
displayed to the browser.

In simpler terms

Model handles all our database logic. Using the model we connect to our database and provide an abstraction layer.

2). View : The view represents the presentation of the
application. The view object refers to the model. It uses
the query methods of the model to obtain the contents and
renders it. The view is not dependent on the application
logic. It remains same if there is any modification in the
business logic. In other words, we can say that it is the
responsibility of the of the view's to maintain the
consistency in its presentation when the model changes.


In simpler terms

Controller represents all our business logic i.e. all our ifs and else.

3). Controller: Whenever the user sends a request for
something then it always go through the controller. The
controller is responsible for intercepting the requests from
view and passes it to the model for the appropriate action.
After the action has been taken on the data, the controller
is responsible for directing the appropriate view to the
user. In GUIs, the views and the controllers often work very closely together.


In simpler terms

View represents our presentation logic i.e our HTML/XML/JSON code.
Read More

What is MVC Architechture

View Comments
add to del.icio.us
saved by 0 users

If You are planned to develop a project(Stand alone application/Web development) you have to look into many aspects regarding security,code readability and re-usability,understanding and many aspects as per your project goes.

What ever your project domain or what ever your technology chosen for project you will be having directory and file structure. Or else the total system will be confusing and some times the whole project concept will be clopsed. So you should be careful on directory and file structure once you finished your project requirement analysis, and another reason for security reason also you should follow a structured way of programming.


Whether you can define your own file structure or you can have already built in architectures.


If you are planned to write your own file structure means have these things in your mind.

1. Storage

2. Programming

3. GUI


Even stand alone or web application you should have these analysis.

Or if you are planned to use built in architectures means i always recommend you just know about MVC and you will be happily programming. Especially when it comes web application it supports you more than you expect.

Because it is not technology dependent. You can use it in PHP/ASP/JSP

What is MVC Architecture?

The main aim of the MVC architecture  is to separate the business logic and
application data from the presentation data to the user.

Advantages of MVC

1.Modifying isvery easier
2.Clean separation of roles
3.Easy to maintain and future enhancements
4.Parallel development
5.Gives the good productivity

Dis-advantages

1.For parallel development there is a needed multiple programers
2.Knowledge on multiple technologies are required

If you can able to manage above to disadvantages in your project means then i am sure you will be using MVC architecture.


Read More