Skip to main content
  1. All Posts/

obi-bash

Tools Open Source PHP WordPress

Obi Version 2.0

Obi is a project management tool that simplifies WordPress development.

THIS VERSION HAS BEEN DEPRECATED

See HERE for the updated version

Installation:

  1. If you haven’t already, create a folder named “bin” and a file named “.bash_profile” with the following text on it export PATH=$HOME/bin/obi:$PATH, and place them separately in your home directory root folder.
  2. Next, you’ll need to find out which PHP and MySQL your system is using. This can be done with the terminal command which. To do this first run which php from the terminal. If you are presented with a path ending with php, then the location your systems PHP is available to Obi and you are good to go. Now run which mysql from the terminal. If you are presented with a path ending with mysql, then the location your systems MySQL is available to Obi and you can move on to step 3.
    If either command, which php or which mysql do not yield a path then you will need to install or locate which ever one that didn’t show up. After you have verified that PHP and MySQL are both running on your system, you can run the which command again. If you have verified that either of the two are correctly installed and the which command still won’t yield a path then you will need to add the unyielded location for the corresponding service to your “.bash_profile” like shown below replacing the placeholder path with your system’s path.

     export PATH=/path/to/your/systems/php/folder:$PATH
     export PATH=/path/to/your/systems/mysql/folder:$PATH
    
    <p>
      If you are running <strong>MAMP PRO</strong> your PHP will be located at <code>/Applications/MAMP/bin/PHP/[mampphpversion]/bin</code> (where you would replace [mampphpversion] with the version of PHP MAMP PRO is running) and MySQL will be located at <code>/Applications/MAMP/Library/bin</code>.<br /> So say your <strong>MAMP PRO</strong> is running PHP version 5.4.4, you would need to add the lines below to your &#8220;.bash_profile&#8221; below the line in step one.
    </p>
    
    <pre class="notranslate"><code> export PATH=/Applications/MAMP/bin/PHP/php5.4.4/bin:$PATH
    

    export PATH=/Applications/MAMP/Library/bin:$PATH

  3. To ensure that the changes to your “.bash_profile” are available, run the following command.

     source ~/.bash_profile
    
  4. Assuming you already have Git installed run this command from your terminal:
    cd $HOME/bin/ ; git clone https://github.com/micalexander/obi.git
    And then run:
    obi config
    Enter your setting and you’re ready to go.

Useage:

obi [argument]
or
obi [argument] [project_name] [environment(s)]

Arguments:

config: configure obi
help: prints usage to the terminal
mysql: login mysql database (Followed by the [environment(s)])
kill: Remove a working directory completely (Followed by the [project_name])
-e: Create an empty working directory (Followed by the [project_name])
-g: Create a git repository working directory (Followed by the [project_name])
-w: Create a WordPress enabled git working directory (Followed by the [project_name])
-b: Backup mysql database (Followed by the [project_name] and then the [environment(s)])

Project name:

[project_name] : Name of the directory that contains your project.

Environments:

-l: local
-s: staging
-p: production
-lts: local to staging
-ltp: local to production
-stl: staging to local
-stp: staging to production
-ptl: production to local
-pts: production to staging

Getting started

Global config

When the command obi… is ran for the first time, a single hidden file is generated in your home directory with the name .obiconfig. Please do not edit this file directly. This file is used by obi to store the path to your local projects directory that contains all of your projects along with your multiple environment settings.
To edit this file simply run the command obi config.
The default settings are as follows:

localprojectdirectory='0'
localsettings="enabled"
localhost="localhost"
localuser="root"
localpassword='root'

stagingsettings="disabled"
stagingdomain='0'
staginghost="0"
staginguser="0"
stagingpassword='0'

productionsettings="disabled"
productiondomain='0'
productionhost="0"
productionuser="0"
productionpassword='0'

By default when this file is created the localprojectdirectory variable is not set (set to 0) and before obi can be used, it needs to be set to your local projects directory as a direct path without the trailing slash. The localsettings by default are set to enabled and the stagingsettings and productionsetttings to disabled.
The localsettings, stagingsettings and productionsetttings control how obi will access your MySQL credentials. The three possible settings are:

enabled
wp-enabled
disabled

enabled: obi will use the credentials that are set below it.
wp-enabled: obi will use the credentials that are on the wp-config.PHP file.
disabled: obi will not use any credentials

Project specific config

Obi has some features that require a project specific config file to be configured correctly in order to make use of them. The features that rely on this config file are listed below along with their uses.

SSH - used for rsync and to import/dump...