Download the PHP package zunnu/cake-htmx without Composer

On this page you can find all versions of the php package zunnu/cake-htmx. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package cake-htmx

cake-htmx

CakePHP integration for htmx.

Supported CakePHP Versions >= 4.x and 5.x.

Installing Using Composer

cd to the root of your app folder (where the composer.json file is) and run the following command:

Then load the plugin by using CakePHP's console:

To install htmx please browse their documentation

Usage

Main functionality is currently wrapped inside Htmx component. To load the component you will need to modify your src/Controller/AppController.php and load the Htmx component in the initialize() function

Request

You can use detector to check if the request is Htmx.

Using the component you can check more specific details about the request.

Response

Htmx can trigger a client side redirect when it receives a response with the HX-Redirect header.

Htmx will trigger a page reload when it receives a response with the HX-Refresh header. clientRefresh is a custom response that allows you to send such a response. It takes no arguments, since Htmx ignores any content.

When using a polling trigger, 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.

See the documentation for all the remaining available headers.

Additionally, you can trigger client-side events using the addTrigger methods.

If you want to pass details along with the event you can use the second argument to send a body. It supports strings or arrays.

You can call those methods multiple times if you want to trigger multiple events.

CSRF token

To add CSRF token to all your request add below code to your layout.

Rendering blocks and OOB Swap

The 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.

The addBlock() function allows you to add a specific block to the list of blocks that should be rendered.

The addBlocks() function allows you to add multiple blocks to the list of blocks that should be rendered

OOB Swap

Htmx supports updating multiple targets by returning multiple partial responses with hx-swap-oop. See the example Users index search functionality with pagination update Note if you are working with tables like in the example. You might need to add

In your template or layout.

Examples

Users index search functionality

In 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 called usersTable. When the page loads, we will render the usersTable viewBlock.

In out controller we will check if the request is Htmx and if so then we will only render the usersTable viewBlock.

Users index search functionality with pagination update

In 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 called usersTable and our pagination to pagination block. When the page loads, we will render both the usersTable and pagination viewBlock.

In out controller we will check if the request is Htmx and if so then we will only render the usersTable viewBlock.

License

Licensed under The MIT License.


All versions of cake-htmx with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
cakephp/cakephp Version ^4.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package zunnu/cake-htmx contains the following files

Loading the files please wait ....