Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best Practices for creating a PHP INI/CONFIG file and keep it secure

Tags:

php

config

ini

I always used a normal PHP file and just defined the variables in that file, but is this considered best practice?

Example:

<?php

define('DB_PASS', 'p@ssw0rd');

?>
like image 326
Phill Pafford Avatar asked Oct 30 '09 15:10

Phill Pafford


1 Answers

Naming your PHP file something that begins with .ht (for instance .htconfig.inc.php) also helps, since Apache usually has a rule never to serve any files that are named .ht*. But placing your file outside of the document root is even better.

like image 54
Wim Avatar answered Nov 14 '22 21:11

Wim