{"id":23219123,"url":"https://github.com/b2pweb/bdf-prime-analyzer","last_synced_at":"2026-02-09T15:35:44.169Z","repository":{"id":62490850,"uuid":"365249228","full_name":"b2pweb/bdf-prime-analyzer","owner":"b2pweb","description":"Analyze queries generated by Prime ORM and dump unsafe or not optimized queries","archived":false,"fork":false,"pushed_at":"2025-11-25T15:57:29.000Z","size":152,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"1.0","last_synced_at":"2025-11-28T21:38:32.316Z","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/b2pweb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-05-07T13:51:37.000Z","updated_at":"2025-11-25T15:54:28.000Z","dependencies_parsed_at":"2024-02-26T16:54:00.715Z","dependency_job_id":"96c5252f-f857-4541-824e-5777ade4d79d","html_url":"https://github.com/b2pweb/bdf-prime-analyzer","commit_stats":{"total_commits":42,"total_committers":2,"mean_commits":21.0,"dds":"0.11904761904761907","last_synced_commit":"b9a2ce0323c4a7c9705880c1410d281fdabe39c3"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/b2pweb/bdf-prime-analyzer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b2pweb%2Fbdf-prime-analyzer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b2pweb%2Fbdf-prime-analyzer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b2pweb%2Fbdf-prime-analyzer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b2pweb%2Fbdf-prime-analyzer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/b2pweb","download_url":"https://codeload.github.com/b2pweb/bdf-prime-analyzer/tar.gz/refs/heads/1.0","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b2pweb%2Fbdf-prime-analyzer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29271037,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-09T13:47:44.167Z","status":"ssl_error","status_checked_at":"2026-02-09T13:47:43.721Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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-18T21:19:20.879Z","updated_at":"2026-02-09T15:35:44.155Z","avatar_url":"https://github.com/b2pweb.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Prime Analyzer\n[![build](https://github.com/b2pweb/bdf-prime-analyzer/actions/workflows/php.yml/badge.svg)](https://github.com/b2pweb/bdf-prime-analyzer/actions/workflows/php.yml)\n[![codecov](https://codecov.io/github/b2pweb/bdf-prime-analyzer/branch/2.0/graph/badge.svg?token=VOFSPEWYKX)](https://app.codecov.io/github/b2pweb/bdf-prime-analyzer)\n[![Packagist Version](https://img.shields.io/packagist/v/b2pweb/bdf-prime-analyzer.svg)](https://packagist.org/packages/b2pweb/bdf-prime-analyzer)\n[![Total Downloads](https://img.shields.io/packagist/dt/b2pweb/bdf-prime-analyzer.svg)](https://packagist.org/packages/b2pweb/bdf-prime-analyzer)\n[![Type Coverage](https://shepherd.dev/github/b2pweb/bdf-prime-analyzer/coverage.svg)](https://shepherd.dev/github/b2pweb/bdf-prime-analyzer)\n\nAnalyse executed queries during runtime to report suspicious queries or optimisations tips.\n\n## Usage\n\nInstall using composer\n\n```\ncomposer require --dev b2p/bdf-prime-analyzer\n```\n\nRegister on unit test case\n\n```php\n    public static function createApplication()\n    {\n        $app = require __DIR__ . '/../../app/application.php';\n        // ...\n        $app-\u003eregister(new \\Bdf\\Prime\\Analyzer\\PrimeAnalyzerServiceProvider([\n            'ignoredPath' =\u003e [dirname(__DIR__)],\n            'dumpFormats' =\u003e [\n                new \\Bdf\\Prime\\Analyzer\\Testing\\DumpFormat\\HtmlDumpFormat(__DIR__.'/prime-report.html'),\n                new \\Bdf\\Prime\\Analyzer\\Testing\\DumpFormat\\ConsoleDumpFormat(),\n            ],\n            'ignoredAnalysis' =\u003e [],\n        ]));\n        \n        // ...\n\n        return $app;\n    }\n```\n\nTo ignore analysis on a single query, simple add the `@prime-analyzer-ignore [analisys]` tag on the execute line.\n\n```php\n$credentials = $device-\u003erelation('credentials')-\u003efirst(); // @prime-analyzer-ignore optimisation sort\n```\n\nYou can also ignore analysis globally on the entity, using the docblock of the Mapper class.\nUnlike the query inline ignore, parameters can be set to ignore only the listed attributes.\n\n```php\n/**\n * Mapper for TourOperation\n *\n * @prime-analyzer-ignore sort position\n * @prime-analyzer-ignore not_declared my_raw_attribute\n * @prime-analyzer-ignore index\n */\nclass TourOperationMapper extends Mapper\n{\n    // ...\n}\n```\n\n## Options\n\nAvailable options to set on the service provider registration :\n\n- **ignoredPath** : List of path to ignore on the query analysis. For example the tests directory.\n- **ignoredAnalysis** : List of analysis to ignore. See AnalysisTypes. AnalysisTypes::optimisations() can be used to only report dangerous queries.\n- **dumpFormats** :  List of DumpFormatInterface instances. \n    * ConsoleDumpFormat : for dump in console after the end of tests\n    * HtmlDumpFormat : for dump into an HTML file\n- **register** : Set false to disable reporting\n\n## Analysis\n\n- **like** : Analyse the LIKE filters, and dump values without wildcard _ or %.\n- **index** : Dump queries without any indexes. Queries with at least one relation or join are ignored.\n- **not_declared** : Dump use of undeclared attributes (i.e. attributes not in mapper).\n- **sort** : Dump queries with an ORDER clause on non-indexed attribute. You may ignore those reports if the returned set is small.\n- **or** : Dump queries with an OR clause not nested into parenthesis.\n- **optimisation** : Dump queries which can be optimised using KeyValueQuery or findById. See limitations for more information.\n- **relation_distant_key** : Dump queries using the distant key of a relation instead of the local key. This cause a useless join. Do not handle \"through\" relations.\n- **write** : Dump invalid update or insert queries. Analyse undeclared attributes and values types.\n- **n+1** : Dump N+1 or loop queries. To raise an N+1, the queries must be at least called twice with the same stacktrace. Ignore only if the loop is desired (like walker).\n\n## Limitations\n\n- Do not handle raw expressions or join.\n- **optimisation** may generate report on relation query, which cannot be fixed, and should be ignored.\n- **n+1** may report a false positive in case of load() two relations on same entity (ex: $orderCustomer.load(['lading', 'delivery'])).\n- Always verify indexes. The **index** analysis do not replace an **EXPLAIN**.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fb2pweb%2Fbdf-prime-analyzer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fb2pweb%2Fbdf-prime-analyzer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fb2pweb%2Fbdf-prime-analyzer/lists"}