Download the PHP package quest/cakephp-environment without Composer
On this page you can find all versions of the php package quest/cakephp-environment. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download quest/cakephp-environment
More information about quest/cakephp-environment
Files in quest/cakephp-environment
Package cakephp-environment
Short Description Environments Plugin for CakePHP
License MIT
Homepage http://victorsanmartin.com
Informations about the package cakephp-environment
Environment Plugin for CakePHP
for CakePHP 2.x
Requirement
- PHP version: PHP 5.2+
- CakePHP version: 2.x Stable
Installation
- Clone/Copy the files in this diectory into
app/Plugin/Environment
- Ensure the plugin is loaded in
app/Config/bootstrap.php
by callingCakePlugin::load('Environment', array('bootstrap' => true))
Using Composer
Add the plugin to your project's composer.json
- something like this:
Because this plugin has the type cakephp-plugin
set in its own composer.json
, Composer will install it inside your /Plugins
directory, rather than in the usual vendors file. It is recommended that you add /Plugins/Environment
to your .gitignore file. (Why? read this.)
Manual
- Download this: http://github.com/quest/cakephp-environment/zipball/master
- Unzip that download.
- Copy the resulting folder to
app/Plugin
- Rename the folder you just copied to
Environment
GIT Submodule
In your app directory type:
GIT Clone
In your Plugin
directory type:
Enable plugin
In 2.0 you need to enable the plugin in your app/Config/bootstrap.php
file:
Usage
Create file app/Config/env.php
with this example content.
Environment Detection
In order to detect the project environment and apply their settings, use the application hostname, just like this:
You must use regex to define the hostname. You can create many environments as you want.
Methods
Environment::get()
Get the current environment depending on hostname requested:
Environment::set(string $environment)
Avoid set the environment based on hostname request, by using set()
method. It will overwrite any other environment previously settled.
Environment::is(string $environment)
Use this method to check the current/working environment.
Environment::write()
You can write environment settings by using the write()
method in two ways:
Multiple
Single
Environment::read()
Read environment settings by using the read()
method:
- $key: Key to find
- $environment: Optional — Environment scope
Environment::write()
also can be used to update or modify Cake's app/Config/core.php
file settings. For example:
TODO
Support
To report bugs or request features, please visit the Issue Tracker.
Contributing to this Plugin
Please feel free to contribute to the plugin with new issues, requests, unit tests and code fixes or new features. If you want to contribute some code, create a feature branch from develop, and send us your pull request. Unit tests for new features and issues detected are mandatory to keep quality high.
License
Copyright 2014, Victor San Martín
Licensed under The MIT License
Redistributions of files must retain the above copyright notice.