Enables developers to modify Magento installations (configuration, data) based on the given environment using n98-magerun.

Overview

LimeSoda Environment Configuration

Enables developers to modify Magento installations (configuration, data, ...) based on the given environment using n98-magerun.

Build Status

Latest Release

Scrutinizer Code Quality

Development Branch

Scrutinizer Code Quality

Facts

  • version: 1.3.0 (Unreleased)
  • extension key: LimeSoda_EnvironmentConfiguration
  • Composer key: limesoda/limesoda_environment-configuration
  • extension on GitHub

Requirements

Compatibility

  • Magento >= EE 1.13.0.2 (should also work on older and CE versions)

Installation Instructions

  1. Install the extension via modman or Composer.
  2. Add names to your environments.
  3. Configure environments.

Usage

After configuring your environments (see below) call n98-magerun like this:

n98-magerun.phar ls:env:configure [environment]

Set an environment name

Configure the environment of the environment in your XML. Most of the time you will want to put this in local.xml as this file doesn't get shared between copies of the shop in most setups.


    
        
            
                dev
            
        
    

Adding environments

Create a new extension (or use an existing one) and add a global > limesoda > environments node to your config.xml:

">


    
        
            
                
            
        
    

Congratulations, you created your "default" environment!

Calling

n98-magerun.phar ls:env:configure default

will execute the actions you specified for this environment.

Adding commands

Next we create a command. You create a commands node beneath your environment node. To add a command, you choose a unique node name and add the n98-magerun command as the value:

config:set -- "web/unsecure/base_url" "http://www.domain.tld/" ">


    
        
            
                
                    
                        config:set -- "web/unsecure/base_url" "http://www.domain.tld/"
                    
                
            
        
    

Using variables

You can replace hard-coded strings (e.g. URLs) with variables. Add variables for your environment as children of a variables node. Then you can insert the values into commands using the notation ${variable_name}.

config:set -- "web/unsecure/base_url" "${unsecure_base_url}" ">


    
        
            
                
                    
                        
                    
                    
                        config:set -- "web/unsecure/base_url" "${unsecure_base_url}"
                    
                
            
        
    

Add values to 'System > Configuration'

In the first two examples we set a value for System > Configuration using the normal config:set syntax. If you have to do this for many values and different scopes this can get confusing.

Alternatively you can use a special system_config node for setting values. It supports scopes the same way you know it from the default, websites and stores nodes in config.xml.

Use encrypt="true" to set an encrypted configuration value.

${unsecure_base_url} ">


    
        
            
                
                    
                        
                    
                    
                        
                            
                                
                                    ${unsecure_base_url}
                                
                            
                        
                    
                
            
        
    

Define values on website and store view scopes the same way. You can use the website and store code instead of the numeric ids. If you for whatever reason prefer the ID you also can use this one instead.

${unsecure_base_url} ${unsecure_base_url} http://seconddomain.tld/ http://thirddomain.tld/ <4> http://fourthdomain.tld/ ">


    
        
            
                
                    
                        
                    
                    
                        
                            
                                
                                    ${unsecure_base_url}
                                
                            
                        
                        
                            
                                
                                    
                                        ${unsecure_base_url}
                                    
                                
                            
                            
                                
                                    
                                        http://seconddomain.tld/
                                    
                                
                            
                        
                        
                            
                                
                                    
                                        http://thirddomain.tld/
                                    
                                
                            
                            <4>
                                
                                    
                                        http://fourthdomain.tld/
                                    
                                
                            
                        
                    
                
            
        
    

Overriding values for single CLI calls

Introduced in 1.3.0 you can now override one or multiple variable values when calling ls:env:configure:

n98-magerun.phar ls:env:configure --override='var1=val1' --override='var2=val2' mz

This command will set the value of the variable var1 to val1 and var2 to val2, no matter what was defined in the configuration XML.

Command stages

In the first two examples all commands were placed in the commands node. As we just mentioned you can use system_configuration to put all system configuration settings in its own node and make big configurations clearer.

You still may have many commands left which have to be specified in commands and have a hard time sorting them in the right way by being creative with the names of the XML nodes.

To help a little bit with that you can use two custom stages, pre_configure and post_configure, which are executed before and after the operations in commands are processed.

