{"id":22157700,"url":"https://github.com/link0/profiler","last_synced_at":"2025-07-26T08:32:07.181Z","repository":{"id":21090601,"uuid":"24390571","full_name":"link0/profiler","owner":"link0","description":"A profiling library for PHP using XHProf or uprofiler and providing multiple persistance layers","archived":false,"fork":false,"pushed_at":"2017-07-06T14:00:36.000Z","size":617,"stargazers_count":14,"open_issues_count":5,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-30T01:55:50.755Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/link0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-09-23T21:46:34.000Z","updated_at":"2016-05-31T09:06:43.000Z","dependencies_parsed_at":"2022-07-31T06:17:57.231Z","dependency_job_id":null,"html_url":"https://github.com/link0/profiler","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/link0%2Fprofiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/link0%2Fprofiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/link0%2Fprofiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/link0%2Fprofiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/link0","download_url":"https://codeload.github.com/link0/profiler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227291286,"owners_count":17759284,"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-12-02T03:12:56.886Z","updated_at":"2024-12-02T03:12:58.352Z","avatar_url":"https://github.com/link0.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Link0\\Profiler\n==============\n[![Latest Stable Version](https://poser.pugx.org/link0/profiler/v/stable.svg)](https://packagist.org/packages/link0/profiler)\n[![Total Downloads](https://poser.pugx.org/link0/profiler/downloads.svg)](https://packagist.org/packages/link0/profiler)\n[![License](https://poser.pugx.org/link0/profiler/license.svg)](https://packagist.org/packages/link0/profiler)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/link0/profiler/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/link0/profiler/?branch=master)\n[![Code Coverage](https://scrutinizer-ci.com/g/link0/profiler/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/link0/profiler/?branch=master)\n[![Build Status](https://scrutinizer-ci.com/g/link0/profiler/badges/build.png?b=master)](https://scrutinizer-ci.com/g/link0/profiler/build-status/master)\n\n**Link0/Profiler** as a layer over XHProf profiling, and persisting profiles for later analysis.\n\nThe code is quite new, so please report any bugs if you encounter them, even though unit-tests should cover 100% of the code.\n\nAll ideas are welcome, and contributors as well.\n\n[![SensioLabsInsight](https://insight.sensiolabs.com/projects/1151c973-75c3-41ea-b944-1e677e41862a/big.png)](https://insight.sensiolabs.com/projects/1151c973-75c3-41ea-b944-1e677e41862a)\n\nRequirements\n============\n* PHP 5.4 is required but using the latest version of PHP is highly recommended\n* [XHProf](http://pecl.php.net/package/xhprof) or [Uprofiler](https://github.com/FriendsOfPHP/uprofiler) is required to do actual profiling\n\nInstallation\n============\nTo add **Link0/Profiler** as a local, per-project dependency to your project, simply require the dependency `link0/profiler` with composer.\n\n    composer require \"link0/profiler\" \"~1.0\"\n\nThere is also a Symfony2 bundle available, see [Link0/ProfilerBundle](https://github.com/link0/ProfilerBundle). To install it, use the following composer package\n\n    composer require \"link0/profiler-bundle\" \"~1.0\"\n\nTo install XHProf on your machine\n\n    pecl install -f xhprof\n\nor \n\n    apt-get install php5-xhprof\n\nor\n\n    # If you have the josegonzalez/homebrew-php formulae tapped, install them with brew.\n    # Change your version accordingly\n    brew install php55-xhprof\n\nQuick setup with XHGui\n===============\nTo get started with this profiler package and XHGui, setup XHGui to listen to your MongoDB instance.\n\nFrom every project that you want to profile, and aggregate the results to the centralized server, setup the following config:\n\n```php\n    $connectionAddress = 'mongodb://mongodb.example.com:27017';\n    $mongoClient = new \\Link0\\Profiler\\PersistenceHandler\\MongoDbHandler\\MongoClient($connectionAddress);\n    $persistenceHandler = new \\Link0\\Profiler\\PersistenceHandler\\MongoDbHandler($mongoClient);\n    $profiler = new \\Link0\\Profiler\\Profiler($persistenceHandler);\n    $profiler-\u003estart();\n```\n\nMore in-depth\n===============\nThe library is all about the [Profiler](https://github.com/link0/profiler/blob/master/src/Link0/Profiler/Profiler.php), you want to instantiate that and let it do it's magic\n\n```php\n$profiler = new \\Link0\\Profiler\\Profiler();\n$profiler-\u003estart();\nprint_r($profiler-\u003estop());\n```\n\nIf you want to start profiling using a browser based tool like [XHProf Helper](https://chrome.google.com/webstore/detail/xhprof-helper/adnlhmmjijeflmbmlpmhilkicpnodphi?hl=en), You can use this method\n```php\n$profiler = new \\Link0\\Profiler\\Profiler();\n$profiler-\u003estartOn(@$_COOKIE['_profiler']);\n// or\n$profiler-\u003estartOn(@$_COOKIE['XHProf_Profile']);\n```\n\nIf you want to store the results, you can pass a [PersistenceHandler](https://github.com/dennisdegreef/profiler/tree/cleanup/src/Link0/Profiler/PersistenceHandler) object to the Profiler\n\n```php\n$persistenceHandler = new \\Link0\\Profiler\\PersistenceHandler\\MemoryHandler();\n$profiler = new \\Link0\\Profiler\\Profiler($persistenceHandler);\n```\n\nThis way, the results are stored in memory, may not be that convienient, but can be nice to play around with.\n\nThere is also an implementation to store profiles on the filesystem, using the [Flysystem](http://flysystem.thephpleague.com/) library.\n\n```php\n$filesystemAdapter = new \\League\\Flysystem\\Adapter\\Local('/tmp/profiler');\n$filesystem = new \\League\\Flysystem\\Filesystem($filesystemAdapter);\n$persistenceHandler = new \\Link0\\Profiler\\PersistenceHandler\\FilesystemHandler($filesystem);\n$profiler = new \\Link0\\Profiler\\Profiler($persistenceHandler);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flink0%2Fprofiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flink0%2Fprofiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flink0%2Fprofiler/lists"}