{"id":24705943,"url":"https://github.com/zunnu/cake-htmx","last_synced_at":"2026-01-15T03:58:17.687Z","repository":{"id":219933545,"uuid":"750297927","full_name":"zunnu/cake-htmx","owner":"zunnu","description":"CakePHP helper library for Htmx","archived":false,"fork":false,"pushed_at":"2025-12-03T15:08:25.000Z","size":56,"stargazers_count":18,"open_issues_count":0,"forks_count":5,"subscribers_count":4,"default_branch":"main","last_synced_at":"2026-01-14T14:14:18.297Z","etag":null,"topics":["ajax","backend","cakephp","cakephp-plugin","frontend","htmx","htmx-cakephp","php","web-development"],"latest_commit_sha":null,"homepage":"","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/zunnu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2024-01-30T11:26:10.000Z","updated_at":"2025-12-03T14:57:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"810fb827-3174-487f-8347-fd17e7415ab2","html_url":"https://github.com/zunnu/cake-htmx","commit_stats":null,"previous_names":["zunnu/cake-htmx"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/zunnu/cake-htmx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zunnu%2Fcake-htmx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zunnu%2Fcake-htmx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zunnu%2Fcake-htmx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zunnu%2Fcake-htmx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zunnu","download_url":"https://codeload.github.com/zunnu/cake-htmx/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zunnu%2Fcake-htmx/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28442357,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-15T00:55:22.719Z","status":"online","status_checked_at":"2026-01-15T02:00:08.019Z","response_time":62,"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":["ajax","backend","cakephp","cakephp-plugin","frontend","htmx","htmx-cakephp","php","web-development"],"created_at":"2025-01-27T06:01:57.773Z","updated_at":"2026-01-15T03:58:17.670Z","avatar_url":"https://github.com/zunnu.png","language":"PHP","funding_links":[],"categories":["Miscellaneous","Tools","Plugins"],"sub_categories":["Miscellaneous"],"readme":"# cake-htmx\n\nCakePHP integration for [htmx](https://htmx.org/).\n\nSupported CakePHP Versions \u003e= [4.x](https://github.com/zunnu/cake-htmx/tree/4.x) and 5.x.\n\n## Installing Using [Composer][composer]\n\n`cd` to the root of your app folder (where the `composer.json` file is) and run the following command:\n\n```\ncomposer require zunnu/cake-htmx\n```\nThen load the plugin by using CakePHP's console:\n\n```\n./bin/cake plugin load CakeHtmx\n```\nTo install htmx please browse [their documentation](https://htmx.org/docs/#installing)\n\n## Usage\n\nMain functionality is currently wrapped inside Htmx component.\nTo load the component you will need to modify your `src/Controller/AppController.php` and load the Htmx component in the `initialize()` function\n```php\n$this-\u003eloadComponent('CakeHtmx.Htmx');\n```\n\n### Request\n\nYou can use detector to check if the request is Htmx.  \n```php\n$this-\u003egetRequest()-\u003eis('htmx')  // Always true if the request is performed by Htmx\n$this-\u003egetRequest()-\u003eis('boosted') // Indicates that the request is via an element using hx-boost\n$this-\u003egetRequest()-\u003eis('htmx-noboost') // Convenience check that returns true if the request is htmx but not boosted.\n$this-\u003egetRequest()-\u003eis('historyRestoreRequest') // True if the request is for history restoration after a miss in the local history cache\n```\nUsing the component you can check more specific details about the request.  \n```php\n$this-\u003eHtmx-\u003egetCurrentUrl();  // The current URL of the browser\n$this-\u003eHtmx-\u003egetPromptResponse(); // The user response to an hx-prompt\n$this-\u003eHtmx-\u003egetTarget(); // The id of the target element if it exists\n$this-\u003eHtmx-\u003egetTriggerName(); // The name of the triggered element if it exists\n$this-\u003eHtmx-\u003egetTriggerId(); // The id of the triggered element if it exists\n```\n\n### Response\n- `redirect`\n\nHtmx can trigger a client side redirect when it receives a response with the `HX-Redirect` [header](https://htmx.org/reference/#response_headers).  \n\n```php\n$this-\u003eHtmx-\u003eredirect('/somewhere-else');\n```\n\n- `clientRefresh`\n\nHtmx will trigger a page reload when it receives a response with the `HX-Refresh` [header](https://htmx.org/reference/#response_headers). `clientRefresh` is a custom response that allows you to send such a response. It takes no arguments, since Htmx ignores any content.\n\n```php\n$this-\u003eHtmx-\u003eclientRefresh();\n```\n\n- `stopPolling`\n\nWhen using a [polling trigger](https://htmx.org/docs/#polling), Htmx will stop polling when it encounters a response with the special HTTP status code 286. `stopPolling` is a custom response with that status code.\n\n```php\n$this-\u003eHtmx-\u003estopPolling();\n```\n\nSee the documentation for all the remaining [available headers](https://htmx.org/reference/#response_headers).  \n```php\n$this-\u003eHtmx-\u003elocation($location) // Allows you to do a client-side redirect that does not do a full page reload\n$this-\u003eHtmx-\u003epushUrl($url) // pushes a new url into the history stack\n$this-\u003eHtmx-\u003ereplaceUrl($url) // replaces the current URL in the location bar\n$this-\u003eHtmx-\u003ereswap($option) // Allows you to specify how the response will be swapped\n$this-\u003eHtmx-\u003eretarget($selector); // A CSS selector that updates the target of the content update to a different element on the page\n```\nAdditionally, you can trigger [client-side events](https://htmx.org/headers/hx-trigger/) using the `addTrigger` methods.\n\n```php\n$this-\u003eHtmx\n    -\u003eaddTrigger('myEvent')\n    -\u003eaddTriggerAfterSettle('myEventAfterSettle')\n    -\u003eaddTriggerAfterSwap('myEventAfterSwap');\n```\n\nIf you want to pass details along with the event you can use the second argument to send a body. It supports strings or arrays.\n\n```php\n$this-\u003eHtmx-\u003eaddTrigger('myEvent', 'Hello from myEvent')\n-\u003eaddTriggerAfterSettle('showMessage', [\n    'level' =\u003e 'info',\n    'message' =\u003e 'Here is a Message'\n]);\n```\n\nYou can call those methods multiple times if you want to trigger multiple events.\n\n```php\n$this-\u003eHtmx\n    -\u003eaddTrigger('trigger1', 'A Message')\n    -\u003eaddTrigger('trigger2', 'Another Message')\n```\n\n## CSRF token\n\nTo add CSRF token to all your request add below code to your layout.\n\n```php\ndocument.body.addEventListener('htmx:configRequest', (event) =\u003e {\n    event.detail.headers['X-CSRF-Token'] = \"\u003c?= $this-\u003egetRequest()-\u003egetAttribute('csrfToken') ?\u003e\";\n})\n```\n\n## Rendering blocks and OOB Swap\nThe `setBlock()` function allows you to render a specific block while removing other blocks that might be rendered. This is particularly useful when you need to update only a portion of your view.\n\nCalling `setBlock(null)` clears any selection.\n\n```php\n$this-\u003eHtmx-\u003esetBlock('userTable');\n```\nThe `addBlock()` function allows you to add a specific block to the list of blocks that should be rendered.\n\n```php\n$this-\u003eHtmx-\u003eaddBlock('userTable');\n```\nThe `addBlocks()` function allows you to add multiple blocks to the list of blocks that should be rendered\n```php\n$this-\u003eHtmx-\u003eaddBlocks(['userTable', 'pagination']);\n$this-\u003eHtmx-\u003eaddBlocks(['userTable', 'pagination'], true); // Appends the blocks to the existing array.\n```\n\u003e **Note:** `addBlocks()` appends by default. Pass `false` as the second argument to replace:\n\u003e\n\u003e ```php\n\u003e $this-\u003eHtmx-\u003eaddBlocks(['usersTable', 'pagination']);           // append (default)\n\u003e $this-\u003eHtmx-\u003eaddBlocks(['onlyThis'], false);                    // replace\n\u003e ```\n\n### OOB Swap\nHtmx supports updating multiple targets by returning multiple partial responses with [`hx-swap-oob`](https://htmx.org/docs/#oob_swaps).\nSee the example `Users index search functionality with pagination update`\nNote if you are working with tables like in the example. You might need to add\n```javascript\n\u003cscript type=\"text/javascript\"\u003e\n    htmx.config.useTemplateFragments = true;\n\u003c/script\u003e\n```\nIn your template or layout.\n\n\n### Clearing Blocks\nYou can clear the current block selection in two equivalent ways:\n```php\n// Explicitly clear any selection\n$this-\u003eHtmx-\u003eclearBlocks();\n\n// Or, using setBlock(null)\n$this-\u003eHtmx-\u003esetBlock(null);\n```\n\n## Examples\n\n### Users index search functionality\n\nIn this example, we will implement a search functionality for the users' index using Htmx to filter results dynamically. We will wrap our table body inside a [viewBlock](https://book.cakephp.org/5/en/views.html#using-view-blocks) called `usersTable`. When the page loads, we will render the `usersTable` [viewBlock](https://book.cakephp.org/5/en/views.html#using-view-blocks).\n\n```php\n// Template/Users/index.php\n\n\u003c?= $this-\u003eForm-\u003econtrol('search', [\n    'label' =\u003e false, \n    'placeholder' =\u003e __('Search'),\n    'type' =\u003e 'text', \n    'required' =\u003e false, \n    'class' =\u003e 'form-control input-text search',\n    'value' =\u003e !empty($search) ? $search : '',\n    'hx-get' =\u003e $this-\u003eUrl-\u003ebuild(['controller' =\u003e 'Users', 'action' =\u003e 'index']),\n    'hx-trigger' =\u003e \"keyup changed delay:200ms\",\n    'hx-target' =\u003e \"#search-results\",\n    'templates' =\u003e [\n        'inputContainer' =\u003e '\u003cdiv class=\"col-10 col-md-6 col-lg-5\"\u003e{{content}}\u003c/div\u003e'\n    ]\n]); ?\u003e\n\n\u003ctable id=\"usersTable\" class=\"table table-hover table-white-bordered\"\u003e\n    \u003cthead\u003e\n        \u003ctr\u003e\n            \u003cth scope=\"col\"\u003e\u003c?= 'id' ?\u003e\u003c/th\u003e\n            \u003cth scope=\"col\"\u003e\u003c?= 'Name' ?\u003e\u003c/th\u003e\n            \u003cth scope=\"col\"\u003e\u003c?= 'Email' ?\u003e\u003c/th\u003e\n            \u003cth scope=\"col\"\u003e\u003c?= 'Modified' ?\u003e\u003c/th\u003e\n            \u003cth scope=\"col\"\u003e\u003c?= 'Created' ?\u003e\u003c/th\u003e\n            \u003cth scope=\"col\" class=\"actions\"\u003e\u003c?= 'Actions' ?\u003e\u003c/th\u003e\n        \u003c/tr\u003e\n    \u003c/thead\u003e\n    \n    \u003ctbody id=\"search-results\"\u003e\n        \u003c?php $this-\u003estart('usersTable'); ?\u003e\n            \u003c?php foreach ($users as $user): ?\u003e\n                \u003ctr\u003e\n                    \u003ctd\u003e\u003c?= $user-\u003eid ?\u003e\u003c/td\u003e\n                    \u003ctd\u003e\u003c?= h($user-\u003ename) ?\u003e\u003c/td\u003e\n                    \u003ctd\u003e\u003c?= h($user-\u003eemail) ?\u003e\u003c/td\u003e\n                    \u003ctd\u003e\u003c?= $user-\u003emodified ?\u003e\u003c/td\u003e\n                    \u003ctd\u003e\u003c?= $user-\u003ecreated ?\u003e\u003c/td\u003e\n                    \u003ctd class=\"actions\"\u003e\n                        \u003c?= $this-\u003eHtml-\u003elink('Edit',\n                            [\n                                'action' =\u003e 'edit',\n                                $user-\u003eid\n                            ],\n                            [\n                                'escape' =\u003e false\n                            ]\n                        ); ?\u003e\n                        \u003c?= $this-\u003eForm-\u003epostLink('Delete',\n                            [\n                                'action' =\u003e 'delete',\n                                $user-\u003eid\n                            ],\n                            [\n                                'confirm' =\u003e __('Are you sure you want to delete user {0}?', $user-\u003eemail),\n                                'escape' =\u003e false\n                            ]\n                        ); ?\u003e\n                    \u003c/td\u003e\n                \u003c/tr\u003e\n            \u003c?php endforeach; ?\u003e\n        \u003c?php $this-\u003eend(); ?\u003e\n\n        \u003c?php echo $this-\u003efetch('usersTable'); ?\u003e\n    \u003c/tbody\u003e\n\u003c/table\u003e\n```\nIn out controller we will check if the request is Htmx and if so then we will only render the `usersTable` [viewBlock](https://book.cakephp.org/5/en/views.html#using-view-blocks).\n\n```php\n// src/Controller/UsersController.php\n\npublic function index()\n{\n    $search = null;\n    $query = $this-\u003eUsers-\u003efind('all');\n\n    if ($this-\u003erequest-\u003eis('get')) {\n        if(!empty($this-\u003erequest-\u003egetQueryParams())) {\n            $data = $this-\u003erequest-\u003egetQueryParams();\n\n            if(isset($data['search'])) {\n                $data = $data['search'];\n                $conditions = [\n                    'OR' =\u003e [\n                        'Users.id' =\u003e (int)$data,\n                        'Users.name LIKE' =\u003e '%' . $data . '%',\n                        'Users.email LIKE' =\u003e '%' . $data . '%',\n                    ],\n                ];\n                $query = $query-\u003ewhere([$conditions]);\n                $search = $data;\n            }\n        }\n    }\n\n    $users = $query-\u003etoArray();\n    $this-\u003eset(compact('users', 'search'));\n\n    if($this-\u003egetRequest()-\u003eis('htmx')) {\n        $this-\u003eviewBuilder()-\u003edisableAutoLayout();\n\n        // we will only render the usersTable viewblock\n        $this-\u003eHtmx-\u003esetBlock('usersTable');\n    }\n}\n```\n\n### Users index search functionality with pagination update\nIn this example, we will implement a dynamic search functionality for the users' index using Htmx. This will allow us to filter results in real-time and update pagination accordingly. We will wrap our table body inside a [viewBlock](https://book.cakephp.org/5/en/views.html#using-view-blocks) called `usersTable` and our pagination to `pagination` block. When the page loads, we will render both the `usersTable` and `pagination` [viewBlock](https://book.cakephp.org/5/en/views.html#using-view-blocks).\n\n```php\n// Template/Users/index.php\n\n\u003c?= $this-\u003eForm-\u003econtrol('search', [\n    'label' =\u003e false, \n    'placeholder' =\u003e __('Search'),\n    'type' =\u003e 'text', \n    'required' =\u003e false, \n    'class' =\u003e 'form-control input-text search',\n    'value' =\u003e !empty($search) ? $search : '',\n    'hx-get' =\u003e $this-\u003eUrl-\u003ebuild(['controller' =\u003e 'Users', 'action' =\u003e 'index']),\n    'hx-trigger' =\u003e 'keyup changed delay:200ms',\n    'hx-target' =\u003e '#search-results',\n    'hx-push-url' =\u003e 'true',\n    'templates' =\u003e [\n        'inputContainer' =\u003e '\u003cdiv class=\"col-10 col-md-6 col-lg-5\"\u003e{{content}}\u003c/div\u003e'\n    ]\n]); ?\u003e\n\n\u003ctable id=\"usersTable\" class=\"table table-hover table-white-bordered\"\u003e\n    \u003cthead\u003e\n        \u003ctr\u003e\n            \u003cth scope=\"col\"\u003e\u003c?= 'id' ?\u003e\u003c/th\u003e\n            \u003cth scope=\"col\"\u003e\u003c?= 'Name' ?\u003e\u003c/th\u003e\n            \u003cth scope=\"col\"\u003e\u003c?= 'Email' ?\u003e\u003c/th\u003e\n            \u003cth scope=\"col\"\u003e\u003c?= 'Modified' ?\u003e\u003c/th\u003e\n            \u003cth scope=\"col\"\u003e\u003c?= 'Created' ?\u003e\u003c/th\u003e\n            \u003cth scope=\"col\" class=\"actions\"\u003e\u003c?= 'Actions' ?\u003e\u003c/th\u003e\n        \u003c/tr\u003e\n    \u003c/thead\u003e\n    \n    \u003ctbody id=\"search-results\"\u003e\n        \u003c?php $this-\u003estart('usersTable'); ?\u003e\n            \u003c?php foreach ($users as $user): ?\u003e\n                \u003ctr\u003e\n                    \u003ctd\u003e\u003c?= $user-\u003eid ?\u003e\u003c/td\u003e\n                    \u003ctd\u003e\u003c?= h($user-\u003ename) ?\u003e\u003c/td\u003e\n                    \u003ctd\u003e\u003c?= h($user-\u003eemail) ?\u003e\u003c/td\u003e\n                    \u003ctd\u003e\u003c?= $user-\u003emodified ?\u003e\u003c/td\u003e\n                    \u003ctd\u003e\u003c?= $user-\u003ecreated ?\u003e\u003c/td\u003e\n                    \u003ctd class=\"actions\"\u003e\n                        \u003c?= $this-\u003eHtml-\u003elink('Edit',\n                            [\n                                'action' =\u003e 'edit',\n                                $user-\u003eid\n                            ],\n                            [\n                                'escape' =\u003e false\n                            ]\n                        ); ?\u003e\n                        \u003c?= $this-\u003eForm-\u003epostLink('Delete',\n                            [\n                                'action' =\u003e 'delete',\n                                $user-\u003eid\n                            ],\n                            [\n                                'confirm' =\u003e __('Are you sure you want to delete user {0}?', $user-\u003eemail),\n                                'escape' =\u003e false\n                            ]\n                        ); ?\u003e\n                    \u003c/td\u003e\n                \u003c/tr\u003e\n            \u003c?php endforeach; ?\u003e\n        \u003c?php $this-\u003eend(); ?\u003e\n\n        \u003c?php echo $this-\u003efetch('usersTable'); ?\u003e\n    \u003c/tbody\u003e\n\u003c/table\u003e\n\n// pagination\n\u003c?php $this-\u003estart('pagination'); ?\u003e\n    \u003cnav aria-label=\"Page navigation\" id=\"pagination\"\u003e\n        \u003cul class=\"pagination justify-content-center\"\u003e\n            \u003c?php $this-\u003ePaginator-\u003esetTemplates([\n                'prevActive' =\u003e '\u003cli class=\"page-item pagination-previous\"\u003e\u003ca class=\"page-link\" hx-get=\"{{url}}\" hx-target=\"#search-results\" hx-push-url=\"true\" href=\"#\"\u003e{{text}}\u003c/a\u003e\u003c/li\u003e',\n                'prevDisabled' =\u003e '\u003cli class=\"page-item disabled pagination-previous\"\u003e\u003ca class=\"page-link\" hx-get=\"{{url}}\" hx-target=\"#search-results\" hx-push-url=\"true\" href=\"#\"\u003e{{text}}\u003c/a\u003e\u003c/li\u003e',\n                'number' =\u003e '\u003cli class=\"page-item\"\u003e\u003ca class=\"page-link\" hx-get=\"{{url}}\" hx-target=\"#search-results\" hx-push-url=\"true\" href=\"#\"\u003e{{text}}\u003c/a\u003e\u003c/li\u003e',\n                'current' =\u003e '\u003cli class=\"page-item active\"\u003e\u003ca class=\"page-link\" hx-get=\"{{url}}\" hx-target=\"#search-results\" hx-push-url=\"true\" href=\"#\"\u003e{{text}}\u003c/a\u003e\u003c/li\u003e',\n                'nextActive' =\u003e '\u003cli class=\"page-item pagination-next\"\u003e\u003ca class=\"page-link\" hx-get=\"{{url}}\" hx-target=\"#search-results\" hx-push-url=\"true\" href=\"#\"\u003e{{text}}\u003c/a\u003e\u003c/li\u003e',\n                'nextDisabled' =\u003e '\u003cli class=\"page-item disabled pagination-next\"\u003e\u003ca class=\"page-link\" hx-get=\"{{url}}\" hx-target=\"#search-results\" hx-push-url=\"true\" href=\"#\"\u003e{{text}}\u003c/a\u003e\u003c/li\u003e',\n                'first' =\u003e '\u003cli class=\"page-item pagination-next\"\u003e\u003ca class=\"page-link\" hx-get=\"{{url}}\" hx-target=\"#search-results\" hx-push-url=\"true\" href=\"#\"\u003e{{text}}\u003c/a\u003e\u003c/li\u003e',\n                'last' =\u003e '\u003cli class=\"page-item pagination-next\"\u003e\u003ca class=\"page-link\" hx-get=\"{{url}}\" hx-target=\"#search-results\" hx-push-url=\"true\" href=\"#\"\u003e{{text}}\u003c/a\u003e\u003c/li\u003e',\n            ]); ?\u003e\n            \u003c?= $this-\u003ePaginator-\u003efirst('\u003ci class=\"fas fa-angles-left\"\u003e\u003c/i\u003e', ['escape' =\u003e false]) ?\u003e\n            \u003c?= $this-\u003ePaginator-\u003eprev('\u003ci class=\"fas fa-chevron-left\"\u003e\u003c/i\u003e', ['escape' =\u003e false]) ?\u003e\n            \u003c?= $this-\u003ePaginator-\u003enumbers(['first' =\u003e 1, 'last' =\u003e 1, 'modulus' =\u003e 3]) ?\u003e\n            \u003c?= $this-\u003ePaginator-\u003enext('\u003ci class=\"fas fa-chevron-right\"\u003e\u003c/i\u003e', ['escape' =\u003e false]) ?\u003e\n            \u003c?= $this-\u003ePaginator-\u003elast('\u003ci class=\"fas fa-angles-right\"\u003e\u003c/i\u003e', ['escape' =\u003e false]) ?\u003e\n        \u003c/ul\u003e\n    \u003c/nav\u003e\n\u003c?php $this-\u003eend(); ?\u003e\n\n\u003c?= $this-\u003efetch('pagination'); ?\u003e\n```\nIn out controller we will check if the request is Htmx and if so then we will only render the `usersTable` [viewBlock](https://book.cakephp.org/5/en/views.html#using-view-blocks).\n\n```php\n// src/Controller/UsersController.php\n\npublic function index()\n{\n    $search = null;\n    $query = $this-\u003eUsers-\u003efind('all');\n\n    if ($this-\u003erequest-\u003eis('get')) {\n        if(!empty($this-\u003erequest-\u003egetQueryParams())) {\n            $data = $this-\u003erequest-\u003egetQueryParams();\n\n            if(isset($data['search'])) {\n                $data = $data['search'];\n                $conditions = [\n                    'OR' =\u003e [\n                        'Users.id' =\u003e (int)$data,\n                        'Users.name LIKE' =\u003e '%' . $data . '%',\n                        'Users.email LIKE' =\u003e '%' . $data . '%',\n                    ],\n                ];\n                $query = $query-\u003ewhere([$conditions]);\n                $search = $data;\n            }\n        }\n    }\n\n    $this-\u003epaginate['limit'] = 200;\n    $users = $this-\u003epaginate($query);\n    $this-\u003eset(compact('users', 'search'));\n\n    if($this-\u003egetRequest()-\u003eis('htmx')) {\n        $this-\u003eviewBuilder()-\u003edisableAutoLayout();\n\n        // render users table and pagination blocks\n        $this-\u003eHtmx-\u003eaddBlock('usersTable')-\u003eaddBlock('pagination');\n    }\n}\n```\n\n## License\n\nLicensed under [The MIT License][mit].\n\n[cakephp]:http://cakephp.org\n[composer]:http://getcomposer.org\n[mit]:LICENSE.md\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzunnu%2Fcake-htmx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzunnu%2Fcake-htmx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzunnu%2Fcake-htmx/lists"}