Install Aire for Laravel
composer require glhd/airewebsite·Indexed 31 days ago
https://airephp.com/A fluent and expressive PHP library for building forms, featuring built-in client-side validation using Laravel's rule syntax and support for Alpine.js. It includes a variety of form components, theme support for Bootstrap and Tailwind CSS, and a chainable API accessible via the Aire facade or aire() helper.
composer require glhd/aireAire provides built-in support for Alpine.js, allowing developers to add reactive interactions to server-generated forms. By calling the asAlpineComponent() method on an Aire form instance, Aire automatically:
x-data attribute on the <form> tag using the form's existing data binding logic.x-model attributes to each form element to sync them with the Alpine.js state.{{ Aire::route('demo.store')->asAlpineComponent() }}The resourceful() helper automates route names, HTTP methods, and model binding based on a provided model instance. It distinguishes between 'create' (new model) and 'update' (existing model) automatically.
Aire::resourceful($model)Aire::resourceful($model, 'custom_name')Aire::resourceful($model, 'nested.route', [$parentModel])// Update existing user (infers users.update and PUT)
{{ Aire::resourceful(User::find(1)) }}
// Create new user (infers users.store and POST)
{{ Aire::resourceful(new User()) }}
// Nested route: teams.users.update with parameters [$team, $user]
{{ Aire::resourceful($user, 'teams.users', [$team]) }}Aire::input() to create a standard input field. You can chain methods to define the ID, requirement status, input type, placeholder, default value, and help text. The variant() method allows for size adjustments (e.g., lg() for large or sm() for small).Aire::input('input', 'Sample Input')
->id('sample-input-field')
->required()
->type('text')
->placeholder('Placeholder text')
->value('Pre-filled with data')
->helpText('This is a regular input element');
// Large variant
Aire::input()->label('Large input')
->variant()->lg();
// Small variant
Aire::input()->label('Small Input')
->variant()->sm();// Print a simple error count message
{{ Aire::summary() }}
// Print a detailed itemized list of errors
{{ Aire::summary()->verbose() }}data($key, $value) method to add data- attributes. Passing NULL as the value unsets the attribute. If the value is an array or an object implementing Jsonable, JsonSerializable, or Arrayable, Aire automatically JSON-encodes it.{{ Aire::input()->label('Demo Input')->id('demo') }}glhd/aire-bootstrap package via Composer. Once installed, Aire will automatically apply the corresponding Bootstrap classes to its components.composer require glhd/aire-bootstrapAire automatically handles Laravel's security and routing requirements:
GET or POST, Aire automatically adds the _method hidden field. It can infer the method from the route name._token field is automatically injected for non-GET forms if a session is enabled.// In routes
Route::delete('/photos/{photo}', 'PhotosController@destroy')->name('photos.destroy');
// In view: Aire generates <form action="/photos/1" method="POST">
// with <input type="hidden" name="_method" value="DELETE" />
{{ Aire::open()->route('photos.destroy', $photo) }}
{{ Aire::close() }}addClass() and removeClass() methods.Aire elements can be grouped to automatically generate wrapping markup for labels and help text. Grouping is often enabled by default. You can control this behavior using grouped() or withoutGroup(). Grouped elements provide the following methods:
label(string $text): Sets the label text.helpText(string $text): Adds instructions below the element.valid() / invalid(): Manually marks the group's validation state.errors($message): Adds a specific error message below the element.prepend(string $text) / append(string $text): Adds inline text before or after the element.wire:click), use the setAttribute($key, $value) method.