Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Đối với ứng dụng chính thức, bạn cần thiết lập quy trình phát triển rõ ràng, đặc biệt nếu có nhiều người cùng làm việc trên ứng dụng của bạn. Quy trình phát triển thường liên quan đến việc thiết lập và quản lý nhiều môi trường.
Firebase có nhiều mức độ hỗ trợ khác nhau cho quy trình làm việc của nhà phát triển và môi trường cấu thành. Sau khi bạn đã nắm rõ các thuật ngữ và giả định về quy trình làm việc của nhà phát triển trên trang này, hãy tham khảo các phương pháp hay nhất chung và nguyên tắc bảo mật chung để thiết lập dự án Firebase và ứng dụng của bạn.
Giới thiệu về môi trường
Trong quá trình phát triển phần mềm, môi trường là tất cả phần cứng và phần mềm cần có để chạy một thực thể của ứng dụng hoặc hệ thống .
Một loạt môi trường cung cấp sự tách biệt để phát triển và kiểm thử phần mềm mà không ảnh hưởng đến người dùng. Như minh hoạ trong sơ đồ bên dưới, các môi trường ở cấp cao được coi là tiền sản xuất hoặc sản xuất và bạn có thể có nhiều môi trường tiền sản xuất nếu cần. Biểu đồ này cũng mô tả các phương pháp và tính năng phổ biến có liên quan đến từng loại môi trường.
Quá trình phát triển một tính năng hoặc bản phát hành thông qua các môi trường này để được gọi là quy trình triển khai.
Các loại môi trường
Một môi trường bao gồm cơ sở hạ tầng cơ bản mà bạn cần chạy và hỗ trợ ứng dụng, mã và dữ liệu của ứng dụng. Mở rộng từng điều khoản sau đây để xem nội dung mô tả về một số môi trường phổ biến, bao gồm cả mẹo về các loại dữ liệu được sử dụng trong từng loại môi trường.
Môi trường phát triển (nhà phát triển)
Mọi nhà phát triển đều cần một môi trường phát triển — một nơi an toàn và riêng biệt để kiểm thử sẽ thay đổi trong quá trình xây dựng. Tốt nhất là mọi nhà phát triển trong nhóm của bạn đều có quyền truy cập vào môi trường phát triển của riêng họ. Ngoài ra, nếu môi trường nhà phát triển là một thực thể cục bộ, giúp nhà phát triển lặp lại nhanh hơn nhiều.
Dữ liệu trong môi trường nhà phát triển được khởi đầu với những dữ liệu thường giống với dữ liệu sản xuất, nhưng không được chứa bất kỳ dữ liệu . Việc này cũng có thể chứa dữ liệu đã gây ra lỗi trong quá khứ, chẳng hạn như các chuỗi rất dài.
Môi trường kiểm thử và đảm bảo chất lượng
Nếu có kiểm thử tự động, bạn cần một môi trường để chạy các thử nghiệm đó kiểm thử và bạn cần đặt lại dữ liệu mỗi khi xoay vòng kiểm thử môi trường.
Nếu bạn có kỹ sư đảm bảo chất lượng, họ có thể cần một môi trường mà tất cả đều sử dụng hoặc họ có thể cần các môi trường riêng lẻ để kiểm thử bản phát hành mới.
Dữ liệu trong môi trường thử nghiệm và đảm bảo chất lượng được khởi đầu bằng dữ liệu chất lượng thường đại diện cho dữ liệu thực tế, cùng với dữ liệu đại diện cho những trường hợp phức tạp và ví dụ về dữ liệu đã gây ra lỗi trong quá khứ.
Môi trường thử nghiệm
Để kiểm thử thực tế về cách một bản phát hành sẽ hoạt động trong môi trường phát hành công khai, bạn cần có một môi trường thử nghiệm mô phỏng cơ sở hạ tầng phát hành công khai một cách gần nhất có thể. Bây giờ thường có nhiều phiên bản thử nghiệm nếu bạn cần kiểm thử tích hợp riêng biệt.
Dưới đây là những điểm khác biệt phổ biến giữa môi trường thử nghiệm và môi trường sản xuất:
Cách bố trí có thể thiếu một số tính năng hoặc sản phẩm tích hợp có thể gây ra lỗi các hiệu ứng. Ví dụ: bạn có thể thiết lập thử nghiệm để không gửi email.
Cách bố trí có thể chứa dữ liệu ẩn danh; dữ liệu có thể là giả mạo, nhưng đó phải là chân thực. Do thử nghiệm là nơi để gỡ lỗi một cách an toàn, bạn có thể có nhiều quyền truy cập hơn vào dữ liệu thử nghiệm so với dữ liệu thực tế. Vì vậy, để bảo vệ người dùng quyền riêng tư, bạn không nên sử dụng dữ liệu người dùng thực tế trong thử nghiệm.
Môi trường sản xuất (sản xuất)
Đối với mỗi ứng dụng bạn duy trì, bạn cần một phiên bản môi trường. Đây là thực thể mà người dùng của bạn tương tác.
Không giống như các môi trường khác mà bạn có thể thay đổi, xoá và/hoặc tạo lại dữ liệu, dữ liệu trong môi trường sản xuất rất quan trọng; việc mất hoặc thay đổi dữ liệu sản xuất sẽ trực tiếp ảnh hưởng đến người dùng.
Trong bảng điều khiển Firebase, bạn nên gắn thẻ dự án Firebase đã liên kết với môi trường sản xuất như một "sản xuất" . Thẻ này có thể giúp nhắc bạn và thành viên trong nhóm biết rằng bất kỳ thay đổi nào cũng có thể ảnh hưởng đến ứng dụng chính thức được liên kết và dữ liệu của chúng.
Các bước tiếp theo
Xem các phương pháp chung hay nhất của chúng tôi để thiết lập các dự án Firebase. Hướng dẫn này trả lời các câu hỏi về Firebase hệ thống phân cấp dự án, cách đăng ký các biến thể ứng dụng và đa khách hàng.
Xem nguyên tắc chung về bảo mật cho các môi trường khác nhau. Bạn muốn đảm bảo rằng mỗi môi trường và đều được bảo mật.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-07-25 UTC."],[],[],null,["For production apps, you need to set up a clear development workflow, especially\nif you have more than one person working on your app. A development workflow\nusually involves setting up and managing multiple environments.\n\nFirebase has varying levels of support for developer workflows and the\nconstituent environments. Once you're familiar with the developer workflow terms\nand assumptions on this page, check out our\n[general best practices](/docs/projects/dev-workflows/general-best-practices)\nand\n[general security guidelines](/docs/projects/dev-workflows/general-security-guidelines)\nfor setting up a Firebase project and your apps.\n| **Key Point:** We recommend reading our guides thoroughly, but here's the top takeaway about development workflows: \n| **Firebase recommends using a *separate* Firebase project for *each* environment\n| in your development workflow.**\n\nAbout environments\n\nIn software development, an ***environment*** is all the hardware and software\nthat are required to run an instance of an application or system of\napplications.\n\nA series of environments provides isolation for developing and testing software\nwithout impacting users. As shown in the diagram below, environments at a\nhigh-level are considered either *pre-production* or *production* , and you can\nhave as many pre-production environments as needed. The diagram also describes\ncommon practices and features associated with each\n[type of environment](#types).\n\nThe process of progressing a feature or release through these environments to\nproduction is called a ***deployment pipeline***.\n\nTypes of environments\n\nAn environment is composed of the underlying infrastructure that you need to run\nand support your application, its code, and its data. Expand each of the\nfollowing terms to review descriptions of some common environments, including\ntips on the types of data used in each environment type.\n| **Key Point:** Every app should have at least one *pre-production* environment that's isolated from production data and resources.\n\n\u003cbr /\u003e\n\n**Development (dev) environments**\n\n\u003cbr /\u003e\n\nEvery developer needs a development environment --- a safe, isolated place to test\nchanges as they're being built. Ideally, every developer on your team has access\nto their own dev environment. Also, if the dev environment is a local instance,\na developer can iterate much faster.\n\nThe data in a dev environment is seeded with data that generally resembles the\nproduction data, but should never contain any real users' data. It may also\ncontain data that has caused bugs in the past, like very long strings.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n**Test and QA environments**\n\n\u003cbr /\u003e\n\nIf you have automated tests, you need an environment in which to run those\ntests, and you need to reset the data each time you spin up the test\nenvironment.\n\nIf you have QA engineers, they may need one environment that they all use, or\nthey may need individual environments to test a new release candidate.\n\nThe data in test and QA environments is seeded with quality data that's\ngenerally representative of the production data, along with data that represents\ncorner cases and examples of data that have caused bugs in the past.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n**Staging environments**\n\n\u003cbr /\u003e\n\nFor realistic tests of how a release will work in production, you need a staging\nenvironment that mimics production infrastructure as closely as possible. It's\ncommon to have multiple staging instances if you need to test specific\nintegrations in isolation.\n\nHere are common differences between staging and prod:\n\n- Staging may be missing some features or integrations that could cause side\n effects. For example, staging may be set to not send email.\n\n- Staging may have anonymized data; the data can be fake, but it should be\n realistic. Because staging is a place to safely debug problems, you might give\n broader team access to staging data than production data. So, to protect user\n privacy, you shouldn't use actual user data in staging.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n**Production (prod) environments**\n\n\u003cbr /\u003e\n\nFor each application that you maintain, you need a single production\nenvironment. This is the instance with which your users interact.\n\nUnlike the other environments where you can change, delete, and/or recreate\ndata, the data in your prod environment is very important; losing or altering\nyour prod data will directly affect your users.\n\nIn the Firebase console, we recommend tagging the Firebase project associated\nwith your production environment as a\n[\"production\" environment type](/support/faq#set-environment-type). This tag\ncan help remind you and your teammates that any changes could affect your\nassociated production apps and their data.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| **Tip** : Integrations with analytics services, including Google Analytics, often require special attention when you're setting up a new environment. You also don't want your tests from pre-production environments to impact production analytics.\n|\n| We recommend not setting up analytics for most pre-production environments,\n| unless you want to specifically test analytics integrations, like making\n| sure the right parameters are being sent to your analytics service.\n\nNext steps\n\n- Review our [general best practices](/docs/projects/dev-workflows/general-best-practices)\n for setting up Firebase projects. This guide answers questions about Firebase\n project hierarchy, how to register your app variants, and multi-tenancy.\n\n- Review the [general security guidelines](/docs/projects/dev-workflows/general-security-guidelines)\n for different environments. You want to make sure each environment and its\n data are secure.\n\n- Review the [Firebase launch checklist](/support/guides/launch-checklist)."]]