2017 © Pedro Peláez
 

library branching

Symfony BranchingBundle. Auto change database depends on еру current git branch.

image

therat/branching

Symfony BranchingBundle. Auto change database depends on еру current git branch.

  • Thursday, August 20, 2015
  • by TheRatG
  • Repository
  • 2 Watchers
  • 0 Stars
  • 509 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 2 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

BranchingBundle

Symfony BranchingBundle. Auto change mysql database depends on current git branch., (*1)

SensioLabsInsight, (*2)

Bundle version is connected with supported symfony version., (*3)

Installation

Download bundle by composer, (*4)

composer require therat/branching

Then, enable the bundle by adding the following line in the app/AppKernel.php file of your project:, (*5)

<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        if (in_array($this->getEnvironment(), ['dev', 'test'])) {
            $bundles[] = new TheRat\BranchingBundle\TheRatBranchingBundle();

        // ...
    }

    // ...
}

Create new branch git branch feature or git checkout -b feature., (*6)

After that run 'app/console' command, and bundle create and copy new database automatically., (*7)

Be sure, that your mysql connect has privileges to create new scheme. Bundle use default symfony connection params 'database_host' etc., (*8)

Configuration

# Default configuration for "BranchingBundle"

the_rat_branching:
    switch_db: false     #enable or disable auto switch db
    copy_db_data: false  #copy db from root db

Nginx example

Obviously, you're hosting must support dns name like this *.test.my.project.com. There is an example of nginx config for different branches:, (*9)

server {
    #...

    if ($branch = "") {
        set $branch "master";
    }
    server_name ~^(www\.)?(?<branch>.+)\.test\.my\.project\.com$;
    root /www/test.my.project.com/project/$branch/web;

    #...

Twig extensions

Current branch

  • Get current branch, useful for generating project title
#your twig template file

{{ current_branch() }}

For master branch return master (dev) string., (*10)

The Versions

20/08 2015

dev-master

9999999-dev

Symfony BranchingBundle. Auto change database depends on еру current git branch.

  Sources   Download

MIT

The Requires

 

by Vladimir Pak

15/08 2015

2.7.0

2.7.0.0

Symfony BranchingBundle. Auto change database depends on еру current git branch.

  Sources   Download

MIT

The Requires

 

by Vladimir Pak

12/06 2015

2.6.0

2.6.0.0

Symfony BranchingBundle. Auto change database depends on еру current git branch.

  Sources   Download

MIT

The Requires

 

by Vladimir Pak