Skip to content

Commit 3f87cc7

Browse files
authored
Set up the PHP-SPX UI for out of the box profiling (#454)
1 parent f06e8e4 commit 3f87cc7

4 files changed

Lines changed: 17 additions & 2 deletions

File tree

CONTRIBUTING.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ To profile how a specific PDF is being parsed, you can run the parser with SPX_E
1616
docker compose exec -e SPX_ENABLED=1 php vendor/bin/phpunit tests/Samples/ --filter "gdocs-image-simple"
1717
```
1818

19+
If you want a more detailed profile, you can run the following command:
20+
21+
```bash
22+
docker compose exec -e SPX_ENABLED=1 -e SPX_REPORT=full php vendor/bin/phpunit tests/Samples/ --filter "gdocs-image-simple"
23+
```
24+
25+
you can then head to http://localhost, scroll down to the last run and click on it to view the full profile.
26+
1927
## Acquiring the specification document
2028

2129
Because the specification document is not freely available, it cannot be included in this repository directly. The specification document is downloadable on two different places:

compose.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@ services:
55
container_name: php
66
volumes:
77
- ./:/app
8+
- ./docker/php.ini:/usr/local/etc/php/conf.d/99-custom.ini
89
working_dir: /app
9-
command: sleep infinity
10+
command: php -S 0.0.0.0:80 -t /app /opt/spx/spx.php
11+
ports:
12+
- "80:80"

docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ RUN apk add --no-cache --virtual .build-deps \
1515
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
1616
&& docker-php-ext-install gd \
1717
&& pie install noisebynorthwest/php-spx \
18-
&& mkdir -p /opt/spx && echo '<?php declare(strict_types=1);' > /opt/spx/spx.php \
18+
&& mkdir -p /opt/spx && echo "<?php declare(strict_types=1); if (!isset(\$_GET['SPX_KEY']) && !isset(\$_GET['SPX_UI_URI']) && !isset(\$_GET['SPX_ENABLED'])) {header('Location: /?SPX_KEY=dev&SPX_UI_URI=/'); exit;}" > /opt/spx/spx.php \
1919
&& apk del .build-deps \
2020
&& rm -rf /tmp/* /var/tmp/* /var/cache/apk/* /usr/bin/pie
2121

docker/php.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
spx.data_dir=/tmp
2+
spx.http_enabled=1
3+
spx.http_key=dev
4+
spx.http_ip_whitelist=*

0 commit comments

Comments
 (0)