Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [ '8.0', '8.1', '8.2', '8.3' ]
php: [ '8.0', '8.1', '8.2', '8.3', '8.4' ]
webserver: [ 'apache', 'nginx' ]
distroAddon: [ '', '-alpine' ]
steps:
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ FROM base${DIST_ADDON}
COPY entrypoint.d/* /opt/docker/provision/entrypoint.d/
COPY profiler.php /opt/docker/profiler.php
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/bin/
RUN install-php-extensions @fix_letsencrypt xhprof mongodb pcov && \
RUN install-php-extensions @fix_letsencrypt xhprof pcov && \
echo "auto_prepend_file=/opt/docker/profiler.php" >> /opt/docker/etc/php/php.ini && \
echo "pcov.enabled=0" >> /usr/local/etc/php/conf.d/docker-php-ext-pcov.ini && \
echo "pcov.exclude='~vendor~'" >> /usr/local/etc/php/conf.d/docker-php-ext-pcov.ini && \
Expand Down Expand Up @@ -50,7 +50,7 @@ ENV \
XHGUI_PROFILING="enabled" \
TZ=Europe/Berlin

RUN composer global require davidrjonas/composer-lock-diff perftools/xhgui-collector alcaeus/mongo-php-adapter perftools/php-profiler && \
RUN composer global require davidrjonas/composer-lock-diff perftools/php-profiler && \
composer clear && \
echo "source ~/.additional_bashrc.sh" >> ~/.bashrc && \
curl -L https://raw.github.com/git/git/master/contrib/completion/git-prompt.sh > ~/.bash_git
Expand Down
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ We recommend using [pluswerk/docker-global](https://github.com/pluswerk/docker-g

# Tags

- php versions supported: `8.0`-`8.3`
- php versions supported: `8.0`-`8.4`
- php versions unsupported: `5.6`-`7.4`
- webserver supported: `nginx` and `apache`
- alpine images: `-alpine`
- examples
- `pluswerk/php-dev:nginx-8.3-alpine`
- `pluswerk/php-dev:nginx-8.4-alpine`
- `pluswerk/php-dev:apache-8.0-alpine`
- `pluswerk/php-dev:nginx-8.2`
- list of [all Tags](https://github.com/pluswerk/php-dev/pkgs/container/php-dev/versions?filters%5Bversion_type%5D=tagged)
Expand Down Expand Up @@ -56,7 +56,7 @@ Example file: compose/Development/docker-compose.yml
```yaml
services:
web:
image: pluswerk/php-dev:nginx-8.3-alpine
image: pluswerk/php-dev:nginx-8.4-alpine

volumes:
- .:/app
Expand All @@ -68,32 +68,32 @@ services:

environment:
# Take a look at VIRTUAL_* in the documentation under Nginx Reverse Proxy
- VIRTUAL_HOST=docker-website.${TLD_DOMAIN:?TLD_DOMAIN is required},sub.docker-website.${TLD_DOMAIN:?TLD_DOMAIN is required}
# - HTTPS_METHOD=noredirect
VIRTUAL_HOST: docker-website.${TLD_DOMAIN:?TLD_DOMAIN is required},sub.docker-website.${TLD_DOMAIN:?TLD_DOMAIN is required}
# HTTPS_METHOD: noredirect

- WEB_DOCUMENT_ROOT=/app/public
- XDEBUG_CLIENT_HOST=${XDEBUG_CLIENT_HOST:-}
- php.xdebug.idekey=${XDEBUG_IDEKEY:-PHPSTORM}
- PHP_IDE_CONFIG=${XDEBUG_IDEKEY:-"serverName=_"}
WEB_DOCUMENT_ROOT: /app/public
XDEBUG_CLIENT_HOST: ${XDEBUG_CLIENT_HOST:-}
php.xdebug.idekey: ${XDEBUG_IDEKEY:-PHPSTORM}
PHP_IDE_CONFIG: ${XDEBUG_IDEKEY:-"serverName=_"}

# Project Env vars (enable what you need)
# - APP_ENV=development_docker
# - PIMCORE_ENVIRONMENT=development_docker
# - TYPO3_CONTEXT=Development/docker
# APP_ENV: development_docker
# PIMCORE_ENVIRONMENT: development_docker
# TYPO3_CONTEXT: Development/docker

# Don't forget to connect via bash start.sh
- APPLICATION_UID=${APPLICATION_UID:-1000}
- APPLICATION_GID=${APPLICATION_GID:-1000}
APPLICATION_UID: ${APPLICATION_UID:-1000}
APPLICATION_GID: ${APPLICATION_GID:-1000}

node:
image: node:18
image: node:24
volumes:
- ./:/app
working_dir: /app
environment:
# Don't forget to connect via bash start.sh
- APPLICATION_UID=${APPLICATION_UID:-1000}
- APPLICATION_GID=${APPLICATION_GID:-1000}
APPLICATION_UID: ${APPLICATION_UID:-1000}
APPLICATION_GID: ${APPLICATION_GID:-1000}
stop_signal: SIGKILL
entrypoint: bash -c 'groupmod -g $$APPLICATION_GID node; usermod -u $$APPLICATION_UID node; sleep infinity'

Expand Down
60 changes: 9 additions & 51 deletions profiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,65 +3,23 @@
// we do not want the /home/application/.config/composer/vendor/autoload.php
// we want minimal file inclusion.

if ((isset($_COOKIE['XDEBUG_PROFILE']) || getenv('PROFILING_ENABLED'))) {
if (!isset($_COOKIE['XDEBUG_PROFILE']) && !getenv('PROFILING_ENABLED')) {
return;
}

(function () {
$composerVendorDir = '/home/application/.composer/vendor';
if (!is_dir($composerVendorDir)) {
$composerVendorDir = '/home/application/.config/composer/vendor';
}
require_once $composerVendorDir . '/perftools/php-profiler/autoload.php';

$tmpFile = '/tmp/' . uniqid('xhgui', true) . '.data.jsonl';

$profiler = new \Xhgui\Profiler\Profiler(
[
'profiler' => \Xhgui\Profiler\Profiler::PROFILER_XHPROF,
# 'save.handler' => \Xhgui\Profiler\Profiler::SAVER_MONGODB,

'save.handler' => \Xhgui\Profiler\Profiler::SAVER_FILE,
'save.handler.file' => [
// Appends jsonlines formatted data to this path
'filename' => $tmpFile,
'save.handler.upload' => [
'url' => 'http://' . (getenv('XHGUI_MONGO_HOST') ?: 'global-xhgui') . '/run/import',
],
]
);
$profiler->enable();


register_shutdown_function(static function () use ($composerVendorDir, $tmpFile, $profiler) {
//we want this autoloading only after the main php script executed everything.
require_once $composerVendorDir . '/autoload.php';
$profiler->stop();

//huge performance Optimisation possible:
// do not import into mongodb at this point, do it asyncroniasly in the background
//return;
$saver = \Xhgui\Profiler\SaverFactory::create(
\Xhgui\Profiler\Profiler::SAVER_MONGODB,
new \Xhgui\Profiler\Config(
[
'save.handler.mongodb' => [
'dsn' => 'mongodb://' . str_replace('mongodb://', '', getenv('XHGUI_MONGO_URI') ?: 'global-xhgui:27017'),
'database' => 'xhprof',
// Allows you to pass additional options like replicaSet to MongoClient.
// 'username', 'password' and 'db' (where the user is added)
'options' => [],
// Allows you to pass driver options like ca_file to MongoClient
'driverOptions' => [],
],
]
)
);
if (!$saver) {
throw new RuntimeException("Unable to obtain saver");
}

$importer = new \Xhgui\Profiler\Importer($saver);
$fp = fopen($tmpFile, 'r');
if (!$fp) {
throw new RuntimeException("Can't open " . $tmpFile);
}
$importer->import($fp);
fclose($fp);
unlink($tmpFile);
});
$profiler->start();
}
)();
Loading