Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In Zend 2 There are </p> <ol> <li>Global configuration file &amp;</li> <li>Module level configuration file</li> </ol> <p>IF you want to know there use you can refer the link below </p> <p><a href="http://zf2.readthedocs.org/en/latest/tutorials/config.advanced.html" rel="nofollow">How does configuration works in ZF2 </a></p> <p>When I had a same scenario I used the above link to understand and exploit Zend Config module which is really good to handle the situation like this . </p> <p>create two files </p> <p>production.php local.php</p> <p>in both these files </p> <p>return this array based on the environment </p> <pre><code>return array( "dbname" =&gt; "yourdbname" "dbhostname" =&gt; "dbhostname" "dbusername" =&gt; "yourdbusername", "dbpassword" =&gt; "yourdbpassword" ); </code></pre> <p>in config/autoload/ directory of your zend framewrok application </p> <p>later edit your config/application.config.php file as per below instructions </p> <p>// get the application env from Apache vhost file ( here you can set in your apache vhost file as production or local ) </p> <pre><code>$applicationEnv = getenv('APPLICATION_ENV'); </code></pre> <p>$environmentSpecificConfigPath = "config/autoload/{,*.}{".$applicationEnv.",local}.php";</p> <p>// Next with in the config array pass the environment specific configuration path </p> <pre><code> 'config_glob_paths' =&gt; array($environmentSpecificConfigPath) </code></pre> <p>in any controller or action </p> <p>you can just use the below code </p> <pre><code> $configArray = $this-&gt;getGlobalConfig(); </code></pre> <p>Now $configarray has all your DB credentials to create a connection </p> <pre><code>$adapter = new Zend\Db\Adapter\Adapter(array( 'driver' =&gt; 'Mysqli', 'database' =&gt; $configArray['dbname'], 'username' =&gt; $configArray['dbusername'], 'password' =&gt; $configArray['dbpassword'] )); </code></pre> <p>If you use config array to connect the DB in your entire application you dont need to worry about environment changes just make sure you have an Apache APPLICATION_ENV entry in your vhost file </p> <p>you can do that by adding below line in your apache vhost file </p> <pre><code> SetEnv APPLICATION_ENV "production" // in your production server SetEnv APPLICATION_ENV "local" // in your local </code></pre> <p>Also Last but not least you can use the Zend Experts module ZeDB </p> <p><a href="https://github.com/ZendExperts/ZeDb" rel="nofollow">https://github.com/ZendExperts/ZeDb</a></p> <p>To manage your CRUD applications </p> <p>Hope the above steps may help you in creating the environment </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload