<<

Web Frameworks, ACAD 276 Fall 2018

© 2018 Zune Nguyen Dynamic

Web Browser Web

HTTP request for http://dailytrojan.com/

HTTP response is an HTML document (index.) No server-side code is in response Browser renders index.php

© 2018 Zune Nguyen Spaghetti Code

Classic Anti-Pattern Example.

Typically, code that is: ● Unorganized, ● Unstructured, ● Unpredictable, ● Difficult to maintain.

© 2018 Zune Nguyen Spaghetti Code

search_results.php is almost Spaghetti Code.

In a single file, we scattered: 1. Configurations, 2. Business logic, 3. , 4. Output to users.

© 2018 Zune Nguyen Spaghetti Code

search_results.php is almost Spaghetti Code.

In a single file, we scattered: 1. Configurations, ... 2. Business logic, 3. Database, 4. Output to users.

© 2018 Zune Nguyen Spaghetti Code ...

search_results.php is almost Spaghetti Code.

In a single file, we scattered: ... 1. Configurations, 2. Business logic, 3. Database, 4. Output to users.

© 2018 Zune Nguyen Spaghetti Code

search_results.php is almost Spaghetti Code.

In a single file, we scattered: 1. Configurations, 2. Business logic, 3. Database, ... 4. Output to users.

© 2018 Zune Nguyen Spaghetti Code

search_results.php is almost Spaghetti Code.

In a single file, we scattered: 1. Configurations, 2. Business logic, ... 3. Database, 4. Output to users.

© 2018 Zune Nguyen Web Framework

Software used to create web applications.

Prevents us from reinventing the wheel.

Most come with common set of functionalities: ● HTML templating, ● Data validation, ● Database interactions, ● Clear and consistent structure, ● Etc.

© 2018 Zune Nguyen Some Common Web Frameworks

CSS JavaScript PHP

Java Ruby Python

© 2018 Zune Nguyen Model–View–Controller (MVC)

Software design pattern.

Divides software into 3 parts:

Model Data management and business logic.

© 2018 Zune Nguyen Model–View–Controller (MVC)

Software design pattern.

Divides software into 3 parts:

Model Data management and business logic.

View Elements in the .

© 2018 Zune Nguyen Model–View–Controller (MVC)

Software design pattern.

Divides software into 3 parts:

Model Data management and business logic.

View Elements in the user interface.

Controller Connection between models and views.

© 2018 Zune Nguyen Laravel

Open-source, PHP, MVC web framework.

One of the most popular PHP frameworks.

Website: https://laravel.com/

© 2018 Zune Nguyen Laravel & MVC

1. User Request Routing

2. Route to Controller Method

4. Update View 3. Request & Receive Controller Data from Model

5. Display in the Browser

View Model

© 2018 Zune Nguyen Laravel File Structure

Config .env

Routing routes/web.php

Models app/

Views resources/views/

Controllers app/Http/Controllers/

© 2018 Zune Nguyen