PHP Environments

Download PHP Environments

Post on 05-Dec-2014

1.091 views

Category:

Technology

0 download

Embed Size (px)

DESCRIPTION

Learn how to customize environments in ProdigyView.

TRANSCRIPT

<ul><li> 1. Environments </li> <li> 2. OverivewObjectiveLearn how to set different environments in theconfiguration file.Requirements Understanding of the configuration fileEstimated Time7 minutes http://www.prodigyview.com </li> <li> 3. Follow Along With A Code Example1. Download a copy of the example code at www.prodigyview.com/source.2. Install the system in an environment you feel comfortable testing in.3. Proceed to examples/system/Environments.php http://www.prodigyview.com </li> <li> 4. EnvironmentsEnvironments are a specified configuration to use basedon the current system environment.In ProdigyView, configurations can be set to certainenvironments. An example of usage is having differentdatabase connections used based upon the server beingused.When you understand how to set up environments, youcan also begin to use them in other areas, such asconfigurations based upon a user. http://www.prodigyview.com </li> <li> 5. Setting up Connections To start this tutorial, we are going to set up to database connections, one for development and one for production.1. Production Connection2. Development Connection </li> <li> 6. Add Configuration Once we have our configurations set up, we can add them with an environment set. Every configuration as a key used for saving and accessing the data.1. Configuration key 2. Data associated with key 3. Environment </li> <li> 7. Retrieving Environment VariablesOnce the environments are saved, they can be retrievedby calling the environment it was saved as. 1. Key used to save the environment 2. Environment </li> <li> 8. Setting Our Default EnvironmentOur next step is to set the default environment. There are many ways to the setserver environment. $_SERVER[ENV] $_SERVER[SERVER_NAME] In NGINX and FastCGI, you can set a custom variable in the fastcgi_params In Apache, you can set a custom environment variable in the htaccess fileIn our example, we are going to use the HTTP_HOST to decide our environment. </li> <li> 9. ConfigurationNow its time for initializing the configuration class with ourenvironment. This will create a default environment whenadding and retrieving configurations. Initialize with environment </li> <li> 10. Retrieving Our ConfigurationThe last step is retrieving the configuration. Because weset the environment in the initialization, we no longer needto specify it when retrieving the configuration. Retrieve configuration with only the key </li> <li> 11. Review1. Set a configuration with PVConfiguration::addConfiguration method.2. Retrieve a set configuration using PVConfiguration::getConfiguration method.3. An environment can be explicitly set when adding and retrieving configurations.4. Setting an environment in PVConfiguration::init will create a default environment in which you will no longer need a explicitly set the environment when adding or retrieving data. http://www.prodigyview.com </li> <li> 12. More TutorialsFor more tutorials, please visit:http://www.prodigyview.com/tutorials www.prodigyview.com </li> </ul>