Download Web App. Framework

yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Information privacy law wikipedia , lookup

Clusterpoint wikipedia , lookup

Expense and cost recovery system (ECRS) wikipedia , lookup

Business intelligence wikipedia , lookup

Semantic Web wikipedia , lookup

Web analytics wikipedia , lookup

PHP wikipedia , lookup

CSC 2720
Building Web Applications
Basic Frameworks for Building
Dynamic Web Sites / Web Applications
Web Application Framework
 A web application framework is a software
framework that is designed to support the
development of dynamic websites and Web
 Aims
Improve productivity
Promote code reuse
Minimize errors
Reduce cost of maintenance
 Input:
 Extract form data, cookies, etc. from a HTTP request
 Process
 Validate data, authenticate user, check access right, etc.
 Retrieve data from or update data in the storage layer
 Apply business logic
 Output
 Format the output in HTML and CSS
 Write PHP scripts to conditionally or iteratively generate
the output
Suggestion: Organizing the contents in a PHP script
// Validate input
// Process the input
// Store the output (including error status
// and messages if there is any) in some
// designated variables
<!-Contains mainly HTML, CSS, and PHP scripts that
deal with presentation logic
Suggestion: Organizing the contents in a PHP script
 Commonly used codes should be made into
functions and placed in separate files (so they can
be reused). For examples, codes to
Authenticate a user
Establish a database connection
Retrieve data from a database
Validate the format of an email address or a credit card
 Codes that make up the business logic should also
be placed in separate files.
Modular Design
Presentation Layer
Commonly used
Business Logic
Data Access Layer
(PHP Functions to retrieve, store, or update data)
Data Storage Layer
(Database, Files, etc.)
Model-1 Architecture
Input Validation + Business Logic
Presentation Logic
Model-1 Architecture
 Each PHP page is regarded as the focal point for
the entire application.
 Each PHP page
 Contains code for extracting HTTP request parameters
and call the business logic
 Contains the presentation logics
 Adv: Easy to add/remove pages
 Suitable for small/simple application
Model-2 Architecture
controller.php can
pass the necessary
data to page1.php via
some global
if ($action == 'p1') {
Input Validation + Business Logic
Presentation Logic
Note: These files can be
placed in a folder that
cannot be accessed directly
via a URL.
Model-2 Architecture
 One PHP script serves as a controller that
 Handles requests, setup sessions
 Performs authentication, validation
 Decides what logic to invoke or which PHP script to
handle the business logic
 Decides which PHP script to be used to present the
 Adv: One entry point to the web application (easier
to enforce access control and perform user
 Suitable for large or complicated application