{"id":13387802,"url":"https://github.com/qihoo360/phptrace","last_synced_at":"2025-04-08T09:09:29.074Z","repository":{"id":25193979,"uuid":"28617562","full_name":"Qihoo360/phptrace","owner":"Qihoo360","description":"A tracing and troubleshooting tool for PHP scripts.","archived":false,"fork":false,"pushed_at":"2018-11-28T15:12:11.000Z","size":1704,"stargazers_count":1677,"open_issues_count":28,"forks_count":389,"subscribers_count":154,"default_branch":"master","last_synced_at":"2025-04-01T07:53:27.275Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Qihoo360.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-12-30T04:25:30.000Z","updated_at":"2025-03-11T00:51:19.000Z","dependencies_parsed_at":"2022-08-23T18:01:03.952Z","dependency_job_id":null,"html_url":"https://github.com/Qihoo360/phptrace","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Qihoo360%2Fphptrace","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Qihoo360%2Fphptrace/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Qihoo360%2Fphptrace/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Qihoo360%2Fphptrace/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Qihoo360","download_url":"https://codeload.github.com/Qihoo360/phptrace/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247809964,"owners_count":20999816,"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":[],"created_at":"2024-07-30T12:01:31.997Z","updated_at":"2025-04-08T09:09:29.053Z","avatar_url":"https://github.com/Qihoo360.png","language":"C","funding_links":[],"categories":["\u003ca id=\"1d9dec1320a5d774dc8e0e7604edfcd3\"\u003e\u003c/a\u003e工具-新添加的"],"sub_categories":["\u003ca id=\"8f1b9c5c2737493524809684b934d49a\"\u003e\u003c/a\u003e文章\u0026\u0026视频"],"readme":"# phptrace\n\n\u003e We have a new trace tool **[Molten](https://github.com/chuan-yun/Molten)**,\n\u003e It's an OpenTracing supported tracer, for Distributed Tracing System.\n\n\u003e 我们开发了新的Trace工具 **[Molten](https://github.com/chuan-yun/Molten)**，\n\u003e 它支持OpenTracing，用于分布式追踪系统。\n\n\n[![Build Status](https://travis-ci.org/Qihoo360/phptrace.svg)](https://travis-ci.org/Qihoo360/phptrace)\n\n\u003e Readme in [Chinese 中文](https://github.com/Qihoo360/phptrace/blob/master/README_ZH.md)\n\nphptrace is a low-overhead tracing tool for PHP.\n\nIt can trace all PHP executing, function calls, request information during\nrun-time. And provides features like Filter, Statistics, Current Status and so\non.\n\nIt is very useful to locate blocking, heavy-load problems and debug in all\nenvironments, especially in production environments.\n\nFeatures:\n* low-overhead, when extension loaded and trace is off\n* stable, running on [Qihoo 360](http://www.360safe.com/) and tested on mainstream frameworks\n* ease of use, view PHP run-time status without extension installation\n\nMisc:\n- [PECL Download](https://pecl.php.net/package/trace)\n\n\u003e News\n\u003e We have build another interesting project [pika](https://github.com/Qihoo360/pika).\n\u003e It's a NoSQL compatible with Redis protocol with huge storage space.\n\n\n## Install from source\n\n1. Extracting tarball\n    ```\n    tar -xf phptrace-{version}.tar.gz\n    cd phptrace-{version}/extension\n    ```\n\n2. Build\n\n    PHP Extension\n    ```\n    {php_bin_dir}/phpize\n    ./configure --with-php-config={php_bin_dir}/php-config\n    make\n    ```\n\n    CLI Binary\n    ```\n    make cli\n    ```\n\n3. Install \u0026 Configure\n\n    Install PHP Extension, CLI Binary into PHP path\n    ```\n    make install-all\n    ```\n\n    Edit `php.ini`, add the following line. A reload is needed if PHP running\n    on php-fpm mode.\n    ```\n    extension=trace.so\n    ```\n\n4. Verify\n    ```\n    php -r 'for ($i = 0; $i \u003c 20; $i++) usleep(50000);' \u0026\n    phptrace -p $!\n    ```\n\n    You should see something below if it works fine\n    ```\n    process attached\n    [pid 3600]\u003e cli php -\n    [pid 3600]\u003e {main}() called at [Command line code:1]\n    [pid 3600]    \u003e usleep(50000) called at [Command line code:1]\n    [pid 3600]    \u003c usleep(50000) = NULL called at [Command line code:1] ~ 0.051s 0.051s\n    [pid 3600]    \u003e usleep(50000) called at [Command line code:1]\n    [pid 3600]    \u003c usleep(50000) = NULL called at [Command line code:1] ~ 0.051s 0.051s\n    [pid 3600]    \u003e usleep(50000) called at [Command line code:1]\n    [pid 3600]    \u003c usleep(50000) = NULL called at [Command line code:1] ~ 0.051s 0.051s\n    [pid 3600]    \u003e usleep(50000) called at [Command line code:1]\n    ...\n    ```\n\n\n## Usage\n\nJust try `php example.php`.\n\n### Command line options\n\n* trace     trace running php process(default)\n* status    display php process status\n* version   show version\n* -p        specify php process id ('all' to trace all processes)\n* -h        show helper\n* -v        same as version\n* -f        filter data by type(url,function,class) and content\n* -l        limit output count\n* --ptrace  in status mode fetch data using ptrace\n\n### Trace executing\n\n```\n$ phptrace -p 3600\n\n[pid 3600]    \u003e Me-\u003erun() called at [example.php:57]\n[pid 3600]        \u003e Me-\u003esay(\"good night\") called at [example.php:33]\n[pid 3600]        \u003c Me-\u003esay(\"good night\") = NULL called at [example.php:33] ~ 0.000s 0.000s\n[pid 3600]        \u003e Me-\u003esleep() called at [example.php:34]\n[pid 3600]            \u003e Me-\u003esay(\"sleeping...\") called at [example.php:27]\n[pid 3600]            \u003c Me-\u003esay(\"sleeping...\") = NULL called at [example.php:27] ~ 0.000s 0.000s\n[pid 3600]            \u003e sleep(2) called at [example.php:28]\n[pid 3600]            \u003c sleep(2) = 0 called at [example.php:28] ~ 2.000s 2.000s\n[pid 3600]        \u003c Me-\u003esleep() = NULL called at [example.php:34] ~ 2.000s 0.000s\n[pid 3600]        \u003e Me-\u003esay(\"wake up\") called at [example.php:35]\n[pid 3600]        \u003c Me-\u003esay(\"wake up\") = NULL called at [example.php:35] ~ 0.000s 0.000s\n[pid 3600]    \u003c Me-\u003erun() = NULL called at [example.php:57] ~ 2.000s 0.000s\n```\n\n### Print current status\n\n```\n$ phptrace status -p 3600\n\n------------------------------- Status --------------------------------\nPHP Version:       7.0.16\nSAPI:              cli\nscript:            example.php\nelapse:            26.958s\n------------------------------ Arguments ------------------------------\n$0\n------------------------------ Backtrace ------------------------------\n#0  fgets() called at [example.php:53]\n#1  {main}() called at [example.php:53]\n```\n\n### Tracing with filter of url/class/function\n\n```\n$ phptrace -p 3600 -f type=class,content=Me\n\n[pid 3600]\u003e Me-\u003erun() called at [example.php:57]\n[pid 3600]\u003e Me-\u003esay(\"good night\") called at [example.php:33]\n[pid 3600]\u003c Me-\u003esay(\"good night\") = NULL called at [example.php:33] ~ 0.000s 0.000s\n[pid 3600]\u003e Me-\u003esleep() called at [example.php:34]\n[pid 3600]\u003e Me-\u003esay(\"sleeping...\") called at [example.php:27]\n[pid 3600]\u003c Me-\u003esay(\"sleeping...\") = NULL called at [example.php:27] ~ 0.000s 0.000s\n[pid 3600]\u003c Me-\u003esleep() = NULL called at [example.php:34] ~ 2.000s 2.000s\n[pid 3600]\u003e Me-\u003esay(\"wake up\") called at [example.php:35]\n[pid 3600]\u003c Me-\u003esay(\"wake up\") = NULL called at [example.php:35] ~ 0.000s 0.000s\n[pid 3600]\u003c Me-\u003erun() = NULL called at [example.php:57] ~ 2.001s 0.000s\n```\n\n### Limit frame/URL display times\n\n```\n$ phptrace -p 3600 -l 2\n\n[pid 3600]    \u003e Me-\u003erun() called at [example.php:57]\n[pid 3600]        \u003e Me-\u003esay(\"good night\") called at [example.php:33]\n[pid 3600]        \u003c Me-\u003esay(\"good night\") = NULL called at [example.php:33] ~ 0.000s 0.000s\n[pid 3600]        \u003e Me-\u003esleep() called at [example.php:34]\n[pid 3600]            \u003e Me-\u003esay(\"sleeping...\") called at [example.php:27]\n[pid 3600]            \u003c Me-\u003esay(\"sleeping...\") = NULL called at [example.php:27] ~ 0.000s 0.000s\n```\n\n\n## Contributing\n\nWelcome developers who willing to make PHP environment better.\n\nIf you are interested but have no idea about how to starting, please try these below:\n\n- Use it on your system, [feedback](https://github.com/monque/phptrace/issues) problem, feature request.\n- Here is [roadmap](https://github.com/monque/phptrace/projects), try to develop one.\n- Any other? Contact phobosw@gmail.com.\n\n\n## License\n\nThis project is released under the [Apache 2.0 License](https://raw.githubusercontent.com/Qihoo360/phptrace/master/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqihoo360%2Fphptrace","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqihoo360%2Fphptrace","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqihoo360%2Fphptrace/lists"}