config:set -- "web/unsecure/base_url" "${unsecure_base_url}" cache:disable cache:flush ">


    
        
            
                
                    
                        
                    
                    
                        config:set -- "web/unsecure/base_url" "${unsecure_base_url}"
                    
                    
                        cache:disable
                        cache:flush
                    
                
            
        
    

The settings from system_configuration are applied in the commands stage. This means the commands will be added in the following order:

  • pre_configure
  • commands
  • system_configuration
  • post_configure

Nesting environments

Using variables is nice but the most you will profit if you nest environments. This means you can create a base definition for commands and variables and expand them in other environments. You do this by specifying the parent in your environments base node: .

A typical setup could be:

  • default
    • dev
      • developer 1
      • developer 2
      • developer 3
    • test
    • qa
    • staging
    • live

If you want to re-build this setup for the environment configuration, your XML will look like this:

">


    
        
            
                
                
                
                
                
                
                
                
                
            
        
    

If you define a command or variable in a parent environment, the child environment will inherit them.

By specifying commands and variables on different levels, you can save yourself some typing and maintenance work. In the next example we disable and flush the cache for all environments while setting a different URL for every environment.

config:set -- "web/unsecure/base_url" "${unsecure_base_url}" cache:disable cache:flush ">


    
        
            
                
                    
                        
                    
                    
                        config:set -- "web/unsecure/base_url" "${unsecure_base_url}"
                    
                
                
                    
                        
                    
                    
                        cache:disable
                        cache:flush
                    
                
                
                    
                        
                    
                
                
                    
                        
                    
                
                
                    
                        
                    
                
            
        
    

Configuration skeleton

You can use this config.xml skeleton as a starting point for your environment configuration.

0.0.1 ">


	
		
			0.0.1
		
	
	
	
		
			
				
					
					
					
					
				
				
					
					
					
					
				
				
					
					
					
					
				
				
					
					
					
					
				
				
					
					
					
					
				
				
					
					
					
					
				
			
		
	

Built-in commands

ls:aoe:scheduler:job:status

Enables and disables cron jobs as used by Aoe_Scheduler >= 1.0.0.

">

  ls:aoe:scheduler:job:status "[jobcode]" "[status]"

All arguments are required.

  • jobcode: The Magento cron job code (e.g. core_email_queue_send_all)
  • status: 0 for inactive, 1 for active.

Example:

">

  ls:aoe:scheduler:job:status "core_email_queue_send_all" "0"

You will get an output like Job 'example_cron': set status to '0'. which makes it easier to identify changes to the crons.

ls:ess:m2epro:channel:status

Sets the channel status for Ess_M2ePro. The extension has to be installed and enabled.

">

  ls:ess:m2epro:channel:status "[name]" "[status]"

###ls:ess:m2epro:license:key

Sets the license key for Ess_M2ePro. The extension has to be installed and enabled.

">

  ls:ess:m2epro:license:key "[key]"

Backend Overview

Navigate to System > Environment Configuration to get a list of all configured environments.

Click on an environment to get a list of the commands that will be executed. Variables not defined for the environment are highlighted.

Displaying the environment name in the header

Backend

You can enable an header bar in System > Configuration > Advanced > Admin > Environment Configuration > Display environment name above admin header.

To make it easier for you to differentiate between environments you can configure the font and background color per environment:


    
        
        	
            #fff
            #090
        
    

You can also display a label, see the node above. If no label is set, the environment name is displayed.

Frontend

You can display the same header bar in the frontend by enabling it in System > Configuration > Advanced > Admin > Environment Configuration > Display environment name above frontend header.

Uninstallation

Just like any other modman or Composer installed extension. No database tables or other additional files are created.

Support

If you have any issues with this extension, open an issue on GitHub.

Contribution

Any contribution is highly appreciated. The best way to contribute code is to open a pull request on GitHub. Please create your pull request against the develop branch.

Developer

Matthias Zeis
http://www.limesoda.com
@mzeis

License

OSL - Open Software Licence 3.0

Copyright

(c) 2014-2015 LimeSoda Interactive Marketing GmbH

