{"id":29008777,"url":"https://github.com/gruz/fusionpbx-api","last_synced_at":"2025-06-25T14:39:46.036Z","repository":{"id":52976664,"uuid":"93081856","full_name":"gruz/fusionpbx-api","owner":"gruz","description":null,"archived":false,"fork":false,"pushed_at":"2022-02-05T10:05:12.000Z","size":16145,"stargazers_count":12,"open_issues_count":6,"forks_count":12,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-05T13:27:12.970Z","etag":null,"topics":["fusionpbx"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gruz.png","metadata":{"files":{"readme":"README copy.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-01T17:19:48.000Z","updated_at":"2025-02-25T04:39:22.000Z","dependencies_parsed_at":"2022-08-30T23:42:59.794Z","dependency_job_id":null,"html_url":"https://github.com/gruz/fusionpbx-api","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/gruz/fusionpbx-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gruz%2Ffusionpbx-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gruz%2Ffusionpbx-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gruz%2Ffusionpbx-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gruz%2Ffusionpbx-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gruz","download_url":"https://codeload.github.com/gruz/fusionpbx-api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gruz%2Ffusionpbx-api/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261893087,"owners_count":23226047,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fusionpbx"],"created_at":"2025-06-25T14:39:42.116Z","updated_at":"2025-06-25T14:39:46.013Z","avatar_url":"https://github.com/gruz.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"- [Fusionpbx API](#fusionpbx-api)\n  - [Development environment (Virtual Box)](#development-environment-virtual-box)\n    - [Install Virtual Box software and create a Debian virtual machine](#install-virtual-box-software-and-create-a-debian-virtual-machine)\n    - [Install FusionPBX](#install-fusionpbx)\n      - [Login into your virtual machine.](#login-into-your-virtual-machine)\n      - [Run installation script](#run-installation-script)\n      - [Create virtual host for API](#create-virtual-host-for-api)\n      - [Enable xdebug](#enable-xdebug)\n      - [Mount local folder with the API code into VM](#mount-local-folder-with-the-api-code-into-vm)\n  - [Development environment (docker)](#development-environment-docker)\n    - [Setup environment](#setup-environment)\n    - [Daily usage](#daily-usage)\n  - [Production environment](#production-environment)\n    - [Introduction](#introduction)\n      - [Install additional packages](#install-additional-packages)\n      - [Install API project files](#install-api-project-files)\n      - [Update .env file](#update-env-file)\n      - [Add nginx virtual host](#add-nginx-virtual-host)\n      - [Setup firewall](#setup-firewall)\n      - [Get and upload apple VOIP push certificate](#get-and-upload-apple-voip-push-certificate)\n      - [Setup and run socket server](#setup-and-run-socket-server)\n    - [Check it's working](#check-its-working)\n    - [Update](#update)\n  - [Documenations](#documenations)\n\n\n# Fusionpbx API\n\n## Development environment (Virtual Box)\n\n### Install Virtual Box software and create a Debian virtual machine\n\n* Install [Virtual Box](https://www.virtualbox.org/)\n* Download a Debian iso file and mount in using virtual box. I used amd 64 https://www.debian.org/distrib/netinst#smallcd\n* Create a new virtual machine usin debian. Select startup disk your mounted iso. ![](docs/select_iso.png)\n* Proceed with the install. Choose defaults when possible.  except points mentioned below. I choose root password, user name and password as `fusionpbx` for development purposes.\n  * Select only neede software, no need to install DE. So disable `Debian desktop environment`, do not enable `web-server` (we don't need apache) and enable `ssh server` ![](docs/select_software.png)\n* Set network adapter to `Bridged apdapter` ![](docs/select_network.png). You may need to reboot VM to apply new network connection. Thus the VM will be treated as a regular computer in your local network.\n* Install Guest Additions.\n  * Insert guest additions ISO using `VB -\u003e Devices` menu\n  * Login into VM\n  * Install guest additions according to https://linuxize.com/post/how-to-install-virtualbox-guest-additions-on-debian-10/\n    ```bash\n    apt install build-essential dkms linux-headers-$(uname -r)\n    mkdir -p /mnt/cdrom\n    mount /dev/cdrom /mnt/cdrom\n    cd /mnt/cdrom\n    sudo sh ./VBoxLinuxAdditions.run --nox11\n    sh ./VBoxLinuxAdditions.run\n    systemctl reboot\n    ```\n* Install additional packages needed\n  ```bash\n  apt install -y wget curl php-zmq php-xdebug nodejs php-mbstring \\\n    \u0026\u0026 apt-get install -y nano mc \\\n    \u0026\u0026 apt install -y supervisor;\n  ```\n\n### Install FusionPBX\n\n#### Login into your virtual machine. \n\nI prefer to ssh into the VM from the host machine, as the terminal in \nVirtualBox window doesn't allow to copy/paste. But first we need to know\nthe VM IP. So login into the VM using VirtualBox and run `hostname -I`.\nIt gave me the IP of the VM in my local network. \nIn my case it's `192.168.0.159`\n![](docs/hostname-I.png)\n\n\u003e Note! Debian doesn't allow by default to login via `ssh` as `root` \n\u003e so we must login as a regular user and the switch to root\n\nNext open termianl at your host machine and `ssh fusionpbx@192.168.0.159`\nwhere `fusionpbx` is my VM user and `192.168.0.159` is the IP of the VM.\nWhen logged in use `su` to switch to root user.\n\n\u003e NOTE! Lower it's assumed all linux commands are run in VM as root\n\n#### Run installation script\n\nWhen being logged into the VM as root use commads provided by FusionPBX \ndoc to [install FusionPBX](https://www.fusionpbx.com/download).\n\nA small command I needed to update GPG keys\n\n```bash\nwget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -\n```\n\nNext run FusionPBX installation\n\n\n```bash\nwget -O - https://raw.githubusercontent.com/fusionpbx/fusionpbx-install.sh/master/debian/pre-install.sh | sh;\n\ncd /usr/src/fusionpbx-install.sh/debian \u0026\u0026 ./install.sh\n```\n\nWhen done, don't forget to copy the final message with login and password.\n\nIn my case smth. like this: \n```bash\n      domain name: https://192.168.0.159\n      username: admin\n      password: RfnxCiRh7pxfuwRkuBLX9zYnVo\n```\n\n![](docs/post_install_message.png)\n\n#### Create virtual host for API\n\nLet's prepare NGINX and system for our API\n\n```bash\ncat \u003c\u003c 'EOF' \u003e /etc/nginx/sites-available/api\nserver {\n        listen 443;\n        server_name fusionpbx;\n        ssl                     on;\n        ssl_certificate         /etc/ssl/certs/nginx.crt;\n        ssl_certificate_key     /etc/ssl/private/nginx.key;\n        ssl_protocols           TLSv1 TLSv1.1 TLSv1.2;\n        ssl_ciphers             HIGH:!ADH:!MD5:!aNULL;\n\n        #letsencrypt\n        location /.well-known/acme-challenge {\n                root /var/www/letsencrypt;\n        }\n\n        access_log /var/log/nginx/access.log;\n        error_log /var/log/nginx/error.log;\n\n        client_max_body_size 80M;\n        client_body_buffer_size 128k;\n\n        location /api {\n                root /var/www/laravel-api/public;\n                index index.php;\n                try_files $uri $uri/ /index.php?$query_string;\n        }\n\n\n        location ~ \\.php$ {\n                fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;\n                #fastcgi_pass 127.0.0.1:9000;\n                fastcgi_index index.php;\n                include fastcgi_params;\n                fastcgi_param   SCRIPT_FILENAME /var/www/laravel-api/public$fastcgi_script_name;\n        }\n\n        # Disable viewing .htaccess \u0026 .htpassword \u0026 .db\n        location ~ .htaccess {\n                deny all;\n        }\n        location ~ .htpassword {\n                deny all;\n        }\n        location ~^.+.(db)$ {\n                deny all;\n        }\n}\nEOF\nln -s /etc/nginx/sites-available/api /etc/nginx/sites-enabled/api\n/etc/init.d/nginx restart\nmkdir -p /var/www/laravel-api/\nchown www-data:www-data laravel-api/\nsudo usermod -aG vboxsf www-data\nsudo iptables -A INPUT -p tcp --dport 444 --jump ACCEPT\nsudo /sbin/iptables-save \u003e /etc/iptables/rules.v4\n```\n\n#### Enable xdebug\n\nTo enable xdebug you must know your host machine IP in your local network\nand the path to the xdebug.ini file. The path \n\n```bash\nHOST_IP=$(echo $SSH_CLIENT | awk '{ print $1}')\nPHP_VERSION=$(php --version | head -1 | awk '{print $2}' | cut -d. -f 1-2)\ncat \u003c\u003c EOF \u003e /etc/php/${PHP_VERSION}/mods-available/xdebug.ini\nzend_extension=xdebug.so\n\nxdebug.remote_host=\"${HOST_IP}\"\nxdebug.remote_connect_back=1\nxdebug.remote_port=9000\nxdebug.idekey=PHPSTORM\n\nxdebug.remote_autostart=1\nxdebug.remote_enable=1\nxdebug.cli_color=1\n;xdebug.profiler_enable=0\n;xdebug.profiler_output_dir=\"~/xdebug/phpstorm/tmp/profiling\"\n\nxdebug.remote_handler=dbgp\nxdebug.remote_mode=req\n\nxdebug.var_display_max_children=-1\nxdebug.var_display_max_data=-1\nxdebug.var_display_max_depth=-1\nEOF\n/etc/init.d/php7.3-fpm restart\n```\n\n\n#### Mount local folder with the API code into VM\n\nClone the project if not done yet\n\n```bash\ngit clone git@github.com:gruz/fusionpbx-api.git\ncd fusionpbx-api\ngit fetch --all\ngit checkout dev\ngit pull\ngit submodule init \u0026\u0026 git submodule update\n```\n\nMount your local folder into VM.\n\n![](docs/mount_api_folder.png)\n\n\nReboot VM\n\n```bash\nsystemctl reboot\n```\n\n- витягнути два проекти на локалці fusionpbx і нашу АПІ\n- підмінити теки на локальні\n- встановити xdebug\n- змінити nginx\n- відкрити порти\n\n\n\n\n\n\n\n## Development environment (docker)\n\nFor developing we use docker. So it's assumed you have docker installed,\nbeing able to run it without `sudo` (your user is added to `docker` group).\n\n### Setup environment\n\nRun commands in terminal and then follow steps. After done you'll have you `fusionpbx` under https://localhost \nand api accessible under https://localhost:444\n\n```bash\ngit clone git@github.com:gruz/fusionpbx-api.git\ncd fusionbpx-api\nbin/init\n```\n\n### Daily usage\n\n\u003e Make sure other services are stopped to have corresponding ports opened.\n\nStart docker\n\n`bin/start`\n\nStop docker\n\n`bin/stop`\n\n\n## Production environment\n\n\u003e Note, the docs below may be outdated for now. We will update them in the future.\n\n### Introduction\n\nIt's assumed you follow FusionPBX installation manual and have your Debian server running.\n\nThe API will be accessible at your server under port 444 (you are free to change it)\n\nThe main steps would be:\n\n* Install additional packages\n* Get the API code and place it to your server\n* Update .env file\n* Add nginx virtual host\n* Setup firewall\n* Get and upload apple VOIP push certificate\n\n\n#### Install additional packages\n\n```bash\napt install composer php-zmq nodejs\n```\n\n#### Install API project files\n\n```\n# cd /var/www\n# git clone git@github.com:gruz/fusionpbx-api.git laravel-api\n# cd laraverl-api\n# composer update\n# cp .env.example .env\n# chown -R www-data:www-data laravel-api\n```\n\n#### Update .env file\n\nNext manually copy database credentials from `/etc/fusionpbx/config.php` to `/var/www/laravel-api/.env`\n\n```bash\nsudo -u www-data php artisan key:generate\nsudo -u www-data php artisan migrate\nsudo -u www-data php artisan passport:install\n```\n\nThe latest command will generate key pairs.\n\nCopy-paste the generated secrets and IDs into your .env file like this\n\n```env\nPERSONAL_CLIENT_ID=1\nPERSONAL_CLIENT_SECRET=mR7k7ITv4f7DJqkwtfEOythkUAsy4GJ622hPkxe6\nPASSWORD_CLIENT_ID=2\nPASSWORD_CLIENT_SECRET=FJWQRS3PQj6atM6fz5f6AtDboo59toGplcuUYrKL\n```\n\nChange `MOTHERSHIP_DOMAIN` domain in .env to your domain.\n\n\n#### Add nginx virtual host\n\nEdit `/etc/nginx/sites-available/fusionpbx` and add code like this (note port 444 which you can change here and in the firewall section)\n\n```\nserver {\n        listen 444;\n        server_name fusionpbx;\n        ssl                     on;\n        ssl_certificate         /etc/ssl/certs/nginx.crt;\n        ssl_certificate_key     /etc/ssl/private/nginx.key;\n        ssl_protocols           TLSv1 TLSv1.1 TLSv1.2;\n        ssl_ciphers             HIGH:!ADH:!MD5:!aNULL;\n\n        #letsencrypt\n        location /.well-known/acme-challenge {\n                root /var/www/letsencrypt;\n        }\n\n        access_log /var/log/nginx/access.log;\n        error_log /var/log/nginx/error.log;\n\n        client_max_body_size 80M;\n        client_body_buffer_size 128k;\n\n        location / {\n                root /var/www/laravel-api/public;\n                index index.php;\n                try_files $uri $uri/ /index.php?$query_string;\n        }\n\n\n        location ~ \\.php$ {\n                fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;\n                #fastcgi_pass 127.0.0.1:9000;\n                fastcgi_index index.php;\n                include fastcgi_params;\n                fastcgi_param   SCRIPT_FILENAME /var/www/laravel-api/public$fastcgi_script_name;\n        }\n\n        # Disable viewing .htaccess \u0026 .htpassword \u0026 .db\n        location ~ .htaccess {\n                deny all;\n        }\n        location ~ .htpassword {\n                deny all;\n        }\n        location ~^.+.(db)$ {\n                deny all;\n        }\n}\n```\n\nRestart server\n\n```bash\nservice nginx restart\n```\n\n#### Setup firewall\n\nAllow your port in Firewall\n\n```bash\niptables -A INPUT -p tcp --dport 444 --jump ACCEPT\niptables -A INPUT -p tcp --dport 8080 --jump ACCEPT\n```\n\nNow we want to make firewal respect your port setting after reboot.\n\nSave current rules to a file\n\n```bash\niptables-save \u003e /etc/iptables.up.rules\n```\n\nCreate a boot file\n\n```bash\nnano /etc/network/if-pre-up.d/iptables\n```\n\nwith contents\n\n```bash\n#!/bin/sh\n/sbin/iptables-restore \u003c /etc/iptables.up.rules\n```\n\nMake it executable\n\n```bash\nchmod +x /etc/network/if-pre-up.d/iptables\n```\n\n#### Get and upload apple VOIP push certificate\n\nThis is needed to send push notifications to wakeup Apple devices.\nGet the certificate at Apple Developer Portal and place it to **resources/certs/VOIP.pem**\n\nEdit `.env` file and place the path to the cert file as well as password if you have it setup.\n\nSearch for `VOIP_APPLE_CERT_PATH` and `VOIP_APPLE_CERT_PASSPHRASE` in your `.env` file.\n\n#### Setup and run socket server\n\nFor production site create configuration suppressing output\n\n```bash\ncat \u003c\u003cEOF \u003e /etc/supervisor/conf.d/laravel-ratchet.conf\n[program:laravel-ratchet]\nprocess_name=%(program_name)s_%(process_num)02d\ncommand=php /var/www/laravel-api/artisan ratchet:serve --driver=IoServer -q\nautostart=true\nautorestart=true\nuser=www-data\nnumprocs=1\nredirect_stderr=true\nstdout_logfile=/var/www/laravel-api/storage/logs/ratchet.log\nEOF\n```\n\nFor dev site use the same config except the -q key\n\n```bash\ncat \u003c\u003cEOF \u003e /etc/supervisor/conf.d/laravel-ratchet.conf\n[program:laravel-ratchet]\nprocess_name=%(program_name)s_%(process_num)02d\ncommand=php /var/www/laravel-api/artisan ratchet:serve --driver=IoServer\nautostart=true\nautorestart=true\nuser=www-data\nnumprocs=1\nredirect_stderr=true\nstdout_logfile=/var/www/laravel-api/storage/logs/ratchet.log\nEOF\n```\n\nEnable and start\n\n```bash\nsudo supervisorctl reread\nsudo supervisorctl update\nsupervisorctl start laravel-ratchet:*\n```\n\n### Check it's working\n\nIf you open **https://yoursite.com:444** (note HTTPS!) you should see something like\n\n```json\n{\"title\":\"FusionPBX API\",\"version\":\"0.0.1\"}\n```\n\n### Update\n\nLogin to your server via ssh and go to the laravel folder\n\n```bash\ncd /var/www/laravel-api/\n```\n\nSwitch to `www-data` user\n```bash\nsu -m -l www-data\n```\n\n\u003e Don't care when you get `-su: /root/.bash_profile: Permission denied`. Just ignore.\n\n\n```bash\ngit pull\n```\n\nInstall composer packaged to get new added packages and remove unneeded ones\n\n```bash\ncomposer install\n```\n\nRun laravel migration\n\n```bash\nphp artisan migrate\n```\n\nCheck `.env.example` file for new entries (compare it with your current file). If there are new lines at the bottom, then update your `.env` file with the new files.\n\nCheck if your certificates (like VOIP push cert) are in place.\n\n## Documenations\n\nCheck this repository wiki","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgruz%2Ffusionpbx-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgruz%2Ffusionpbx-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgruz%2Ffusionpbx-api/lists"}