{"id":23449593,"url":"https://github.com/tsaikoga/performanceprinter","last_synced_at":"2025-04-13T19:10:02.687Z","repository":{"id":57073143,"uuid":"265464568","full_name":"TsaiKoga/PerformancePrinter","owner":"TsaiKoga","description":"PerformancePrinter is a laravel package to print each requests' performance infomation for development.","archived":false,"fork":false,"pushed_at":"2022-10-16T14:15:39.000Z","size":19,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T09:46:26.471Z","etag":null,"topics":["explain-sql","laravel-json-api","printer","raw-sql","request-performance"],"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/TsaiKoga.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}},"created_at":"2020-05-20T05:51:44.000Z","updated_at":"2024-03-11T09:36:34.000Z","dependencies_parsed_at":"2022-08-24T14:54:39.813Z","dependency_job_id":null,"html_url":"https://github.com/TsaiKoga/PerformancePrinter","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TsaiKoga%2FPerformancePrinter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TsaiKoga%2FPerformancePrinter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TsaiKoga%2FPerformancePrinter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TsaiKoga%2FPerformancePrinter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TsaiKoga","download_url":"https://codeload.github.com/TsaiKoga/PerformancePrinter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248766736,"owners_count":21158301,"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":["explain-sql","laravel-json-api","printer","raw-sql","request-performance"],"created_at":"2024-12-23T23:28:04.704Z","updated_at":"2025-04-13T19:10:02.660Z","avatar_url":"https://github.com/TsaiKoga.png","language":"PHP","readme":"\u003ch1 align=\"center\"\u003ePerformance Printer\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca link=\"https://packagist.org/packages/tsaikoga/performance-printer\" style=\"text-decoration:none;\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/stable-v1.1.2-brightgreen\" alt=\"Stable\"\u003e\n\u003c/a\u003e\n\u003ca link=\"https://packagist.org/packages/tsaikoga/performance-printer\" style=\"text-decoration:none;\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/unstable-dev--master-blue\" alt=\"Unstable\"\u003e\n\u003c/a\u003e\n\u003ca link=\"https://packagist.org/packages/tsaikoga/performance-printer\" style=\"text-decoration:none;\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/license-MIT-orange.svg\" alt=\"License\"\u003e\n\u003c/a\u003e\n\u003ca link=\"https://packagist.org/packages/tsaikoga/performance-printer\" style=\"text-decoration:none;\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/laravel-5.5%2B-green\" alt=\"Laravel\"\u003e\n\u003c/a\u003e\n\u003c/p\u003e\n\nPerformance Printer is a laravel package to print each requests' performance infomation for development.\n\n\n**require** : Laravel/framework 5.5+\n\n## Features\n- Request\n\u003e Display request method, request path and request body.\n- Files\n\u003e The count of included files\n- Query\n\u003e Each raw SQL that be generated by request and the times it costs.\n\u003e\n\u003e The explain of SQL\n\u003e\n\u003e The SQL count of request\n- Response\n\u003e The response datas and the times it costs.\n\n## Usage\n1. Install the package for development environment:\n\n**Stable version**:\n```bash\ncomposer require tsaikoga/performance-printer --dev\n```\n\n**Unstable version**:\n```bash\ncomposer require tsaikoga/performance-printer:dev-master --dev\n```\n\nYou can add custom configuration for the printer.\n\n2. Create a file `config/performance_printer.php`:\n```php\n\u003c?php\nreturn [\n    // print request message\n    'request' =\u003e true,\n\n    // print response datas\n    'response' =\u003e false,\n\n    // included files count\n    'included_files_count' =\u003e true,\n\n    // print table Style\n    'table_style' =\u003e 'default',\n\n    // language: Only support English(en) and Chinese(cn) now\n    'lang' =\u003e 'cn',\n\n    'query' =\u003e [\n        // print raw sql\n        'raw_sql' =\u003e true,\n\n        // print explain sql\n        'explain' =\u003e true,\n\n        // Same queries with different bindings are superimposed\n        'unique_query' =\u003e true,\n\n        // The connections\n        'connections' =\u003e ['mysql'],\n    ],\n\n    // enable this package or disable it\n    'enable' =\u003e true,\n\n    // log\n    'log' =\u003e [\n        // is logging enable?\n        'enable' =\u003e true,\n\n        // The path that the log file stored\n        'filepath' =\u003e '/tmp/performance_printer.log',\n    ],\n];\n```\n\n3. In `.env` file, set `local` to the application environment:\n```bash\nAPP_ENV=local\n```\n\n4. Run the server:\n```bash\nphp artisan serve\n```\nIf you are using nginx or apache as server.\nTry to enable the logger for message in configuration instead, you can customize the log path (default path: `/tmp/performance_printer.log`)\n```bash\ntail -f /tmp/performance_printer.log\n```\n\n\n## Preview\nPrinting Result:\n```bash\n[ POST ] /api/user/login\n[ Content-Type ] :  application/json\n{\n\t\"user\": \"12345678910\",\n\t\"password\": \"b49f16999ce2a0a0df9b6e0e66bd4f32\"\n}\n\n[ Included Files Count ]  379\n\n[ Total ] 2 queries and ran for 16.39 ms.\n[ SQL ran for 11.56 ms ] RAW SQL: select * from `users` where `phone` = \"12345678910\" or `email` = \"12345678910\" limit 1\n\n+----+-------------+-------+------------+------+--------------------+-----+---------+-----+------+----------+-------------+\n| id | select_type | table | partitions | type | possible_keys      | key | key_len | ref | rows | filtered | Extra       |\n+----+-------------+-------+------------+------+--------------------+-----+---------+-----+------+----------+-------------+\n| 1  | SIMPLE      | users |            | ALL  | users_email_unique |     |         |     | 1770 | 19       | Using where |\n+----+-------------+-------+------------+------+--------------------+-----+---------+-----+------+----------+-------------+\n\n[ SQL ran for 4.83 ms ] RAW SQL: insert into `ticket` (`user_id`, `expire_time`, `ticket`, `updated_at`, `created_at`) values (1, \"2020-06-08 17:20:39\", \"08c14bace9bdfd9dbe3558adba463d1f198\", \"2020-06-01 17:20:39\", \"2020-06-01 17:20:39\")\n\n+----+-------------+--------+------------+------+---------------+-----+---------+-----+------+----------+-------+\n| id | select_type | table  | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |\n+----+-------------+--------+------------+------+---------------+-----+---------+-----+------+----------+-------+\n| 1  | INSERT      | ticket |            | ALL  |               |     |         |     |      |          |       |\n+----+-------------+--------+------------+------+---------------+-----+---------+-----+------+----------+-------+\n\n[ Response Load 88.63 ms] {\"code\":200,\"data\":{\"user\":{\"id\":1,\"username\":\"koga\",\"phone\":\"12345678910\",\"email\":\"koga@gmail.com\",\"created_at\":\"2020-06-01 14:45:09\",\"updated_at\":\"2019-06-01 14:45:09\",\"loginname\":\"koga\",\"from\":\"api\",\"regip\":null,\"regdate\":null,\"ticket\":\"08c14bace9bdfd9dbe3558adba463d1f198\"}},\"msg\":\"\\u767b\\u5f55\\u6210\\u529f\\uff01\"}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsaikoga%2Fperformanceprinter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftsaikoga%2Fperformanceprinter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsaikoga%2Fperformanceprinter/lists"}