PHP code example of tomrf / htmx-message

1. Go to this page and download the library: Download tomrf/htmx-message library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tomrf / htmx-message example snippets


$request = new HtmxRequest($request);     // PSR-7 `ServerRequestInterface`

if ($request->isHxRequest() && $request->isHxBoosted()) {
    $layout = 'ajax.layout';
}

[...]

$response = new HtmxResponse($response);  // PSR-7 `ResponseInterface`

$response = $response->withHxTrigger('aSimpleTrigger')
    ->withAddedHxTrigger('triggerWithParams', ['arg' => true, 'arg2' => 7])
    ->withTriggerAfterSwap('afterSwap', time())
    ->withHxPush($newUrl);

// Emit $response as normal
[...]

public function getHxPush(): string

public function getHxRedirect(): string

public function getHxRetarget(): string

public function getHxTrigger(): array

@return   array

public function getHxTriggerAfterSettle(): array

@return   array

public function getHxTriggerAfterSwap(): array

@return   array

public function hasHxPush(): bool

public function hasHxRedirect(): bool

public function hasHxRefresh(): bool

public function hasHxRetarget(): bool

public function hasHxTrigger(): bool

public function hasHxTriggerAfterSettle(): bool

public function hasHxTriggerAfterSwap(): bool

public function withAddedHxTrigger(
    string $trigger,
    mixed $argument = null
): static

public function withAddedHxTriggerAfterSettle(
    string $trigger,
    mixed $argument = null
): static

public function withAddedHxTriggerAfterSwap(
    string $trigger,
    mixed $argument = null
): static

public function withHxPush(
    string|bool $url
): static

public function withHxRedirect(
    string $url
): static

public function withHxRefresh(): static

public function withHxRetarget(
    string $selector
): static

public function withHxTrigger(
    string $trigger,
    mixed $argument = null
): static

public function withHxTriggerAfterSettle(
    string $trigger,
    mixed $argument = null
): static

public function withHxTriggerAfterSwap(
    string $trigger,
    mixed $argument = null
): static

public function withoutHxPush(): static

public function withoutHxRedirect(): static

public function withoutHxRefresh(): static

public function withoutHxRetarget(): static

public function withoutHxTrigger(): static

public function withoutHxTriggerAfterSettle(): static

public function withoutHxTriggerAfterSwap(): static

public function getHxCurrentUrl(): string

public function getHxPrompt(): string

public function getHxTarget(): string

public function getHxTrigger(): string

public function getHxTriggerName(): string

public function hasHxPrompt(): bool

public function hasHxTarget(): bool

public function hasHxTrigger(): bool

public function hasHxTriggerName(): bool

public function isHxBoosted(): bool

public function isHxHistoryRestoreRequest(): bool

public function isHxRequest(): bool

public function __construct(
    Psr\Http\Message\ServerRequestInterface $message
): void