title: Cleanest way to read config settings from PHP file and upload entire project code using shell script
body: <p>I am a newbie with shell scripting so need a few ideas on parsing a PHP file using a shell script.</p>
  
  <p>Ours is a PHP project and I am improving our shell script which is used to upload code to  production server.</p>
  
  <p>There is one PHP config file <code>production.settings.php</code> which needs to be read during upload, for a few constants -   </p>
  
  <p><code>BASE_PATH</code>  (path to project root on prod server)<br>
  <code>db_host</code>, <code>db_name</code> etc. (database settings of prod database - to be used for taking a backup of the database before upload)</p>
  
  <p><strong>Question</strong>  </p>
  
  <ul>
  <li><p>How to read the value of the constants?</p>
  
  <p>They are defined like this:    </p>
  
  <pre><code>define("BASE_PATH","/path/to/project/root");
  </code></pre></li>
  <li><p>How to read the first uncommented value of the constant?<br>
  <em>Note -</em> The constant may be defined more than once in the same file (let's assume the possibilty - this may happen by mistake or there may be commented instances of the line)</p></li>
  </ul>
  
  <p>So far I am only able to get the number of lines containing the string <code>define("BASE_PATH"</code> using <code>grep</code> in my shell script - </p>
  
  <pre><code>cd ..
  PROJECT_ROOT=$PWD
  result= grep -ic 'define("BASE_PATH",' $PROJECT_ROOT'/config/main.settings.php'
  echo "see"$result
  </code></pre>
  
  <ul>
  <li>Is this method of parsing good enough or a yml file would be better? Is there any shell command/snippet for doing this so that I can get the result by writing lesser amount of code?</li>
  </ul>
  
  <p><strong>Updates</strong><br>
  Check my other questions for more details on this:-<br>
  <a href="https://stackoverflow.com/questions/4377191/manipulating-an-array-printed-by-php-cli-in-shell-script">Manipulating an array (printed by php-cli) in shell script</a>,<br>
  <a href="https://stackoverflow.com/questions/4376695/assigning-values-printed-by-php-cli-to-shell-variables">Assigning values printed by PHP CLI to shell variables</a>,<br>
  <a href="https://stackoverflow.com/questions/4385097/initiating-dynamic-variables-variable-variables-in-bash-shell-script">Initiating dynamic variables (variable variables) in bash shell script</a></p>