2017 © Pedro Peláez
 

cakephp-plugin cake-php-environment-manager

A configurable environment manager for CakePHP.

image

asugai/cake-php-environment-manager

A configurable environment manager for CakePHP.

  • Tuesday, February 17, 2015
  • by asugai
  • Repository
  • 0 Watchers
  • 1 Stars
  • 761 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

CakePHP Environment Manager

A configurable URL and working directory environment manager for CakePHP., (*1)

Background

Easily set up management for multiple environments based on URL and working directory structures., (*2)

Requirements

  • PHP >= 5.3
  • CakePHP 2.x

Installation

[Manual], (*3)

  • Download this: http://github.com/asugai/CakePHP-Environment-Manager/zipball/master
  • Unzip that download.
  • Copy the resulting folder to app/Plugin
  • Rename the folder you just copied to EnvironmentManager

[GIT Submodule], (*4)

In your app directory type:, (*5)

git submodule add git://github.com/asugai/CakePHP-Environment-Manager.git Plugin/EnvironmentManager
git submodule update --init

[GIT Clone], (*6)

In your app directory type, (*7)

git clone git://github.com/asugai/CakePHP-Environment-Manager.git Plugin/EnvironmentManager

Enable plugin

Enable the plugin your app/Config/bootstrap.php file:, (*8)

CakePlugin::load('EnvironmentManager');

If you are already using CakePlugin::loadAll();, then this is not necessary., (*9)

Usage

Setup EnvironmentManager

Edit /app/Config/bootstrap.php file and add EnvironmentUtility environments:, (*10)

Configure::write('EnvironmentUtility.environments', [
    'prod' => [
        'urls' => [
            // example: 'www.example.com'
            // example: 'api.example.com'
            // example: 'example.com'
        ],
        'paths' => [
            // example: '/path/to/my/cakephp/app/'
            // example: '/var/www/html/app/'
            // example: '/var/www/public/app/'
        ]
    ],
    'beta' => [
        'urls' => [
            // example: 'beta.example.com'
        ],
        'paths' => [
            // example: '/var/www/beta/app/'
        ]
    ],
    'stage' => [
        'urls' => [
            // example: 'stage.example.com'
        ],
        'paths' => [
            // example: '/var/www/stage/app/'
        ]
    ],
    'dev' => [
        'urls' => [
            // example: 'dev.example.com'
        ],
        'paths' => [
            // example: '/var/www/dev/app/'
        ]
    ],
    'local' => [
        'urls' => [
            // example: 'local.example.com'
        ],
        'paths' => [
            // example: '/var/www/local/app/'
        ]
    ]
]);

Set up Environment events in your models., (*11)

Example - Send push Environment to a user:, (*12)

App::uses('EnvironmentUtility', 'EnvironmentManager.Lib');
...
public function theEnv()
{
    ... 
    $env = EnvironmentUtility::which(); // Get the current environment, returns false if unknown
    ...
    if (EnvironmentUtility::is('prod')) {
        // Run this code if in the production environment
    }

    if (EnvironmentUtility::is('dev')) {
        // Run this code if in the development environment
    }
}

Todo

  • Comments!

License

Copyright (c) 2013 Andre Sugai, (*13)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:, (*14)

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software., (*15)

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE., (*16)

The Versions

17/02 2015

dev-master

9999999-dev http://github.com/asugai/cake-php-environment-manager

A configurable environment manager for CakePHP.

  Sources   Download

MIT

The Requires

 

cakephp environments