Getting Started with symfony

Các môi trường

You are currently browsing
the website for symfony 1

Visit the Symfony2 website


About

You are currently reading "Getting Started with symfony" which is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported License license.

Tutorial Content

Master symfony

Be trained by SensioLabs experts (2 to 6 day sessions -- French or English).
trainings.sensiolabs.com

Books on symfony

Learn more about symfony with the official guides.
books.sensiolabs.com

L'audit Qualité par SensioLabs

200 points de contrôle de votre applicatif web.
audit.sensiolabs.com
symfony training
Be trained by symfony experts
May 29: Paris (Web Development with Symfony2 - Français)
May 31: Paris (Mastering Symfony2 - Français)
Jun 06: Paris (Introduction to Symfony2 - Français)
Jun 06: Paris (Introduction to Symfony2 - English)
Jun 06: Paris (Going Further with Symfony2 - English)
and more...

Search


powered by google
You are currently browsing "Getting Started with symfony" in for the 1.2 version - Switch to language:
Creative Commons License This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.
This version of symfony is not maintained anymore.
If some of your projects still use this version, consider upgrading as soon as possible.

Trong thư mục web/ có 2 file PHP: index.phpfrontend_dev.php. Những file này được gọi là front controller; tất cả các yêu cầu tới ứng dụng đều thông qua chúng. Nhưng tại sao chúng ta lại có 2 front controller cho mỗi application?

Cả 2 file này đều cho cùng một application nhưng ở các môi trường khác nhau. Khi bạn phát triển một ứng dụng, trừ khi bạn phát triển trực tiếp trên production server, bạn cần vài môi trường:

Các môi trường khác nhau như thế nào? Trong môi trường phát triển, ứng dụng cần log tất cả các yêu cầu để dễ debug, hệ thống cache phải tắt để khi ứng dụng thay đổi khi thay đổi code. Do đó, môi trường development phải được cấu hình phù hợp cho lập trình viên. Ví dụ khi một lỗi xảy ra, để giúp lập trình viên debug lỗi nhanh hơn, symfony hiển thị exception với tất cả các thông tin về yêu cầu hiện tại trên trình duyệt:

An exception in the dev environment

Nhưng ở môi trường sản phẩm, tầng cache phải được bật và tất nhiên ứng dụng phải hiểu thị thông báo lỗi đã được sửa lại thay vì hiển thị lỗi thực sự. Do đó, môi trường sản phẩm phải được tối ưu về tốc độ và tính thân thiện với người dùng.

An exception in the prod environment

Nếu bạn mở file front controller, bạn sẽ thấy nội dung những file này tương tự như nhau, chỉ khác nội dung cấu hình môi trường:

// web/index.php
<?php
 
require_once(dirname(__FILE__).'/../config/ProjectConfiguration.class.php');
 
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'prod', false);
sfContext::createInstance($configuration)->dispatch();

Web debug toolbar cũng là một ví dụ về việc sử dụng môi trường. Nó hiển thị trên môi trường phát triển và cho phép bạn truy cập nhiều thông tin bằng cách click vào các tab: cấu hình hiện tại của ứng dụng, log yêu cầu hiện tại, câu SQL thực thi ở database engine, thông tin bộ nhớ, và thời gian thực thi.

Tiếp theo ? »
« Cấu hình Web Server

Questions & Feedback

If you find a typo or an error, please register and open a ticket.

If you need support or have a technical question, please post to the official user mailing-list.