Windows
How to organize workspace for MikoPBX extension developement.
Example of organizing a working directory
MikoPBX
├── Core
│   ├── ...
│   └── ...
├── Extensions
│   ├── ModuleBackup
│   └── ModuleYourModule
└── MikoPBXUtils
    └──node_modulesCore - files from the repository mikopbx/Core
Extensions - directory for storing module files
ModuleBackup - files from the repository mikopbx/ModuleBackup
ModuleYourModule - directory with files of your module
MikoPBXUtils - directory with external tools
node_modules - node-js modules
Environment
We widely use the composer to manage dependents libraries, NodeJS runtime for Javascript code processing.
# Install PHP 7.4
# https://dev.to/amulya_shahi/how-to-download-install-php-7-4-6-manually-on-windows-10-4io0
# Install GIT
# Just go to https://git-scm.com/download/win and the download will start automatically. 
# Install composer
# Download and run https://getcomposer.org/Composer-Setup.exe
# Install xdebug PHP extension
# https://xdebug.org/docs/install#windows
# Install nodeJS
# Download and run https://nodejs.org/en/download/ 
# Create DIR for example MikoPBX/MikoPBXUtils, enter to itIn MikoPBXUtils dir create file babel.config.json:
{
  "presets": [["airbnb", {
    "targets": {
      "chrome": 50,
      "ie": 11,
      "firefox": 45
    }
  }]]
}In MikoPBXUtils dir create file package.json:
{
  "devDependencies": {
    "@babel/cli": "^7.14.3",
    "@babel/core": "^7.14.3",
    "@babel/polyfill": "^7.12.1",
    "@babel/preset-env": "^7.14.2",
    "babel-preset-airbnb": "^5.0.0",
    "eslint": "^7.27.0",
    "eslint-config-airbnb-base": "^14.2.1",
    "eslint-plugin-import": "^2.23.3"
  }
}Install all from package.json file
npm installClone the Core MikoPBX repository
Use GIT command to make similar to picture folder sctructure with MikoPBX sources.
MikoPBX
├── Core <- Clone https://github.com/mikopbx/Core.git here
├── Extensions
└── MikoPBXUtilsInstall third party PHP libraries to MikoPBX/Core folder
cd MikoPBX/Core
composer install --ignore-platform-reqs Create a new module structure
To create a new module for MikoPBX, you can use the ModuleTemplate repository as ready for use template.
Every MikoPBX module must have a unique identifier, i.e. you are developing a call back module with the identifier – ModuleYourModule
MikoPBX
├── Core 
├── Extensions
│   └── ModuleYourModule
└── MikoPBXUtilsСopy the script mod_replace.py to the Extensions dir and run it. It clones the ModuleTemplate repository and renames folders, files, namespaces and class names according to the new module unique id – ModuleYourModule.
cd MikoPBX/Extensions
python mod_replace.py ModuleMyNewModPHPStorm IDE
We advise using PHPStorm IDE because all MikoPBX code was written with this tool.
You have to download it by the next link and install it.
Create a new PHP empty Project from existing sources.

Setup the composer executable path according to this manual.
Setup the PHP interpreter path according to this manual.
PHPStorm: setup Babel
Babel is a toolchain that is mainly used to convert ECMAScript 2015+ code into a backwards compatible version of JavaScript in current and older browsers or environments.
Babel guarantees that the JS code will work the same in all web browsers.
The source JS files are located in directories:
MikoPBX/Core/sites/admin-cabinet/assets/js/srcMikoPBX/Extensions/*/public/assets/js/src
Files that the web interface uses are located in directories:
MikoPBX/Core/sites/admin-cabinet/assets/js/pbxMikoPBX/Extensions/*/public/assets/js
With any modification of the source file, babel must create a final file.
Go to
Settings / Tools / File WatchersClick to "Add" button
Choose template "Babel"
Set "Name" - Babel Core
Set "Program"
$ProjectFileDir$\MikoPBXUtils\node_modules\.bin\babelSet "Arguments"
$FilePath$ --out-dir $FileParentDir$/../pbx/$FileDirName$ --source-maps inline --presets airbnbSet "Output path to refresh":
$FileParentDir$/../pbx/$FileDirName$/$FileprNameWithoutExtension$.js:$FileParentDir$/../pbx/$FileDirName$/$FileNameWithoutExtension$.js.mapSet "Auto-save edited files to trigger the watcher"
Set "Trigger the watcher on external changes"
Set "Working directory":
$ProjectFileDir$\MikoPBXUtilsSetup "Scope"
Set "Name" - Project Core
Set "Pattern":
file:Core/sites/admin-cabinet/assets/js/src/*.js


Go to
Settings / Tools / File WatchersClick to "Add" button
Choose template "Babel"
Set "Name" - Babel Modules
Set "Program"
$ProjectFileDir$\MikoPBXUtils\node_modules\.bin\babelSet "Arguments"
$FilePath$ --out-dir $FileParentDir$ --source-maps inline --presets airbnbSet "Output path to refresh":
$FileParentDir$\$FileNameWithoutExtension$.js:$FileParentDir$\$FileNameWithoutExtension$.js.mapSet "Auto-save edited files to trigger the watcher"
Set "Trigger the watcher on external changes"
Set "Working directory":
$ProjectFileDir$\MikoPBXUtilsSetup "Scope"
Set "Name" - Project Modules
Set "Pattern":
file:Extensions/*/public/assets/js/src/*.js


PHPStorm: setup Phalcon Autocomplete
Go to
Settings / PluginsSearch "Phalcon" and install it

Last updated
Was this helpful?