Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 514377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:31:06+00:00 2026-05-13T07:31:06+00:00

I was planning to use an XML document to store configuration for my next

  • 0

I was planning to use an XML document to store configuration for my next PHP project, in a format similar to ASP.NET Web.Config files. Just two concerns:

  1. Cannot be served to the browser.
  2. Must be viable in shared hosting.

The best way I could think to prevent it from being served is to change the filetype to PHP and add the following comment:

<?xml version="1.0" ?>
<!-- <?php if(!defined('FW_LOADED')){ exit; } ?> -->
<configuration>
....
</configuration>

This is working fine, but I don’t feel like it is the best solution.

Has anybody else used XML to store configuration for a PHP project? What are some good alternate solutions (instead of putting a comment at the beginning of the file which exits the script if a constant is not defined)?


Update:

Changed the question title to better reflect what I’m looking for. Sorry for the misleading original question title. Using XML for configuration is not the question. I am asking for the best practices when using XML for configuration. Please stop suggesting that I use arrays or INI files…

I want the config file to be as easy as possible to use, even for non php developers. I chose XML because it is language neutral. I am already using SimpleXML to parse the config (partially). I am also not worried about compiling or making it faster because that can be achieved using memcached or other utilities.

The best solutions so far are:

  • Moving it out of web root.
    • Possible, but would like to keep the config as close as possible to the application.
  • Using htaccess to hide the config file.
    • I don’t want to risk the chance that someone breaks the .htaccess file, leaving the config file exposed.

I would like to hear from someone who has experience using XML for configuration settings in an application, and how they prevent the config file from being served.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T07:31:06+00:00Added an answer on May 13, 2026 at 7:31 am

    I think the best way to prevent files from being accessed from outside is to store them outside the root web folder.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 257k
  • Answers 257k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Think this is more Java question, and workaround should be… May 13, 2026 at 10:43 am
  • Editorial Team
    Editorial Team added an answer This code works (checked with firebug). The $(this) seems to… May 13, 2026 at 10:43 am
  • Editorial Team
    Editorial Team added an answer Use Sonar for that! As you can see in the… May 13, 2026 at 10:43 am

Related Questions

I am storing user inputs through a form with wiki style formatting ( text
I am trying to create an XML schema representing an 'order' for a shopping
We use maven for our large-ish product. All of our artifacts are deployed to
I was planning to use url routing for a Web Forms application. But, after
I was planning to create an unordered list of users of my web application

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.