{"id":13746113,"url":"https://github.com/Tan5en5/codeigniter-debugbar","last_synced_at":"2025-05-09T06:31:18.175Z","repository":{"id":23856635,"uuid":"27234699","full_name":"Tan5en5/codeigniter-debugbar","owner":"Tan5en5","description":"CodeIgniter Debug Bar using PHP Debug Bar","archived":false,"fork":false,"pushed_at":"2021-01-14T11:31:34.000Z","size":41,"stargazers_count":57,"open_issues_count":2,"forks_count":26,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-25T23:18:11.884Z","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/Tan5en5.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}},"created_at":"2014-11-27T17:07:38.000Z","updated_at":"2024-05-01T08:01:27.000Z","dependencies_parsed_at":"2022-08-24T07:50:28.390Z","dependency_job_id":null,"html_url":"https://github.com/Tan5en5/codeigniter-debugbar","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tan5en5%2Fcodeigniter-debugbar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tan5en5%2Fcodeigniter-debugbar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tan5en5%2Fcodeigniter-debugbar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tan5en5%2Fcodeigniter-debugbar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Tan5en5","download_url":"https://codeload.github.com/Tan5en5/codeigniter-debugbar/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253206067,"owners_count":21871158,"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-08-03T06:00:47.168Z","updated_at":"2025-05-09T06:31:17.791Z","avatar_url":"https://github.com/Tan5en5.png","language":"PHP","readme":"## Requirements\r\n\r\n- PHP 5.5+ (recommended by CodeIgniter)\r\n- CodeIgniter 3.1.x\r\n\r\n## Installation\r\n\r\nCreate `composer.json` file in your application's root if there is none. Add the following text in the file: \r\n```json\r\n{\r\n    \"require\": {\r\n        \"tan5en5/codeigniter-debugbar\": \"dev-master\"\r\n    }\r\n}\r\n```\r\nEnable Composer (locate in `application/config/config.php`) :\r\n```php\r\n$config['composer_autoload'] = realpath(APPPATH.'../vendor/autoload.php');\r\n```\r\nEnable Debugbar package (locate in `application/config/autoload.php`) :\r\n```php\r\n$autoload['packages'] = array(APPPATH.'third_party/codeigniter-debugbar');\r\n```\r\nif you want to log messages and exceptions you can also load console library\r\n```php\r\n$autoload['libraries'] = array('console');\r\n```\r\nTo use it.\r\n```php\r\n$this-\u003econsole-\u003eexception(new Exception('test exception'));\r\n$this-\u003econsole-\u003edebug('Debug message');\r\n$this-\u003econsole-\u003einfo('Info message');\r\n$this-\u003econsole-\u003ewarning('Warning message');\r\n$this-\u003econsole-\u003eerror('Error message');\r\n```\r\nThen, enable the profiler like normal.\r\n```php\r\n$this-\u003eoutput-\u003eenable_profiler(TRUE);\r\n```\r\n\r\nTo complete the installation, add the following header tags :\r\n```html\r\n\u003cscript type=\"text/javascript\" src=\"//cdnjs.cloudflare.com/ajax/libs/jquery/2.2.0/jquery.min.js\"\u003e\u003c/script\u003e\r\n\u003cscript type=\"text/javascript\" src=\"//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.1.0/highlight.min.js\"\u003e\u003c/script\u003e\r\n\u003clink rel=\"stylesheet\" href=\"//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.1.0/styles/github.min.css\"\u003e\r\n\u003clink rel=\"stylesheet\" href=\"//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css\"\u003e\r\n```\r\n\r\n## Configuration\r\n**Duplicate** configuration file located in `application/third_party/codeigniter-debugbar/config/profiler.php` to `application/config/profiler.php`.\r\n\r\nTo configure the profiler, read [CodeIgniter profiler documentation](http://www.codeigniter.com/userguide3/general/profiling.html).\r\n\r\nCodeIgniter Debug Bar adds 4 new sections :\r\n\r\n- CodeIgniter infos : Display informations about CodeIgniter (version, environment and locale).\r\n- Messages : Display messages (Console library must be loaded).\r\n- Exceptions : Display exceptions (Console library must be loaded).\r\n- Included files : Display included or required files.\r\n\r\nYou can configure PHP Debug Bar directly into the profiler configuration file, read [PHP Debug Bar documentation](http://phpdebugbar.com/docs/rendering.html#rendering) for more information.\r\n\r\n## Advanced configuration\r\n\r\n### AJAX\r\n\r\nBy default ajax debug data are send through headers but if you are sending a lot of data it may cause problems with your browser. If you set `open_handler_url` in the configuration file, it will use a storage handler and the open handler to load the data after an ajax request.\r\n\r\nHere is an example of an `open_handler_url` setting.\r\n\r\n```php\r\n$config['open_handler_url'] = get_instance()-\u003econfig-\u003esite_url('debug/open_handler');\r\n```\r\n\r\nThis code will be in `application/controllers/Debug.php`\r\n\r\n```php\r\n\u003c?php\r\ndefined('BASEPATH') OR exit('No direct script access allowed');\r\n\r\nuse DebugBar\\DebugBar;\r\nuse DebugBar\\OpenHandler;\r\nuse DebugBar\\Storage\\FileStorage;\r\n\r\nclass Debug extends CI_Controller \r\n{\r\n    public function open_handler()\r\n    {\r\n        $this-\u003eoutput-\u003eenable_profiler(FALSE);\r\n        $this-\u003econfig-\u003eload('profiler', TRUE);\r\n        $path = $this-\u003econfig-\u003eitem('cache_path', 'profiler');\r\n        $cache_path = ($path === '') ? APPPATH.'cache/debugbar/' : $path;\r\n        $debugbar = new DebugBar();\r\n        $debugbar-\u003esetStorage(new FileStorage($cache_path));\r\n        $openHandler = new OpenHandler($debugbar);\r\n        $data = $openHandler-\u003ehandle(NULL, FALSE, FALSE);\r\n\r\n        $this-\u003eoutput\r\n            -\u003eset_content_type('application/json')\r\n            -\u003eset_output($data);\r\n    }\r\n}\r\n\r\n```\r\n\r\n### Output\r\n\r\nThere is two options that can be use to handle custom profiler output.\r\n\r\n- `display_assets`: Whether display content's assets (default: TRUE)\r\n- `display_javascript`: Whether display inline script (default: TRUE)\r\n\r\nIf you set `display_assets` to false you have to handle assets output manually, for this purpose you can use `CI_Profiler::css_assets()` and `CI_Profiler::js_assets()` they behave exactly like `JavascriptRenderer::dumpJsAssets()` and `JavascriptRenderer::dumpJsAssets()` see [PHP Debug Bar documentation](http://phpdebugbar.com/docs/rendering.html#assets) .\r\n\r\nIf you set `display_javascript` to false you have to handle inline script manually, for this purpose you can use `CI_Profiler::inline_script()` (**IMPORTANT** : It display inline script with \u0026lt;script\u0026gt; tags !).\r\n\r\nHere is an exmple of how you can use it:\r\n\r\n```php\r\n\u003c?php\r\n\r\n    /**\r\n     * This method handle custom profiler output if profiler is enable, except\r\n     * for json output.\r\n     */\r\n    public function _output($output)\r\n    {\r\n        if (stripos($this-\u003eoutput-\u003eget_content_type(), 'json') !== false)\r\n        {\r\n            echo $output;\r\n            return;\r\n        }\r\n\r\n        if ($this-\u003eoutput-\u003eenable_profiler)\r\n        {\r\n            $this-\u003eappendAssets()\r\n                -\u003eappendBody('\u003cscript type=\"text/javascript\" src=\"//cdnjs.cloudflare.com/ajax/libs/jquery/2.2.0/jquery.min.js\"\u003e\u003c/script\u003e')\r\n                -\u003eappendBody('\u003cscript type=\"text/javascript\" src=\"//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.1.0/highlight.min.js\"\u003e\u003c/script\u003e')\r\n                -\u003eappendHeader('\u003clink rel=\"stylesheet\" href=\"//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.1.0/styles/github.min.css\"\u003e')\r\n                -\u003eappendHeader('\u003clink rel=\"stylesheet\" href=\"//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css\"\u003e')\r\n                -\u003eappendInlineScript(trim(str_replace(['\u003cscript type=\"text/javascript\"\u003e', '\u003c/script\u003e'], ['', ''], CI_Profiler::inline_script())));\r\n        }\r\n\r\n        echo $output;\r\n    }\r\n\r\n    /**\r\n     * This method will write PhpDebugbar assets files if they don't exist in\r\n     * public directory and add them to the output with custom functions.\r\n     */\r\n    protected function appendAssets()\r\n    {\r\n        $files = ['css_assets' =\u003e 'public/css/PhpDebugbar.css', 'js_assets' =\u003e 'public/js/PhpDebugbar.js'];\r\n\r\n        foreach ($files as $function =\u003e $filepath)\r\n        {\r\n            if (!file_exists(FCPATH.$filepath))\r\n            {\r\n                forward_static_call_array(array('CI_Profiler', $function), array(FCPATH.$filepath));\r\n            }\r\n        }\r\n\r\n        return $this-\u003eappendBody('\u003cscript type=\"text/javascript\" src=\"'.base_url($files['js_assets']).'\"\u003e\u003c/script\u003e')\r\n            -\u003eappendHeader('\u003clink rel=\"stylesheet\" href=\"'.base_url($files['css_assets']).'\"\u003e');\r\n    }\r\n```\r\n\r\n**IMPORTANT** : Functions to handle profiler output can only be use in CodeIgniter controller function `_output()`.\r\n\r\n## License\r\n\r\nThe MIT License (MIT)\r\n\r\nCopyright (c) 2014-2017 Anthony Tansens\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in\r\nall copies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\nTHE SOFTWARE.\r\n","funding_links":[],"categories":["Profiler"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTan5en5%2Fcodeigniter-debugbar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FTan5en5%2Fcodeigniter-debugbar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTan5en5%2Fcodeigniter-debugbar/lists"}