Download presentation
Presentation is loading. Please wait.
Published byMildred Pitts Modified over 9 years ago
1
CSC 2720 Building Web Applications Basic Frameworks for Building Dynamic Web Sites / Web Applications
2
Web Application Framework A web application framework is a software framework that is designed to support the development of dynamic websites and Web applications.web application framework Aims Improve productivity Promote code reuse Minimize errors Reduce cost of maintenance
3
Input-Process-Output 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
4
Suggestion: Organizing the contents in a PHP script <?php // 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 -->
5
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 number. Codes that make up the business logic should also be placed in separate files.
6
Modular Design Presentation Layer Data Access Layer (PHP Functions to retrieve, store, or update data) Data Storage Layer (Database, Files, etc.) Business LogicCommonly used Functions
7
Model-1 Architecture page1.php Input Validation + Business Logic Presentation Logic page2.phppageN.php … http://website/app_folder/page1.php
8
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
9
Model-2 Architecture page1.php Input Validation + Business Logic Presentation Logic page2.phppageN.php … http://website/app_folder/controller.php?action=p1 Note: These files can be placed in a folder that cannot be accessed directly via a URL. if ($action == 'p1') { include("page1.php"); exit(); } … controller.php controller.php can pass the necessary data to page1.php via some global variables.
10
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 output Adv: One entry point to the web application (easier to enforce access control and perform user authentication) Suitable for large or complicated application
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.