Pro PHP Patterns, Frameworks, Testing and more phần 7

và trong các chương tiếp theo, bạn sẽ tìm hiểu thêm về một số các lớp học SPL tiên tiến. SPL được kích hoạt theo mặc định và có sẵn trên hầu hết các PHP 5 hệ thống. Tuy nhiên, vì tính năng của SPL đáng kể mở rộng với việc phát hành 5,2 PHP, | CHAPTER 14 MVC ARCHITECTURE 203 The MVC architecture also provides a useful subdivision of the file structure. Each MVC framework has a different structure and layout but with few exceptions they all provide separate files for models views and controllers. This feature will reduce code conflicts and will save time that would otherwise be spent merging changes in your revision control system. MVC Application Layout The layout for MVC applications differs by framework however some concepts are common to all MVC frameworks. In the next chapter you will learn about the specifics of the Zend Framework layout. The explanations in this section refer to the typical implementation of the MVC pattern in PHP. From the Web Server Unlike other PHP applications MVC sites typically implement a centralized PHP script that handles all requests on a web site. So instead of the browser going to path to somefile .php the browser goes to controller action. However you won t find a folder named controller or a file named action. Instead a URL rewriter like mod_rewrite is used to redirect all HTTP requests to a centralized script that is called the bootstrap file. The bootstrap file is responsible for initializing the framework loading files reading configuration data parsing the URL into actionable information and populating the objects that encapsulate the request. Finally it is responsible for initializing the controllers. Actions and Controllers After bootstrapping a class called the front controller FC is instantiated and takes over. The front controller is typically a built-in class that is responsible for interpreting request variables and routing code execution to a user-defined class which is called an action controller AC . Usually an action controller will implement a standard interface or descend from an abstract class so that the front controller and action controller may interact using a common API. The front controller will then invoke a method on the action controller .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.