title: adding wordpress to existing ZF web app - where to install?
body: <p>I have a ZF web app up and running. Now we are planning to add blog to our web app. I am considering using WP blog because of the super tight timeline to complete blogging system. Note: I am not looking to convert my ZF app into WP app. </p>
  
  <p>There isn't much about on how to integrate ZF and wordpress on google, so before I install WP I would like to make sure that I am on the right path. So here this is what I have learned so far by looking at the bit and pieces of articles I found on internet.</p>
  
  <p>My ZF directory structure looks like this: (This is just the crude structure)</p>
  
  <pre><code>trunk /
      module /
          app /
              (contains controller, view, model)
      public /
          css
          js
      vendor / 
          ZF
  </code></pre>
  
  <p>1) Create a new directory inside ZP app (let's say www.domain.com/blog)<br>
  2) Upload and install WP under blog directory.<br>
  3) Add the following header to the all PHP pages.</p>
  
  <pre><code>&lt;?php 
  /* This make the magic: */
  define('WP_USE_THEMES', false);
  require('path-to-the-file/wp-blog-header.php');
  </code></pre>
  
  <p>My question is where should I exactly create the blog folder and upload/install WP? Is it going to be under view folder? or in the public folder? Also, is there anything I need to include in root index file for routing? </p>
  
  <p>This is my index.php files looks like which is located in the public folder</p>
  
  <pre><code>&lt;?php
  /**
   * This makes our life easier when dealing with paths. Everything is relative
   * to the application root now.
   */
  chdir(dirname(__DIR__));
  
  function debug( $data ) {
      try {
          throw new Exception();
      } catch( Exception $e ) {
          $trace  = $e-&gt;getTrace();
          $desc = array_shift($trace);
          $info = $desc['file'].' on line '.$desc['line'].'';
          $infoS = basename($desc['file']).'('.$desc['line'].')';
      }
      $errTempId = 'e'.mt_rand(0,9999999999999);
      $onClick = "e=document.getElementById('".$errTempId."');if(e.style.display=='none'){e.style.display='';}else{e.style.display='none';}";
      echo '&lt;strong style="color:#006699"&gt;&lt;acronym style="cursor:pointer;" title="'.$info.'" onClick="'.$onClick.'"&gt;&lt;span style="font-size:11px; font-weight:normal;"&gt;'.$infoS.' debug:&lt;/span&gt;&lt;/acronym&gt;&lt;/strong&gt;&lt;span id="'.$errTempId.'"&gt;';
      if( is_object($data) === true or is_array($data) === true ) {
          echo '&lt;pre&gt;';
          print_r($data);
          echo '&lt;/pre&gt;&lt;br /&gt;';
      } else if( is_null($data) ) {
          echo '&lt;i&gt;NULL&lt;/i&gt;&lt;br /&gt;';
      } else {
          echo $data.'&lt;br /&gt;';
      }
      echo '&lt;/span&gt;';
  }
  
  function arrayMerge( $a, $b ) {
      foreach( $b as $k =&gt; $v ) {
          $a[$k] = $v;
      }
      return $a;
  }
  
  error_reporting(E_ALL &amp; ~E_STRICT &amp; ~E_NOTICE);
  error_reporting(E_ALL &amp; ~E_STRICT &amp; ~E_NOTICE &amp; ~E_WARNING);
  
  // Setup autoloading
  require 'init_autoloader.php';
  
  // Run the application!
  Zend\Mvc\Application::init(require 'config/application.config.php')-&gt;run();
  </code></pre>
  
  <p>htaccess file (just in case I need to modify anything over here)</p>
  
  <pre><code>RewriteEngine On
  # The following rule tells Apache that if the requested filename
  # exists, simply serve it.
  RewriteCond %{REQUEST_FILENAME} -s [OR]
  RewriteCond %{REQUEST_FILENAME} -l [OR]
  RewriteCond %{REQUEST_FILENAME} -d
  RewriteRule ^.*$ - [NC,L]
  # The following rewrites all other queries to index.php. The 
  # condition ensures that if you are using Apache aliases to do
  # mass virtual hosting, the base path will be prepended to 
  # allow proper resolution of the index.php file; it will work
  # in non-aliased environments as well, providing a safe, one-size 
  # fits all solution.
  RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
  RewriteRule ^(.*) - [E=BASE:%1]
  RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]
  # The following rule blocks botnets scripts
  RewriteCond %{HTTP_USER_AGENT} libwww-perl.* 
  RewriteRule .* – [F,L]
  # The following rule maps IP address with domain name
  RewriteCond %{HTTP_HOST} ^***\.**\.***\.**
  RewriteRule (.*) http://www.domain.com/$1 [R=301,L]
  </code></pre>