Setting up a Development environment from the FreePBX Distro (v14 and V15)
This is for the new SNG7 Distro using PHP 5.6 only!
Setup
If you already have the FreePBX distro installed then you already have the perfect environment to start FreePBX development. The steps below outline what you will need to do to be able to develop in FreePBX using the FreePBX distro:
yum -y install sangoma-devel |
Note that 'sangoma-devel' is only available on SNG7 based Distros. If you're using an older SHMZ6 Distro, you will need to 'yum -y install git' instead.
rm -rf /usr/src/freepbx
echo "repo_directory=/usr/src/freepbx" >> ~/.freepbxconfig
cd /usr/src
git clone https://github.com/FreePBX/scm/freepbx/devtools.git
cd /usr/src/devtools
./freepbx_git.php --setup --mode=ssh --switch=release/15.0 --keys=freepbx |
There are two ways of synchronizing your machine with the main Git repository, ssh or https. ssh is significantly faster, and is the recommended way, but you do need to grant access to the SSH key of your development machine with the FreePBX Git Repository.
If you are unsure of how, or unable to do so, remove the '--mode=ssh' parameter, and it will work purely over https.
At this point (regardless of ssh or https) you will be asked for your FreePBX.org username and password. This is so the setup script can iterate over the list of projects available, which is not available without a login.
./freepbx_git.php --setup --mode=ssh --switch=release/15.0 --keys=freepbx |
Make sure everything is symlinked correctly.
Once that is complete you are now free to install the developer mode of FreePBX. Keep in mind that we blow away the entire webroot so that the symlinks are created correctly and so that there are duplicate files laying around.
Fixing Broken Modules
If after development mode has been setup you can check if any modules are broken by querying FreePBX like so:
If any Broken Module are found, you can attempt to fix them individually by running:
If you've got any issue with PM2, then do the same thing for a Broken module.
You can also fix all of them in a batch by using the fix_broken_modules.sh script
Before running that script, make sure your Freepbx Username and Password are set in ~/.freepbxconfig. Remember to remove them after this script to avoid having your credentials stored in plain text:
~/.freepbxconfig
Maintenance
Adding your own custom module
If after development mode has been setup you wish to add your own module the steps are simple.
First change directories to the freepbx source directory
Next you'll either need to checkout your module from your favorite VCS (VCS means git,svn or others). Or add it manually. Remember that the raw name of your module should be the folder name so dont try to get creative and have a module name of "mya@wsome!!Module&&"
Lastly you'll want to run the linker. This process links your module folder into the framework modules folder which let's framework know your module exists
Then tell framework to go update the symlinks. You'll also need to tell framework to go update the symlinks every time you add a new file!
Set proper permissions
Finally install your module!
Don't forget to reload!
Updating all modules from GIT
Later down the line if you want to update everything in FreePBX from upstream simply run
Checking out (adding new modules)
If you want to checkout a single module run
Tricks and tips
Also, we can add some aliases in .bashrc file adding two lines like this:
But, we can add whatever you want as alias in this file.
Here, if we type cdsrc, we will go to the /usr/src dirzectory.
The next login we will get these aliases
To read the freepbx debug logs directly, we can create a file under /usr/local/bin/taildebug with this content.
Don't forget the privileges.
Feel free to create some shortcuts as you want.