Skip to content

Commit

Permalink
DOCS-151: Added PHP app to examples (#7)
Browse files Browse the repository at this point in the history
* DOCS-151: Added PHP app to examples

* Updated README
  • Loading branch information
vikram-rev authored Aug 17, 2022
1 parent 63c77d3 commit 1b6b4ac
Show file tree
Hide file tree
Showing 15 changed files with 2,546 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Welcome To the Rev.ai Example Repository

This repository contains examples for using the rev.ai API from either of the provided SDKs (node and python) as well as from browser.
This repository contains examples for using the rev.ai API from either of the provided SDKs (node and python) as well as from PHP and the browser.

These examples are all for public use. Simply insert your access token where required and you're ready to go.
3 changes: 3 additions & 0 deletions php_examples/voicenotes/.env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
REVAI_ACCESS_TOKEN=''
MONGODB_URI='mongodb://myuser:mypassword@mydb'
CALLBACK_PREFIX=''
3 changes: 3 additions & 0 deletions php_examples/voicenotes/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
vendor/*
.env
.tmp
5 changes: 5 additions & 0 deletions php_examples/voicenotes/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
php_value upload_max_filesize 256M
php_value post_max_size 256M
12 changes: 12 additions & 0 deletions php_examples/voicenotes/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM php:8.1.8-apache
RUN set -eux; \
apt-get update; \
apt-get install -y libcurl4-openssl-dev pkg-config libssl-dev zlib1g-dev zip git; \
pecl install mongodb; \
docker-php-ext-enable mongodb;
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
WORKDIR /var/www
RUN set -eux; \
a2enmod rewrite; \
sed -i 's!/var/www/html!/var/www/public!g' /etc/apache2/sites-available/000-default.conf
EXPOSE 80
30 changes: 30 additions & 0 deletions php_examples/voicenotes/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# PHP Web Application Example - Voice Notes

## Requirements

1. Docker
2. Rev AI access token, available at [https://rev.ai/auth/signup](https://rev.ai/auth/signup).
3. ngrok (only required when running locally or without a public webhook URL)
4. ngrok authentication token available at [https://dashboard.ngrok.com/signup](https://dashboard.ngrok.com/signup)

## Setup

1. Clone this repository. Change to the `php_examples/voicenotes` working directory.
2. Rename the `.env.sample` file to `.env`.
3. In the `.env` file, add the Rev AI access token as the value for the environment variable `REVAI_ACCESS_TOKEN`.
4. In the `.env` file, add the callback URL as the value for the environment variable `CALLBACK_PREFIX`. If you are working locally, configure an ngrok tunnel (`ngrok http 80`) and use the ngrok callback URL.

5. Start the containers, building them if necessary:

```
docker-compose up -d --build
```

6. Install Composer packages, deleting any older ones that may exist:

```
docker exec voicenotes_app rm -rf vendor/
docker exec voicenotes_app composer install
```

7. Browse to `http://YOURDOCKERHOST/index` to use the application.
10 changes: 10 additions & 0 deletions php_examples/voicenotes/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"require": {
"slim/slim": "4.*",
"slim/twig-view": "^3.3",
"php-di/php-di": "^6.4",
"slim/psr7": "^1.5",
"guzzlehttp/guzzle": "7.*",
"mongodb/mongodb": "^1.13"
}
}
Loading

0 comments on commit 1b6b4ac

Please sign in to comment.