Skip to content

Gargantua is a minimalist PHP form wizard library 🪐.

Notifications You must be signed in to change notification settings

azmanabdlh/Gargantua

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gargantua 🪐

Form wizard can be challenging and may require a higher effort to complete them. Gargantua is a minimalist form wizard library.

demo

Table of Content

Installation

Before you install, it is important to check that your PHP version at least PHP 7.1+.

composer require azmanabdlh/gargantua

Quick Start

Read the example test to get started.

API

Form

use Gargantua\Contract\Session;
use Gargantua\Contract\Page;
use Gargantua\Contract\Request;


public static function provide(
  Page[] $page,
  Session $session,
): Form
// get current page utils.
public function page(): PageUtils
// check form page can be navigate back.
public function canBack(): bool
// check form page is last.
public function last(): bool

Page

Page provide a form page

// provide form page name.
public function pageName(): string
// when form page submitted try to invoke func.
public function onSubmit(Request $request): void
// try to move the next page can invoke func.
public function onNext(array $payload): void
// when it reaches the tail, each form page invoke func.
public function onCompleted(): void
use Gargantua\Contract\CanNavigateBack;

// try back to the prev page can invoke func.
public function onNavigateBack(): void

PageUtils

PageUtils provide Page utilities

// validate page is active.
public function is(string $pageName): bool
// get page label.
public function label(): string
// get page icon.
public function icon(): string


// example
public function icon(): string {
  return "<img .../>"; // or <i icon="user-account"></i>
}
// get current page number.
public function number(): int

Cable

Intercept form page using Cable for each Page submitted.

$form->capture([
  new VerifyJwtToken()
]);


// handle logic.
function handle(Request $request): void

License

Licensed under MIT. Totally free for private or commercial projects, or any other uses.