Comments
  • Is it possible to check Use Default in any way?

    Is it possible to check Use Default in any way?

    Hi,

    I'm also wondering if it is possible to use LimeSode to uncheck and check the "Use Default" checkboxes as seen in the attached screenshot? screen shot 2018-05-28 at 14 20 20

    question needs update 
    opened by driesatunit 4
  • Improve check/handling of ls:env:configure

    Improve check/handling of ls:env:configure

    As suggested by @schmengler and discussed internally, the feature should be implemented like this:

    • If no environment name was specified when calling n98-magerun.phar ls:env:configure, assume the environment name set in the local configuration

    • If the environment is used like that, let the user confirm this choice:

      Configure environment 'mz'? [y,n]
      

      The user has to confirm this with "y"

    • For automation, a "force" parameter can be provided which will automatically confirm the question above

    • If the user provides an environment as an argument which is not the one set in the local configuration, stop with a warning/error. Example: if environment abc is set in local.xml but the user executes n98-magerun.phar ls:env:configure def, the execution should be stopped.

    • The user can provide a "force" parameter to still apply the other configuration.

    Note: the naming of the force parameter and the confirmation of the choice is not fixed. If there is a standard way to do/name it in n98-magerun, we can follow that.

    A nice to have feature which could be implemented additionally:

    • If no environment was added as a parameter, list the existing environments as a select dialog with the configured one being the default
    needs update 
    opened by mzeis 3
  • Impossible to use configuration values starting with a dash

    Impossible to use configuration values starting with a dash

    Hi,

    When using ls:env:configure, I've noticed it's impossible to set a variable to a value starting with a dash, like '-1'. This is caused by a known Symfony Console issue (https://github.com/symfony/symfony/pull/3624), and the solution should be fairly straightforward to implement.

    I would make a pull request, but I think you just need to change one line in lib/n98-magerun/modules/LimeSoda_EnvironmentConfiguration/src/LimeSoda/Environment/Configure.php where the config:set commands are executed (line 38):

    $input = new StringInput('-- ' . $command); instead of $input = new StringInput($command);

    The '-- ' makes sure no argument values after its appearance are interpreted as option names.

    enhancement 
    opened by Qronicle 2
  • Show environment notice on frontend too, allow custom labels

    Show environment notice on frontend too, allow custom labels

    I have added a new config´option in system -> configuration -> admin which allows displaying the environment notice on the frontend too. I know the position "admin" is not ideal, but I didn't want to spread the options over the configuration. Neither did I want to move the existing configuration option.

    I have also added the possibility to display custom labels instead of the environment names which can be added as new node "label" inside the XML, see updated readme..

    opened by avstudnitz 1
  • Add compatibility to Magento patch SUPEE-6285 (validating admin ACL)

    Add compatibility to Magento patch SUPEE-6285 (validating admin ACL)

    If you update to Magento 1.9.2.1 and you try to visit System -> Environment Configuration, you get an access denied because of changes made in SUPEE-6285. This patch will add some validation of the admin ACL in the controller.

    opened by gfobe 1
  • Parse error when executing command

    Parse error when executing command

    I configured a module and set up a default environment. I unfortunately get the following error:

    Warning: simplexml_load_file(): Entity: line 69: parser error : expected '>' in /Users/victorterhark/Sites/afurastore.dev/htdocs/app/Mage.php on line 767

    I've tried to trace the problem with no succes :-(.

    Any clues?

    opened by victorth 1
  • Fatal error: Allowed memory size exhausted

    Fatal error: Allowed memory size exhausted

    Hi,

    I really like this module en would like te use it. I used the default configuration XML as the base for versioned configuration, but this is much more advanced and better.

    I only can't get it to work :-). I get an allowed memory size exhausted error:

    Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 33554432 bytes) in /domains/happyrainydays.com/test/lib/Varien/Simplexml/Element.php on line 195

    Can you help me with this? I don't know how to solve this.

    Local.xml: ... testing ...

    Config module config.xml:

    0.1.0
    <global>
        <limesoda>
            <environments>
                <default parent="default">
                    <variables>
                    </variables>
                    <commands>
                    </commands>
                </default>
                <dev parent="default">
                    <variables>
                    </variables>
                    <commands>
                    </commands>
                </dev>
                <developer1 parent="dev">
                    <variables>
                    </variables>
                    <commands>
                    </commands>
                </developer1>
                <testing parent="default">
                    <variables>
                        <unsecure_base_url><![CDATA[http://test.happyrainydays.com/]]></unsecure_base_url>
                    </variables>
                    <system_configuration>
                        <default>
                            <web>
                                <unsecure>
                                    <base_url>${unsecure_base_url}</base_url>
                                </unsecure>
                            </web>
                        </default>
                    </system_configuration>
                    <commands>
                    </commands>
                </testing>
                <staging parent="default">
                    <variables>
                    </variables>
                    <commands>
                    </commands>
                </staging>
                <live parent="default">
                    <variables>
                    </variables>
                    <commands>
                    </commands>
                </live>
            </environments>
        </limesoda>
    </global>
    

    Hope you can help me with this.

    Best regards, Otto Smittenaar

    opened by ottosmittenaar 1
  • Allow encrypted configuration values in <system_configuration>

    Allow encrypted configuration values in

    Currently if you want to set encrypted config values, you have to resort to config:set --encrypt. With these changes, it will also be possible to add an encrypt="true" attribute to a config node in <system_configuration> to encrypt the given configuration value.

    opened by schmengler 0
  • Avoid errors in backend when environment name is not defined

    Avoid errors in backend when environment name is not defined

    When the extension is installed and no environment name is specified, the new admin observer causes an error when grabbing the current environment configuration.

    opened by mzeis 0
Releases(v1.3.0)
  • v1.3.0(Feb 14, 2018)

    Added / Improved:

    • Show environment notice on frontend too, allow custom labels (thanks to @avstudnitz) (#12).
    • Added CLI option to override values in the configuration XML.
    • Make display of environment name for frontend configurable in system
    • Change develop branch to 'develop'
    • Update scrutinizer badge

    Fixed:

    • Corrected closing tags in the README (thanks to @EliasKotlyar) (#9).
    • Added compatibility to Magento patch SUPEE-6285 (validating admin ACL (thanks to @gfobe) (#11).
    • It wasn't possible to set config values starting with a - when using the system_configuration node (thanks to @Qronicle for noticing) (#16).
    • Fix README formating on GitHub
    Source code(tar.gz)
    Source code(zip)
  • v1.2.0(May 31, 2015)

    1.2.0 (31.05.2015)

    Added / Improved:

    • Allow encrypted configuration values in <system_configuration> (thanks to @schmengler) (#6).

    Fixed:

    • Avoid errors in backend when environment name is not defined (thanks to @andreaspenz) (#4).
    • Colors are not set for environment configuration admin header in Chrome.
    • Fixed error in documentation (thanks to @avoelkl) (#7).
    Source code(tar.gz)
    Source code(zip)
  • v1.1.0(Mar 18, 2015)

    Changelog

    1.1.0 (18.03.2015)

    Added / Improved:

    • Added optional header indicating the current environment (thanks to @tegansnyder)
    • Made header colors configurable per environment
    • Added n98-magerun command ls:aoe:scheduler:job:status

    Backwards-incompatible changes:

    • Renamed ls:env:configure:ess:m2epro:channel-status to ls:ess:m2epro:channel:status
    • Renamed ls:env:configure:ess:m2epro:set-license-key to ls:ess:m2epro:license:key
    Source code(tar.gz)
    Source code(zip)
  • v1.0.0(Mar 18, 2015)

    Changelog

    1.0.0 (30.11.2014)

    Added / Improved:

    • Added node <system_configuration> which allows specifying system configuration settings in a more readable manner.
    • Added backend overview which:
      • shows the environments as a hierarchy
      • shows the commands to be executed in a selected environment
      • highlights missing variables in the selected environment
    • Added new command stages 'pre_configure' and 'post_configure'.
    • Added n98-magerun command db:truncate.
    • Added n98-magerun command ls:env:reset.
    Source code(tar.gz)
    Source code(zip)
Owner
LimeSoda Interactive Marketing GmbH
Hi! We are a team of 50+ building websites, webshops and web apps for companies.
LimeSoda Interactive Marketing GmbH
netz98 magerun CLI tools for Magento 1

netz98 magerun CLI tools for Magento 1 The n98 magerun cli tools provides some handy tools to work with Magento from command line. Build Status Latest

netz98 1.4k Dec 31, 2022
A htaccess boilerplate for all Magento Community installations. Features focus on speed, SEO and security.

magento-htaccess A htaccess boilerplate for all Magento Community installations. Features focus on speed, SEO and security. The file should be placed

Creare 114 Sep 18, 2022
Module for integrating Fastly CDN with Magento 2 installations

FASTLY CDN FOR MAGENTO2 DOCUMENTATION Thank you for using the "Fastly CDN module for Magento2" (Fastly_Cdn). This package contains everything you need

Fastly 113 Dec 26, 2022
This Statamic addon allows you to modify the tags rendered by the Bard fieldtype, giving you full control over the final HTML.

Bard Mutator This Statamic addon allows you to modify the tags rendered by the Bard fieldtype, giving you full control over the final HTML. You can ad

Jack Sleight 10 Sep 26, 2022
This extensions makes it possible to modify the TCA of container children elements

This extensions makes it possible to modify the TCA of container children elements

Georg Ringer 6 Oct 24, 2022
This a php environment for developers. based on Vagrant & CentOS & laravel/homestead

Centstead 这是一个 PHP 调试环境 , 基于 centos,laravel/homestead. 介绍   基于开发的实际需求,PHP开发者通常需要一个贴近生产环境,又易于维护的测试与开发环境.以往的选择: xampp, wamp, phpstudy… 集成环境,启动方便,占用小,但是需

JasonChang 52 Sep 30, 2022
MailChimp for Magento 2. Syncs all data (subscriber, customers, orders, products) and enables marketing automation with email campaigns, automations, ads, postcards and more.

MailChimp for Magento 2. Syncs all data (subscriber, customers, orders, products) and enables marketing automation with email campaigns, automations, ads, postcards and more.

Mailchimp 139 Sep 9, 2022
Rah backup - Takes backups from Textpattern CMS installations

rah_backup Packagist | Twitter | Donate Rah_backup keeps your important site safe from disastrous events. Rah_backup is an admin-side backup utility p

Jukka Svahn 5 Apr 24, 2022
Drall - a tool to that helps run drush commands on multi-site Drupal installations

Drall Drall is a tool to that helps run drush commands on multi-site Drupal installations. One command to drush them all. — Jigarius A big thanks and

Jigar Mehta 23 Nov 25, 2022
A Magento implementation for validating JSON Structures against a given Schema

Zepgram JsonSchema A Magento implementation for validating JSON Structures against a given Schema with support for Schemas of Draft-3 or Draft-4. Base

Benjamin Calef 1 Nov 5, 2021
Preferences are configuration variables that are user-managed for which we cannot rely upon container parameters or environment variables.

Preferences Preferences are configuration variables that are meant to be user managed for which we cannot rely upon container parameters or environmen

Makina Corpus 1 Feb 7, 2022
Import/Export configuration data in Magento 2 via CLI.

ConfigImportExport This module provides new CLI commands for Magento 2 to import/export data in/from core_config_data. This module is inspired by the

semaio 135 Dec 9, 2022
Import/Export configuration data in Magento 2 via CLI.

ConfigImportExport This module provides new CLI commands for Magento 2 to import/export data in/from core_config_data. This module is inspired by the

semaio 117 Mar 23, 2022
[ONLY Magento 2.0.x Compatible] Code samples for Magento developers

Synopsis This project is a collection of samples to demonstrate technologies introduced in Magento 2. You will find the most simple extension along wi

Magento 58 Dec 26, 2022
Faker-driven, configuration-based, platform-agnostic, locale-compatible data faker tool

Masquerade Faker-driven, platform-agnostic, locale-compatible data faker tool Point Masquerade to a database, give it a rule-set defined in YAML and M

elgentos ecommerce solutions 219 Dec 13, 2022
provides a nested object property based user interface for accessing this configuration data within application code

laminas-config This package is considered feature-complete, and is now in security-only maintenance mode, following a decision by the Technical Steeri

Laminas Project 43 Dec 26, 2022
A tool that allows to quickly export data from Magento 1 and Magento 2 store and import it back into Magento 2

Simple Import / Export tool A tool that allows to quickly export data from Magento 1 and Magento 2 store and import it back into Magento 2. Table data

EcomDev B.V. 51 Dec 5, 2022