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

  • SEARCH
  • Home
  • 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

Related Questions

I'm planning a ASP.NET project for which I'm going to use AJAX. I'm researching
I am planning to use SCTP for a embedded Linux project. Anybody has some
I am planning to use libcurl in my project. I had downloaded the library
I am planning to use PIC18F6*** serial microntroller for my project serial-ethernet converter. Once
I am planning to try to use XML Serialization in C# but I am
I'm planning an XML web service that takes an XML request and returns an
I'm working on php, mysql on a project I'm planning to add a multilanguage
First Some Background I'm planning out the architecture for a new PHP web application
I am planning to use XPath to query an XML file. Can you please
I'm planning to use flash image rotator based on xml where are defined paths

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.