{"id":15029667,"url":"https://github.com/perftools/xhgui","last_synced_at":"2025-05-13T15:10:53.071Z","repository":{"id":5811878,"uuid":"7026843","full_name":"perftools/xhgui","owner":"perftools","description":"Web interface for XHProf profiling data can store data in MongoDB or PDO database","archived":false,"fork":false,"pushed_at":"2025-05-02T06:42:23.000Z","size":2053,"stargazers_count":1659,"open_issues_count":32,"forks_count":349,"subscribers_count":66,"default_branch":"0.23.x","last_synced_at":"2025-05-02T07:45:20.013Z","etag":null,"topics":["ext-mongodb","ext-pdo","mongodb","php","profiler","profiling-data","xhgui","xhprof"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/perftools.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2012-12-05T23:54:54.000Z","updated_at":"2025-05-02T06:42:27.000Z","dependencies_parsed_at":"2024-01-12T10:26:02.673Z","dependency_job_id":"fef07f09-e7b8-4fa4-8296-62c28ee2b3c4","html_url":"https://github.com/perftools/xhgui","commit_stats":{"total_commits":1248,"total_committers":92,"mean_commits":"13.565217391304348","dds":0.6266025641025641,"last_synced_commit":"e648dc1337dae650cb434c227bc2305d753c3f6b"},"previous_names":[],"tags_count":51,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perftools%2Fxhgui","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perftools%2Fxhgui/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perftools%2Fxhgui/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perftools%2Fxhgui/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/perftools","download_url":"https://codeload.github.com/perftools/xhgui/tar.gz/refs/heads/0.23.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253969248,"owners_count":21992263,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ext-mongodb","ext-pdo","mongodb","php","profiler","profiling-data","xhgui","xhprof"],"created_at":"2024-09-24T20:11:19.472Z","updated_at":"2025-05-13T15:10:48.045Z","avatar_url":"https://github.com/perftools.png","language":"JavaScript","readme":"# XHGui\n\nA graphical interface for XHProf profiling data that can store the results in MongoDB or PDO database.\n\nApplication is profiled and the\nprofiling data is transferred to XHGui, which takes that information, saves it\nin MongoDB (or PDO database), and provides a convenient GUI for working with\nit.\n\nThis project is the GUI for showing profiling results,\nto profile your application, use specific minimal library:\n-  [perftools/php-profiler](#profiling-a-web-request-or-cli-script)\n\n[![Build Status](https://travis-ci.org/perftools/xhgui.svg?branch=master)](https://travis-ci.org/perftools/xhgui)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/perftools/xhgui/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/perftools/xhgui/?branch=master)\n[![Code Coverage](https://scrutinizer-ci.com/g/perftools/xhgui/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/perftools/xhgui/?branch=master)\n\n# System Requirements\n\nXHGui has the following requirements:\n\n- Known to work: PHP 8.0-8.3\n- If using MongoDB storage, see [MongoDB](#MongoDB) requirements\n- If using PDO storage, see [PDO](#PDO) requirements\n- To profile an application, one of the profiling PHP extensions is required.\n  See [Profiling a Web Request or CLI script](#profiling-a-web-request-or-cli-script).\n  The extension is not needed to run XHGui itself.\n\nIf you need to decide which backend to use, you can check the [compatibility\nmatrix](#compatibility-matrix) what features are implemented or missing per\nbackend.\n\n## MongoDB\n\nThe default installation uses MongoDB database. Most of the documentation speaks about MongoDB.\n\n- [MongoDB Extension][ext-mongodb] MongoDB PHP driver: `pecl install mongodb`\n  XHGui requires version 1.3.0 or later.\n- [MongoDB][mongodb] MongoDB Itself. XHGui requires version 3.2 or later.\n\n[ext-mongodb]: https://pecl.php.net/package/mongodb\n[mongodb]: https://www.mongodb.com/\n\n## PDO\n\n- [PDO][ext-pdo] PHP extension\n\nAny of the drivers and an accompanying database:\n\n- [SQLite (PDO)][ext-pdo_sqlite]\n- [MySQL (PDO)][ext-pdo_mysql]\n- [PostgreSQL (PDO)][ext-pdo_pgsql]\n\nNOTE: PDO may not support all the features of XHGui, see [#320].\n\n[ext-pdo]: https://www.php.net/manual/en/book.pdo.php\n[ext-pdo_sqlite]: https://www.php.net/manual/en/ref.pdo-sqlite.php\n[ext-pdo_mysql]: https://www.php.net/manual/en/ref.pdo-mysql.php\n[ext-pdo_pgsql]: https://www.php.net/manual/en/ref.pdo-pgsql.php\n[#320]: https://github.com/perftools/xhgui/issues/320\n\n# Installation from source\n\n1. Clone or download `xhgui` from GitHub.\n\n2. Point your webserver to the `webroot` directory.\n\n3. Set the permissions on the `cache` directory to allow the\n   webserver to create files. If you're lazy, `0777` will work.\n\n   The following command changes the permissions for the `cache` directory:\n\n   ```bash\n   chmod -R 0777 cache\n   ```\n\n4. Start a MongoDB instance. XHGui uses the MongoDB instance to store\n   profiling data.\n\n5. If your MongoDB setup uses authentication, or isn't running on the\n   default port and localhost, update XHGui's `config/config.php` so that XHGui\n   can connect to your `mongod` instance.\n\n6. (**Optional**, but recommended) Add indexes to MongoDB to improve performance.\n\n   XHGui stores profiling information in a `results` collection in the\n   `xhprof` database in MongoDB. Adding indexes improves performance,\n   letting you navigate pages more quickly.\n\n   To add an index, open a `mongo` shell from your command prompt.\n   Then, use MongoDB's `db.collection.ensureIndex()` method to add\n   the indexes, as in the following:\n\n   ```\n   $ mongo\n   \u003e use xhprof\n   \u003e db.results.ensureIndex( { 'meta.SERVER.REQUEST_TIME' : -1 } )\n   \u003e db.results.ensureIndex( { 'profile.main().wt' : -1 } )\n   \u003e db.results.ensureIndex( { 'profile.main().mu' : -1 } )\n   \u003e db.results.ensureIndex( { 'profile.main().cpu' : -1 } )\n   \u003e db.results.ensureIndex( { 'meta.url' : 1 } )\n   \u003e db.results.ensureIndex( { 'meta.simple_url' : 1 } )\n   \u003e db.results.ensureIndex( { 'meta.SERVER.SERVER_NAME' : 1 } )\n   ```\n\n7. Install dependencies with composer\n\n   ```bash\n   composer install --no-dev\n   ```\n\n8. Set up your webserver. The Configuration section below describes how\n   to setup the rewrite rules for both nginx and apache.\n\n# Installation with Docker\n\nThis setup uses [docker-compose] to orchestrate docker containers.\n\n1. Copy example [`docker-compose.yml`][docker-compose.yml] from this project\n\n2. Startup the containers: `docker-compose up -d`\n\n3. Open your browser at http://xhgui.127.0.0.1.nip.io:8142 or just http://localhost:8142 or type at terminal `composer open`\n\n4. To customize xhgui, copy `src/config.default.php` to `config/config.php` and edit that file.\n\n[docker-compose]: https://docs.docker.com/compose/\n[docker-compose.yml]: https://github.com/perftools/xhgui/raw/HEAD/docker-compose.yml\n\n# Configuration\n\n## Configure Webserver Re-Write Rules\n\nXHGui prefers to have URL rewriting enabled, but will work without it.\nFor Apache, you can do the following to enable URL rewriting:\n\n1. Make sure that an .htaccess override is allowed and that AllowOverride\n   has the directive FileInfo set for the correct DocumentRoot.\n\n   Example configuration for Apache 2.4:\n\n   ```apache\n   \u003cDirectory /var/www/xhgui/\u003e\n       Options Indexes FollowSymLinks\n       AllowOverride FileInfo\n       Require all granted\n   \u003c/Directory\u003e\n   ```\n\n2. Make sure you are loading up mod_rewrite correctly.\n   You should see something like:\n\n   ```apache\n   LoadModule rewrite_module libexec/apache2/mod_rewrite.so\n   ```\n\n3. XHGui comes with a `.htaccess` file to enable the remaining rewrite rules.\n\nFor nginx and fast-cgi, you can use the following snippet as a start:\n\n```nginx\nserver {\n    listen   80;\n    server_name example.com;\n\n    # root directive should be global\n    root   /var/www/example.com/public/xhgui/webroot/;\n    index  index.php;\n\n    location / {\n        try_files $uri $uri/ /index.php?$args;\n    }\n\n    location ~ \\.php$ {\n        try_files $uri =404;\n        include /etc/nginx/fastcgi_params;\n        fastcgi_pass    127.0.0.1:9000;\n        fastcgi_index   index.php;\n        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\n    }\n}\n```\n\n# Profiling a Web Request or CLI script\n\nThe supported way to profile an application is to use [perftools/php-profiler]\npackage.\n\nYou can use that package to collect data from your web application or a CLI\nscript.\n\nThis data is then pushed into XHGui database where it can be viewed with XHGui\napplication.\n\nThe `php-profiler` package offers submitting data directly to XHGui instance\nonce the profiling is complete at the end of the request.\n\nIf the application cannot directly connect to XHGui instance, the package\noffers solution to capture profiling data to a file which you can import later\nusing the [import][import-jsonl-files] script.\n\n**Warning**: Importing the same file twice will create duplicate profiles.\n\n[perftools/php-profiler]: https://github.com/perftools/php-profiler\n[import-jsonl-files]: https://github.com/perftools/php-profiler#import-jsonl-files\n\n## Limiting MongoDB Disk Usage\n\nDisk usage can grow quickly, especially when profiling applications with large\ncode bases or that use larger frameworks.\n\nTo keep the growth\nin check, configure MongoDB to automatically delete profiling documents once they\nhave reached a certain age by creating a [TTL index](http://docs.mongodb.org/manual/core/index-ttl/).\n\nDecide on a maximum profile document age in seconds: you\nmay wish to choose a lower value in development (where you profile everything),\nthan production (where you profile only a selection of documents). The\nfollowing command instructs Mongo to delete documents over 5 days (432000\nseconds) old.\n\n```\n$ mongo\n\u003e use xhprof\n\u003e db.results.ensureIndex( { \"meta.request_ts\" : 1 }, { expireAfterSeconds : 432000 } )\n```\n\n## Waterfall Display\n\nThe goal of XHGui's waterfall display is to recognize that concurrent requests can\naffect each other. Concurrent database requests, CPU-intensive\nactivities and even locks on session files can become relevant. With an\nAjax-heavy application, understanding the page build is far more complex than\na single load: hopefully the waterfall can help. Remember, if you're only\nprofiling a sample of requests, the waterfall fills you with impolite lies.\n\nSome Notes:\n\n- There should probably be more indexes on MongoDB for this to be performant.\n- The waterfall display introduces storage of a new `request_ts_micro` value, as second level\n  granularity doesn't work well with waterfalls.\n- The waterfall display is still very much in alpha.\n- Feedback and pull requests are welcome :)\n\n# Monitoring\n\n[Prometheus](https://prometheus.io) metrics suitable for monitoring service\nhealth are exposed on `/metrics`.  (This currently only works if using PDO for\nstorage.)\n\n# Compatibility matrix\n\n| Feature                         | MongoDB  | PDO      |\n|---------------------------------|----------|----------|\n| Prometheus exporter             | ✗        | ✓ [#305] |\n| Searcher::latest()              | ✓        | ✓        |\n| Searcher::query()               | ✓        | ✗ [#384] |\n| Searcher::get()                 | ✓        | ✓        |\n| Searcher::getForUrl()           | ✓        | ✓ [#436] |\n| Searcher::getPercentileForUrl() | ✓        | ✓ [#436] |\n| Searcher::getAvgsForUrl()       | ✓        | ✗ [#384] |\n| Searcher::getAll(sort)          | ✓        | ✓ [#436] |\n| Searcher::getAll(direction)     | ✓        | ✓ [#436] |\n| Searcher::delete()              | ✓        | ✓        |\n| Searcher::truncate()            | ✓        | ✓        |\n| Searcher::saveWatch()           | ✓        | ✓ [#435] |\n| Searcher::getAllWatches()       | ✓        | ✓ [#435] |\n| Searcher::truncateWatches()     | ✓        | ✓ [#435] |\n| Searcher::stats()               | ✗ [#305] | ✓        |\n| Searcher::getAllServerNames()   | ✓ [#460] | ✗        |\n\n[#305]: https://github.com/perftools/xhgui/pull/305\n[#384]: https://github.com/perftools/xhgui/pull/384\n[#435]: https://github.com/perftools/xhgui/pull/435\n[#436]: https://github.com/perftools/xhgui/pull/436\n[#460]: https://github.com/perftools/xhgui/pull/460\n\n# Releases / Changelog\n\nSee the [releases](https://github.com/perftools/xhgui/releases) for changelogs,\nand release information.\n\n# License\n\nCopyright (c) 2013 Mark Story \u0026 Paul Reinheimer\n\nPermission is hereby granted, free of charge, to any person obtaining a\ncopy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be included\nin all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","funding_links":[],"categories":["调试和性能( Debugging and Profiling )"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperftools%2Fxhgui","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fperftools%2Fxhgui","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperftools%2Fxhgui/lists"}