Skip to content

Commit

Permalink
Initial release (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdosoftei committed Mar 26, 2022
1 parent a06803c commit 53794e4
Show file tree
Hide file tree
Showing 303 changed files with 21,200 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/.gitattributes export-ignore
/.github export-ignore
/.gitignore export-ignore
/etc/phpstan.neon export-ignore
/etc/psalm.xml export-ignore
/etc/unit.xml.dist export-ignore
/tests/ export-ignore
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "daily"
24 changes: 24 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: CI

on:
push:
pull_request:

jobs:
StaticAnalysis:
name: StaticAnalysis (PHP ${{ matrix.php }} on ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-20.04
php:
- 8.1
steps:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
- run: composer install
- run: composer phpstan
- run: composer psalm
43 changes: 43 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Publish

on:
push:
tags:
- '*'

jobs:
PublishAssets:
name: PublishAssets
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@v2
with:
php-version: 8.1
- run: curl -OL https://clue.engineering/phar-composer-latest.phar
- run: chmod +x phar-composer-latest.phar
- run: composer install --no-dev
- run: ./phar-composer-latest.phar build .
- uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: eqivo.phar
asset_name: eqivo.phar
tag: ${{ github.ref }}
prerelease: true
overwrite: true
- uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- uses: docker/build-push-action@v2
with:
context: .
file: etc/Dockerfile
push: true
tags: rtckit/eqivo:${{ github.ref_name }}-full
- run: curl -OL https://downloads.dockerslim.com/releases/1.37.3/dist_linux.tar.gz
- run: tar zfvx dist_linux.tar.gz
- run: ./dist_linux/docker-slim build --http-probe-off --continue-after 1 --include-cert-all --include-exe=/usr/local/bin/eqivo --include-exe=/usr/local/bin/php --target rtckit/eqivo:${{ github.ref_name }}-full --tag rtckit/eqivo:${{ github.ref_name }}
- run: docker push rtckit/eqivo:${{ github.ref_name }}
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.editorconfig
.phpunit.result.cache
reports
vendor
composer.lock
etc/dev*
eqivo.phar
slim.report.json
36 changes: 36 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Contributing

Contributions are welcome, and they are greatly appreciated!

## Ways to Contribute

There are many different ways, in which you may contribute to this project, including:

* Opening issues by using the [issue tracker](https://github.com/rtckit/eqivo/issues)
* Commenting and expanding on open issues
* Propose fixes to open issues via a pull request

We suggest that you create an issue on GitHub before starting to work on a pull request, as this gives us a better overview, and allows us to start a conversation about the issue.

We also encourage you to separate unrelated contributions into different pull requests. This makes it easier for us to understand your individual contributions and faster at reviewing them.

## Terms of Service For Contributors

For all contributions to this repository (software, bug fixes, configuration changes, documentation, or any other materials), we emphasize that this happens under GitHubs general Terms of Service and the license of this repository.

### Contributing as an individual

If you are contributing as an individual you must make sure to adhere to:

The [GitHub Terms of Service](https://help.github.com/en/github/site-policy/github-terms-of-service) __*Section D. User-Generated Content,*__ [Subsection: 6. Contributions Under Repository License](https://help.github.com/en/github/site-policy/github-terms-of-service#6-contributions-under-repository-license):

_"Whenever you make a contribution to a repository containing notice of a license, you license your contribution under the same terms, and you agree that you have the right to license your contribution under those terms. If you have a separate agreement to license your contributions under different terms, such as a contributor license agreement, that agreement will supersede.
Isn't this just how it works already? Yep. This is widely accepted as the norm in the open-source community; it's commonly referred to by the shorthand "inbound=outbound". We're just making it explicit."_

### Contributing on behalf of a Corporation

If you are contributing on behalf of a Corporation you must make sure to adhere to:

The [GitHub Corporate Terms of Service](https://help.github.com/en/github/site-policy/github-corporate-terms-of-service) _**Section D. Content Responsibility; Ownership; License Rights,**_ [subsection 5. Contributions Under Repository License](https://help.github.com/en/github/site-policy/github-corporate-terms-of-service#5-contributions-under-repository-license):

_"Whenever Customer makes a contribution to a repository containing notice of a license, it licenses such contributions under the same terms and agrees that it has the right to license such contributions under those terms. If Customer has a separate agreement to license its contributions under different terms, such as a contributor license agreement, that agreement will supersede."_
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Ciprian Dosoftei

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
59 changes: 57 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,57 @@
# eqivo
Open Source Telephony API Platform
<a href="#open-source-telecommunications-api-platform">
<img loading="lazy" src="https://raw.github.com/rtckit/media/master/eqivo/readme-splash.png" alt="eqivo" class="width-full">
</a>

# Open Source Telecommunications API Platform

[![CI Status](https://github.com/rtckit/eqivo/workflows/CI/badge.svg)](https://github.com/rtckit/eqivo/actions/workflows/ci.yaml)
[![Publish Status](https://github.com/rtckit/eqivo/workflows/Publish/badge.svg)](https://github.com/rtckit/eqivo/actions/workflows/publish.yaml)
[![Latest Stable Version](https://poser.pugx.org/rtckit/eqivo/v/stable.png)](https://packagist.org/packages/rtckit/eqivo)
[![Docker Pulls](https://img.shields.io/docker/pulls/rtckit/eqivo.svg)](https://hub.docker.com/r/rtckit/eqivo)
[![Downloads on GitHub](https://img.shields.io/github/downloads/rtckit/eqivo/total?color=blue&label=Downloads%20on%20GitHub)](https://github.com/rtckit/eqivo/releases)
[![Installs on Packagist](https://img.shields.io/packagist/dt/rtckit/eqivo?color=blue&label=Installs%20on%20Packagist)](https://packagist.org/packages/rtckit/eqivo)
[![License](https://img.shields.io/badge/license-MIT-blue)](LICENSE)

A reimplementation of the open source [Plivo framework](https://github.com/plivo/plivoframework) on top of [ReactPHP](https://reactphp.org) and [FreeSWITCH](https://github.com/signalwire/freeswitch). If you are not familiar with the legacy platform, please inspect its [repository](https://github.com/plivo/plivoframework) as well as the archived web resources [here](https://web.archive.org/web/20171127130133/http://docs.plivo.org/), [here](https://web.archive.org/web/20171207074507/http://docs.plivo.org/get-started/) and [here](https://web.archive.org/web/20190108064818/https://www.plivo.com/open-source/).

For integrating **Eqivo** in your projects, please refer to **[https://eqivo.org](https://eqivo.org)**. If you want to contribute or to extend this project, keep reading.

## Requirements

**Eqivo** is compatible with PHP 8.1+ and has several extension dependencies, typically bundled with PHP's core. Please refer to [composer.json](composer.json) for details.

### Static Analysis

In order to ensure high code quality, **Eqivo** uses [PHPStan](https://github.com/phpstan/phpstan):

```sh
composer phpstan
```

and [Psalm](https://github.com/vimeo/psalm):

```sh
composer psalm
```

### Tests

Unit tests are presently lacking, yet they're [stubbed out](tests) for future development. The project itself has been scaffolded against an acceptance test suite hosted in [its own repository](https://github.com/rtckit/eqivo-acceptance-test-suite).

## License

MIT, see [LICENSE file](LICENSE).

![MIT License](https://raw.github.com/rtckit/media/master/3rd-party/mit.png)

### Acknowledgments

* [Plivo framework](https://github.com/plivo/plivoframework) - Original framework; Eqivo and its authors are not affiliated with the legacy open source project nor with with the company behind it
* [ReactPHP](https://reactphp.org) - Provides the asynchronous I/O fabric on top of which Eqivo interacts with FreeSWITCH and the consuming applications
* [FreeSWITCH](https://github.com/signalwire/freeswitch) - Handles the real time communications aspects, particularly signalling and media processing
* [Slate](https://github.com/slatedocs/slate) is responsible for rendering the [project's website](https://eqivo.org)
* [widdershins](https://github.com/Mermade/widdershins) translates the OpenApi spec to Markdown

### Contributing

Bug reports (and small patches) can be submitted via the [issue tracker](https://github.com/rtckit/eqivo/issues). Forking the repository and submitting a Pull Request is preferred for substantial patches. For more details, please head to [CONTRIBUTING.md](CONTRIBUTING.md).
116 changes: 116 additions & 0 deletions bin/eqivo
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
#!/usr/bin/env php
<?php

declare(strict_types=1);

use RTCKit\Eqivo\{
App,
Config,
HttpClient,
Inbound,
Outbound,
Rest
};

error_reporting(-1);
set_time_limit(0);

if (is_file(__DIR__ . '/../vendor/autoload.php')) {
require __DIR__ . '/../vendor/autoload.php';
} else if (is_file('./vendor/autoload.php')) {
require './vendor/autoload.php';
} else {
die('Cannot locate vendor/autoload.php file!' . PHP_EOL);
}

if (!defined('PHP_VERSION_ID') || (PHP_VERSION_ID < 80100)) {
die('Eqivo requires PHP 8.1+' . PHP_EOL);
}

foreach (['ctype', 'date', 'filter', 'json', 'libxml', 'pcre', 'simplexml'] as $ext) {
if (!extension_loaded($ext)) {
die("Please make sure '{$ext}' extension is available and enabled in your PHP configuration" . PHP_EOL);
}
}

$eqivo = new App;

$eqivo->setConfig(new Config\Set);

$eqivo->addConfigResolver(new Config\CliArguments);
$eqivo->addConfigResolver(new Config\LegacyConfigFile);
$eqivo->addConfigResolver(new Config\ConfigFile);
$eqivo->addConfigResolver(new Config\EnvironmentVars);
$eqivo->resolveConfig();

$eqivo->setHttpClient(new HttpClient);

$eqivo->setInboundServer(
(new Inbound\Server)
->setApp($eqivo)
->setController(new Inbound\Controller)
->setElementHandler(new Inbound\Handler\BackgroundJob)
->setElementHandler(new Inbound\Handler\CallUpdate)
->setElementHandler(new Inbound\Handler\ChannelHangupComplete)
->setElementHandler(new Inbound\Handler\ChannelProgress)
->setElementHandler(new Inbound\Handler\ChannelProgressMedia)
->setElementHandler(new Inbound\Handler\ChannelState)
->setElementHandler(new Inbound\Handler\Custom)
->setElementHandler(new Inbound\Handler\RecordStop)
->setElementHandler(new Inbound\Handler\SessionHeartbeat)
);

$eqivo->setOutboundServer(
(new Outbound\Server)
->setApp($eqivo)
->setController(new Outbound\Controller)
->setElementHandler(new Outbound\Conference\Handler)
->setElementHandler(new Outbound\Dial\Handler)
->setElementHandler(new Outbound\GetDigits\Handler)
->setElementHandler(new Outbound\GetSpeech\Handler)
->setElementHandler(new Outbound\Hangup\Handler)
->setElementHandler(new Outbound\Play\Handler)
->setElementHandler(new Outbound\PreAnswer\Handler)
->setElementHandler(new Outbound\Record\Handler)
->setElementHandler(new Outbound\Redirect\Handler)
->setElementHandler(new Outbound\SipTransfer\Handler)
->setElementHandler(new Outbound\Speak\Handler)
->setElementHandler(new Outbound\Wait\Handler)
);

$eqivo->setRestServer(
(new Rest\Server)
->setApp($eqivo)
->setRouteController('POST', '/v0.1/BulkCall/', new Rest\Controller\V0_1\BulkCall)
->setRouteController('POST', '/v0.1/Call/', new Rest\Controller\V0_1\Call)
->setRouteController('POST', '/v0.1/CancelScheduledHangup/', new Rest\Controller\V0_1\CancelScheduledHangup)
->setRouteController('POST', '/v0.1/CancelScheduledPlay/', new Rest\Controller\V0_1\CancelScheduledPlay)
->setRouteController('POST', '/v0.1/ConferenceDeaf/', new Rest\Controller\V0_1\ConferenceDeaf)
->setRouteController('POST', '/v0.1/ConferenceHangup/', new Rest\Controller\V0_1\ConferenceHangup)
->setRouteController('POST', '/v0.1/ConferenceKick/', new Rest\Controller\V0_1\ConferenceKick)
->setRouteController('POST', '/v0.1/ConferenceList/', new Rest\Controller\V0_1\ConferenceList)
->setRouteController('POST', '/v0.1/ConferenceListMembers/', new Rest\Controller\V0_1\ConferenceListMembers)
->setRouteController('POST', '/v0.1/ConferenceMute/', new Rest\Controller\V0_1\ConferenceMute)
->setRouteController('POST', '/v0.1/ConferencePlay/', new Rest\Controller\V0_1\ConferencePlay)
->setRouteController('POST', '/v0.1/ConferenceRecordStart/', new Rest\Controller\V0_1\ConferenceRecordStart)
->setRouteController('POST', '/v0.1/ConferenceRecordStop/', new Rest\Controller\V0_1\ConferenceRecordStop)
->setRouteController('POST', '/v0.1/ConferenceSpeak/', new Rest\Controller\V0_1\ConferenceSpeak)
->setRouteController('POST', '/v0.1/ConferenceUndeaf/', new Rest\Controller\V0_1\ConferenceUndeaf)
->setRouteController('POST', '/v0.1/ConferenceUnmute/', new Rest\Controller\V0_1\ConferenceUnmute)
->setRouteController('POST', '/v0.1/GroupCall/', new Rest\Controller\V0_1\GroupCall)
->setRouteController('POST', '/v0.1/HangupAllCalls/', new Rest\Controller\V0_1\HangupAllCalls)
->setRouteController('POST', '/v0.1/HangupCall/', new Rest\Controller\V0_1\HangupCall)
->setRouteController('POST', '/v0.1/Play/', new Rest\Controller\V0_1\Play)
->setRouteController('POST', '/v0.1/PlayStop/', new Rest\Controller\V0_1\PlayStop)
->setRouteController('POST', '/v0.1/RecordStart/', new Rest\Controller\V0_1\RecordStart)
->setRouteController('POST', '/v0.1/RecordStop/', new Rest\Controller\V0_1\RecordStop)
->setRouteController('POST', '/v0.1/ScheduleHangup/', new Rest\Controller\V0_1\ScheduleHangup)
->setRouteController('POST', '/v0.1/SchedulePlay/', new Rest\Controller\V0_1\SchedulePlay)
->setRouteController('POST', '/v0.1/SendDigits/', new Rest\Controller\V0_1\SendDigits)
->setRouteController('POST', '/v0.1/SoundTouch/', new Rest\Controller\V0_1\SoundTouch)
->setRouteController('POST', '/v0.1/SoundTouchStop/', new Rest\Controller\V0_1\SoundTouchStop)
->setRouteController('POST', '/v0.1/TransferCall/', new Rest\Controller\V0_1\TransferCall)
);

$eqivo->prepare();
$eqivo->run();
Loading

0 comments on commit 53794e4

Please sign in to comment.