I got in every php project (around 25!), some sh scripts that help me with routine tasks such as deployment, repo syncronizing, databases exporting/export, etc.
The sh scripts are the same for all the projects I manage, so there must be a configuration file to store diferent parameters that depend on the project:
# example conf, the sintaxys only needs to be able to have comments and be easy to edit.
host=www.host.com
[email protected]
password=xxx
I just need to find a clean way in which this configuration file can be read (parsed) from a sh script, and at the same time, be able to read those same parameters from my PHP scripts. Without having to use XML.
Do you know a good solution for this?
Guillermo
Simply source the script conf file as another sh file!.
Example:
conf-file.sh:
# A comment
host=www.host.com
[email protected]
password=xxx
Your actual script:
#!/bin/sh
. ./conf-file.sh
echo $host $administrator_email $passwword
And the same conf-file can be parsed in PHP: http://php.net/manual/en/function.parse-ini-file.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With