{"id":20207020,"url":"https://github.com/koolreport/instant","last_synced_at":"2025-04-10T12:33:17.693Z","repository":{"id":57008483,"uuid":"185561640","full_name":"koolreport/instant","owner":"koolreport","description":"Create KoolReport's report or widget instantly everywhere without setting up a full report","archived":false,"fork":false,"pushed_at":"2020-11-10T10:43:36.000Z","size":10,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T11:13:16.253Z","etag":null,"topics":["data-visualization","koolreport","reporting-engine","reporting-tool"],"latest_commit_sha":null,"homepage":"https://www.koolreport.com/","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":"CHANGELOG.md","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":"2019-05-08T08:10:06.000Z","updated_at":"2020-12-04T18:06:55.000Z","dependencies_parsed_at":"2022-08-21T14:31:36.005Z","dependency_job_id":null,"html_url":"https://github.com/koolreport/instant","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koolreport%2Finstant","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koolreport%2Finstant/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koolreport%2Finstant/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koolreport%2Finstant/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/koolreport","download_url":"https://codeload.github.com/koolreport/instant/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248217131,"owners_count":21066633,"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":["data-visualization","koolreport","reporting-engine","reporting-tool"],"created_at":"2024-11-14T05:27:10.535Z","updated_at":"2025-04-10T12:33:17.670Z","avatar_url":"https://github.com/koolreport.png","language":"PHP","readme":"# Introduction\n\nSometimes, we need to show some tables or charts in our page but setting up the whole KoolReport, despite of ease, causes trouble and is not convenient. The `Instant` package allows us to create report or widget instantly everywhere without setting up a full report.\n\nBeside `Instant` package can help you to export any file whether it is `html` or `php` to PDF and other formats.\n\n# Installation\n\n1. Download and unzip the zipped file\n2. Copy `instant` folder into `koolreport\\instant` folder\n\n# Documentation\n\n## Widget\n\n|name|return|description|\n|---|---|---|\n|create(*string* $widgetClassName, *array* $widgetParams)|null|Render the widget. This static function requires `$widgetClassName` which is the name of widget you want to create and `$widgetParams` which is any parameters you want to pass to the widget|\n\n\n## Examples\n\n### Create KoolPHP Table\n\nBelow are example of how to create Table on your PHP page\n\n```\n\u003c?php\n    require_once \"koolreport\\autoload.php\";\n    use \\koolreport\\instant\\Widget;\n    use \\koolreport\\widgets\\koolphp\\Table;\n?\u003e\n\n\u003chtml\u003e\n    \u003chead\u003e\n        \u003ctitle\u003eInstant Table\u003c/title\u003e\n    \u003c/head\u003e\n    \u003cbody\u003e\n    \u003c?php\n    Widget::create(Table::class,array(\n        \"dataSource\"=\u003earray(\n            array(\"name\"=\u003e\"Peter\",\"age\"=\u003e35),\n            array(\"name\"=\u003e\"Karl\",\"age\"=\u003e32),\n        )\n    ));\n    ?\u003e\n    \u003c/body\u003e\n\u003c/html\u003e\n```\n\nAs you see, you do not need to setup the whole KoolReport class and the view in order to use our `Widget`. With the `Instance` package, you can create any widgets you want.\n\n### Create Google BarChart\n\n```\n\u003c?php\n    require_once \"koolreport\\autoload.php\";\n    use \\koolreport\\instant\\Widget;\n    use \\koolreport\\widgets\\google\\BarChart;\n?\u003e\n\n\u003chtml\u003e\n    \u003chead\u003e\n        \u003ctitle\u003eInstant Table\u003c/title\u003e\n    \u003c/head\u003e\n    \u003cbody\u003e\n    \u003c?php\n    Widget::create(BarChart::class,array(\n        \"dataSource\"=\u003earray(\n            array(\"name\"=\u003e\"Peter\",\"age\"=\u003e35),\n            array(\"name\"=\u003e\"Karl\",\"age\"=\u003e32),\n        )\n    ));\n    ?\u003e\n    \u003c/body\u003e\n\u003c/html\u003e\n```\n\n### Create PieChart\n\n```\n\u003c?php\n    require_once \"koolreport\\autoload.php\";\n    use \\koolreport\\instant\\Widget;\n    use \\koolreport\\widgets\\google\\PieChart;\n?\u003e\n\n\u003chtml\u003e\n    \u003chead\u003e\n        \u003ctitle\u003eInstant Table\u003c/title\u003e\n    \u003c/head\u003e\n    \u003cbody\u003e\n    \u003c?php\n    Widget::create(PieChart::class,array(\n        \"dataSource\"=\u003earray(\n            array(\"browser\"=\u003e\"Chrome\",\"usage\"=\u003e44.5),\n            array(\"browser\"=\u003e\"Safari\",\"usage\"=\u003e25.4),\n            array(\"browser\"=\u003e\"Internet Explorer\",\"usage\"=\u003e15.5),\n            array(\"browser\"=\u003e\"Firefox\",\"usage\"=\u003e7.4),\n            array(\"browser\"=\u003e\"Others\",\"usage\"=\u003e7.2),\n        )\n    ));\n    ?\u003e\n    \u003c/body\u003e\n\u003c/html\u003e\n```\n\n## Assets Folder\n\n### Automatically create assets folder\n\nBy default, Instant package will create `koolreport_assets` folder automatically to hold the resources of widgets. This will assure that all widgets work seamlessly.\n\n### Manually create assets folder\n\nIf you want to organize all koolreport widget's resources into a pre-created assets folder of your own, you may do so. For example, you have `assets` folder created, you can do like below:\n\n```\n\u003c?php\nWidget::create(Table::class,array(\n    \"dataSource\"=\u003earray(\n        array(\"name\"=\u003e\"Peter\",\"age\"=\u003e35),\n        array(\"name\"=\u003e\"Karl\",\"age\"=\u003e32),        \n    )\n),array(\n    \"path\"=\u003e\"../../assets\"\n    \"url\"=\u003e\"/assets\",\n));\n?\u003e\n```\n\nThe third parameter of `create` function is optional settings for assets folder. This `assets` settings is necessary if browser can not access to the folder containing resources of Widget. By specifying the `path` and `url`, we let KoolReport know where to put Widget's resources and how to access those resources.\n\n### Turn off this feature\n\nIf you put KoolReport library in folder that can be accessed by browser, there will not be need for create `assets` folder. So you may tell instant package not to create any `assets` folder. Just input `false` value into the third parameter like below\n\n```\n\u003c?php\nWidget::create(Table::class,array(\n    \"dataSource\"=\u003earray(\n        array(\"name\"=\u003e\"Peter\",\"age\"=\u003e35),\n        array(\"name\"=\u003e\"Karl\",\"age\"=\u003e32),        \n    )\n),false);\n?\u003e\n```\n\n\n## Exporter\n\n`Exporter` helps you to ulilize the `Export` package (if you have) to export any HTML or PHP code file to PDF and other formats.\n\n```\n\u003c?php\nrequire_once \"koolreport/autoload.php\";\nuse \\koolreport\\instant\\Exporter;\n\nExporter::export(\"/full/path/to/your/file.php\")\n-\u003epdf(array(\n    \"format\"=\u003e\"A4\",\n    \"orientation\"=\u003e\"portrait\"\n))\n-\u003etoBrowser(\"myfile.pdf\");\n```\n\nor you can save file\n\n```\nExporter::export(\"/full/path/to/your/file.php\")\n-\u003epdf(array(\n    \"format\"=\u003e\"A4\",\n    \"orientation\"=\u003e\"portrait\"\n))\n-\u003esaveAs(\"myfile.pdf\");\n```\n\n## SinglePage\n\nAs you may know, to start a report, we normally need 3 files: a controller class file(ex.`MyReport.php`), a view file (ex. `MyReport.view.php`) and a initiation file (`index.php`). The `SinglePage` allows us to create report in just one file, bundling all the controller, view and initiation file into one. Please view below example:\n\n```\n\u003c?php\n//Index.php\nrequire_once \"../../../koolreport/autoload.php\";\n\nuse \\koolreport\\querybuilder\\DB;\nuse \\koolreport\\widgets\\koolphp\\Table;\n\nclass MyReport extends \\koolreport\\KoolReport\n{\n    use \\koolreport\\instant\\SinglePage;\n    use \\koolreport\\clients\\Bootstrap;\n    function settings()\n    {\n        return array(\n            \"dataSources\"=\u003earray(\n                \"automaker\"=\u003earray(\n                    \"connectionString\"=\u003e\"mysql:host=localhost;dbname=automaker\",\n                    \"username\"=\u003e\"root\",\n                    \"password\"=\u003e\"\",\n                    \"charset\"=\u003e\"utf8\"\n                ),\n            ),\n        );\n    }\n\n    function setup()\n    {\n        $this-\u003esrc('automaker')-\u003equery(\n            DB::table(\"customers\")-\u003eselect(\"customerNumber\",\"customerName\")\n        )\n        -\u003epipe($this-\u003edataStore(\"mydata\"));\n    }\n}\n\n$report = new MyReport;\n$report-\u003estart();\n?\u003e\n\n\u003chtml\u003e\n    \u003chead\u003e\n        \u003ctitle\u003eTest\u003c/title\u003e\n    \u003c/head\u003e\n    \u003cbody\u003e\n        \u003ch1\u003eTesting\u003c/h1\u003e\n        \u003c?php\n        Table::create(array(\n            \"dataSource\"=\u003e$report-\u003edataStore('mydata')\n        ));\n        ?\u003e\n    \u003c/body\u003e\n\u003c/html\u003e\n\n\u003c?php $report-\u003eend(); ?\u003e\n```\n\nAs you may see from above example, we only have 1 file `index.php` containing controller classes `MyReport` and the view inside the `start()` and `end()` methods of report. We declare `use \\koolreport\\instant\\SinglePage;` inside `MyReport` to provide two important methods above.\n\n\n## Support\n\nPlease use our forum if you need support, by this way other people can benefit as well. If the support request need privacy, you may send email to us at __support@koolreport.com__.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoolreport%2Finstant","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkoolreport%2Finstant","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoolreport%2Finstant/lists"}