PHP code example of quest / cakephp-environment

1. Go to this page and download the library: Download quest/cakephp-environment library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

quest / cakephp-environment example snippets


    CakePlugin::load('Environment', array('bootstrap' => true));

	/**
	 * Domains environments
	 * IMPORTANT: This lines on the top of the file
	 */
		Configure::write('Environment.domains', array(
			'development' => '.*',
			'production' => '^(.+\.)?mysite\.com$'
		));

	/**
	 * Development settings
	 */
		Environment::write(array(
			'debug' => 2,
			'Security.salt' => '6978hjkhKjkhskjhd698KGNSLdsDLsdKSAsdf8778sdfg',
			'Security.cipherSeed' => '57283694289374902834892039823756894'
		), 'development');

	/**
	 * Production settings
	 */
		Environment::write(array(
			'debug' => 0
		), 'production');

	Configure::write('Environment.domains', array(
		'development' => '^myapp\.local$',
		'production' => '^mycapp\.com$'
	));

	echo Environment::get(); // print 'development' text

	Environment::set('testing'); // true

	if (Environment::is('development')) {
		echo 'this is development';
	}
	else {
		echo 'this is ' . Environment::get();
	}

	Environment::write(array(
		'debug' => 2,
		'database' => array(
			'login' => 'root',
			'host' => 'localhost',
			'password' => '',
		)
	), 'development');

	Environment::write('debug', 0, 'production');

	// databases.php
	class DATABASE_CONFIG {

		public $default = array(
			'datasource' => 'Database/Mysql',
			'persistent' => false,
			'host' => Environment::read('database.host'),
			'login' => Environment::read('database.login'),
			'password' => Environment::read('database.password'),
			'database' => 'database_name',
			'prefix' => '',
			'encoding' => 'utf8',
		);
	}

	/**
	 * Development settings
	 */
		Environment::write(array(
			'debug' => 2,
			'Security.salt' => '6978hjkhKjkhskjhd698KGNSLdsDLsdKSAsdf8778sdfg',
			'Security.cipherSeed' => '57283694289374902834892039823756894'
		), 'development');

	/**
	 * Production settings
	 */
		Environment::write(array(
			'debug' => 0,
			'Security.salt' => '6978hjkhKjkhskjhd698KGNSLdsDLsdKSAsdf8778sdfg',
			'Security.cipherSeed' => '57283694289374902834892039823756894'
		), 'production');