{"id":30252067,"url":"https://github.com/koolreport/examples-cakephp","last_synced_at":"2025-08-15T11:10:14.376Z","repository":{"id":299749840,"uuid":"988190244","full_name":"koolreport/examples-cakephp","owner":"koolreport","description":"KoolReport examples in CakePHP","archived":false,"fork":false,"pushed_at":"2025-06-18T04:37:47.000Z","size":4125,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-18T05:33:09.643Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/koolreport.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-22T07:27:50.000Z","updated_at":"2025-06-18T04:37:50.000Z","dependencies_parsed_at":"2025-06-18T05:43:20.225Z","dependency_job_id":null,"html_url":"https://github.com/koolreport/examples-cakephp","commit_stats":null,"previous_names":["koolreport/examples-cakephp"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/koolreport/examples-cakephp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koolreport%2Fexamples-cakephp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koolreport%2Fexamples-cakephp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koolreport%2Fexamples-cakephp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koolreport%2Fexamples-cakephp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/koolreport","download_url":"https://codeload.github.com/koolreport/examples-cakephp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koolreport%2Fexamples-cakephp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270558905,"owners_count":24606612,"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","status":"online","status_checked_at":"2025-08-15T02:00:12.559Z","response_time":110,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":"2025-08-15T11:10:09.540Z","updated_at":"2025-08-15T11:10:14.366Z","avatar_url":"https://github.com/koolreport.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# KoolReport in CakePHP\n\nCakePHP is an open-source web, rapid development framework that makes building web applications simpler, faster and require less code.\n\nKoolReport is reporting framework and can be integrated into CakePHP or any other MVC framework. KoolReport help you to create data report faster and easier.\n\nIn this repository, we would like to demonstrate how KoolReport can be used in CakePHP.\n\n# Installation\n\nRun `composer` command in your CakePHP directory to install `koolreport/core`\n\n```\ncomposer require koolreport/core\n```\nor install `koolreport/pro` if you have a license for it\n\n```\ncomposer require koolreport/pro\n```\n\n# Create reports\n\n1. Inside `src` directory, create `reports` subdirectory to hold your reports.\n2. Create `MyReport.php` and `MyReport.view.php` inside `reports` directory. Assign `src\\reports` namespace for the report if you want it can be autoloaded. Otherwise, you could load the report directly in your controller when using it. Please see the contents of two files in our repository.\n\n```\nnamespace App\\reports;\nclass MyReport extends \\koolreport\\KoolReport\n{\n    ...\n```\n\n## Create route and action\n\nIn `config/routes.php`, create a route to your report and its action with a controller:\n\n```\n    $routes-\u003escope('/', function (RouteBuilder $builder): void {\n        $builder-\u003econnect('/customReport', [ 'controller' =\u003e 'Home', 'action' =\u003e 'customReport']);\n```\n\nIn the `HomeController` controller (`src/Controllers/HomeController.php`), create the action method:\n\n```\npublic function customReport()\n{\n    $report = new \\App\\reports\\MyReport();\n    $report_content = $report-\u003erun()-\u003erender(true);\n    $this-\u003eset('report_content', $report_content);\n    return $this-\u003erender('custom_report');\n}\n```\nCreate the report view `templates/Home/customReport.php` and put your report content anywhere you like:\n\n```\n\u003chtml\u003e\n...\n\u003c?php echo $report_content; ?\u003e\n\u003c/html\u003e\n```\n\nAll done!\n\n## View result\n\nPut your CodeIgniter app on your server/localhost. Then you can access after running\n\n```\nhttp://locahost/examples-cakephp/customReport\n```\n\n![combochart](combochart.png)\n\n## CSRF field/token in form submissions and xhr requests\n\nIn reports with form submission or xhr request users need to add csrf field/token to the form and request for server response to work.\n\nFor example, adding csrf field to form:\n\n```\n    \u003cform method=\"post\"\u003e\n        \u003cinput type=\"hidden\" name=\"csrfToken\" value=\"\u003c?= \\Cake\\Routing\\Router::getRequest()-\u003egetAttribute('csrfToken') ?\u003e\"\u003e\n```\nor add csrf token to request:\n\n```\n    \u003cscript\u003e\n        subReport.update(\"SaleByCountriesReport\", {\n            csrfToken:'\u003c?php echo \\Cake\\Routing\\Router::getRequest()-\u003egetAttribute('csrfToken'); ?\u003e'\n        });\n```\nor set csrf token in jQuery's ajax setup:\n\n```\n\u003cmeta name=\"csrfToken\" content=\"\u003c?= \\Cake\\Routing\\Router::getRequest()-\u003egetAttribute('csrfToken') ?\u003e\" /\u003e\n...\n\u003cscript type=\"text/javascript\"\u003e\n    $.ajaxSetup({\n        headers: {\n            'X-CSRF-TOKEN': $('meta[name=\"csrfToken\"]').attr('content')\n        }\n    });\n\u003c/script\u003e\n```\n\n# Summary\n\nKoolReport is a great php reporting framework. You can use KoolReport alone with pure php or inside any modern MVC frameworks like CakePHP, CakePHP, CodeIgniter, Yii2. If you have any questions regarding KoolReport, free free to contact us at [our forum](https://www.koolreport.com/forum/topics) or email to [support@koolreport.com](mailto:support@koolreport.com).\n\n__Happy Reporting!__","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoolreport%2Fexamples-cakephp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkoolreport%2Fexamples-cakephp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoolreport%2Fexamples-cakephp/lists"}