-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PHP SDK Relay Server #62
Open
typotter
wants to merge
38
commits into
main
Choose a base branch
from
tp/sdktest/php
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
b54d139
PHP testing app
typotter 2318f6f
script to build and launch using a ref of the SDK
typotter 8a74a71
poller and some Docker
typotter 6f0f00f
other types
typotter 205d96b
handling env vars and running in docker
typotter dfdaa70
notes
typotter 6523ee5
WIP
typotter 1650299
wip
typotter 489829b
set base dir for php server
typotter c7f1b67
Dockeration
typotter 8e9a054
safe load .env
typotter c40ac55
refactor config
typotter d7989fc
refactor config
typotter 96fe718
hW
typotter f756863
rocking and rolling
typotter 022d56a
process single test case
typotter 3cdf687
release script
typotter c0d83a8
encode log entries before transmit
typotter 33b6c53
docker image name change
typotter 9e4c62c
return bandit requst
typotter eac5f9f
wip
typotter 410274e
debug wip
typotter dfb632a
fix bandit parsing
typotter 0f2f6ef
env var polish
typotter 6d4dc4b
Rename pkg
typotter 1018479
typo
typotter cbbab17
api config values
typotter bb43075
cleanup
typotter 0dd07e1
rename directory
typotter e91cbff
newlines
typotter 3da231e
comment
typotter 662fa8b
newlines
typotter 8edf5f9
add /sdk/rest path to PHP relay server
typotter 9a82923
docker run fix
typotter b13ebd4
clarify loggers by name
typotter 4ce3e79
guard clause
typotter e640bc0
healthcheck
typotter dad99bf
stop and clear container in run script
typotter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Set your appropriate values and save as `.env` | ||
EPPO_API_HOST=localhost | ||
EPPO_API_PORT=5000 | ||
EPPO_API_KEY=A123456780 | ||
|
||
SDK_RELAY_HOST=localhost | ||
SDK_RELAY_PORT=4000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.env | ||
vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
FROM php:8.1 | ||
|
||
# dependencies needed for composer (and for build.sh). | ||
RUN apt-get update && apt-get install -y \ | ||
git \ | ||
curl \ | ||
libpng-dev \ | ||
libonig-dev \ | ||
libxml2-dev \ | ||
zip \ | ||
unzip | ||
|
||
|
||
COPY --from=composer /usr/bin/composer /usr/bin/composer | ||
|
||
WORKDIR /relayapp | ||
|
||
COPY . . | ||
|
||
COPY --chmod=755 build.sh / | ||
|
||
RUN composer install | ||
|
||
ENV SDK_RELAY_HOST=0.0.0.0 | ||
ENV EPPO_API_HOST=host.docker.internal | ||
|
||
EXPOSE 4000 | ||
|
||
HEALTHCHECK CMD curl --fail http://localhost:4000 || exit 1 | ||
|
||
|
||
CMD ["/build.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# PHP Testing Server | ||
|
||
Post test case files to this server and check the results against what's expected. | ||
|
||
## Setup | ||
Open `.env.EXAMPLE`, set your favourite configs and then save it as `.env` | ||
|
||
## Running | ||
|
||
### Locally | ||
|
||
```shell | ||
BASH_ENV=.env SDK_REF=<your branch/tag/SHA> ./build.sh | ||
``` | ||
|
||
### With Docker | ||
#### Build Docker Image | ||
```shell | ||
docker build -t Eppo-exp/php-sdk-relay . | ||
``` | ||
|
||
#### Run the docker container | ||
```shell | ||
docker run -p $PHP_TEST_SERVER_PORT:$PHP_TEST_SERVER_PORT -t Eppo-exp/php-sdk-relay --env-file ./.env -e SDK_REF=<your branch/tag/SHA> | ||
``` | ||
|
||
## Development | ||
|
||
### Running locally | ||
|
||
```shell | ||
php -S localhost:4000 src/index.php | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env bash | ||
|
||
composer install | ||
|
||
# Set default values for vars | ||
|
||
: "${SDK_REF:=main}" | ||
: "${SDK_RELAY_HOST:=localhost}" | ||
: "${SDK_RELAY_PORT:=4000}" | ||
SDK="https://github.com/Eppo-exp/php-sdk.git" | ||
|
||
|
||
# checkout the specified ref of the SDK repo, build it, and then insert it into vendors here. | ||
mkdir -p tmp | ||
|
||
echo "Cloning ${SDK}@${SDK_REF}" | ||
git clone -b ${SDK_REF} --depth 1 --single-branch ${SDK} tmp | ||
|
||
# overwrite vendor files | ||
cp -Rf tmp/. ./vendor/eppo/php-sdk/ | ||
rm -Rf tmp | ||
|
||
# Run the poller | ||
php src/eppo_poller.php & | ||
|
||
echo "Listening on ${SDK_RELAY_HOST}:${SDK_RELAY_PORT}" | ||
|
||
php -S "${SDK_RELAY_HOST}:${SDK_RELAY_PORT}" -t src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"name": "eppo/php-sdk-test", | ||
"description": "Test server using the PHP SDK", | ||
"type": "project", | ||
"license": "MIT", | ||
"homepage": "https://github.com/Eppo-exp/sdk-test-data", | ||
"minimum-stability": "stable", | ||
"autoload": { | ||
"psr-4": { | ||
"Eppo\\SDKTest\\": "src/" | ||
} | ||
}, | ||
"authors": [ | ||
{ | ||
"name": "Ty Potter", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"require": { | ||
"php": "^8.1", | ||
"eppo/php-sdk": "^3.2", | ||
"vlucas/phpdotenv": "^5.6", | ||
"php-http/curl-client": "^2.3", | ||
"nyholm/psr7": "^1.8", | ||
"slim/slim": "^4.14", | ||
"slim/psr7": "^1.7", | ||
"php-di/php-di": "^7.0", | ||
"slim/http": "^1.4" | ||
}, | ||
"config": { | ||
"allow-plugins": { | ||
"php-http/discovery": true | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