Download the PHP package xlited/lamx without Composer

On this page you can find all versions of the php package xlited/lamx. 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 lamx

Lamx - Build Laravel apps with htmx

Latest Version on Packagist Total Downloads GitHub Actions

Lamx brings Livewire-style components to htmx. A component is a single PHP class that holds its state (public properties), its actions (public methods) and its validation rules, plus a Blade view in which $this is available. htmx does the transport: every request made from inside a component carries a signed snapshot of its state, the action runs against the re-hydrated component and the returned HTML is swapped into the page.

Requires PHP 8.1+, Laravel 10–13 and htmx 4.

Installation

Load htmx and the Lamx helpers in your layout:

Optionally publish the config: php artisan vendor:publish --tag=lamx-config.

A component

Use it like any Blade component (<x-todo :id="1" title="Milk" />), build it in PHP (Todo::make(['id' => 1, 'title' => 'Milk'])) or return it from a route or controller — it is Responsable, Htmlable and Stringable.

State

The public properties are the state. When the component renders, a signed snapshot of them is attached to the root element as hx-vals:inherited, so htmx sends it with every request made from inside the component and the action runs on an identical instance. Scalars, arrays, enums, dates, collections and Eloquent models (stored by key, re-fetched on the next request) are supported; anything else is left out and re-created by the constructor.

Actions

$this->action('name') (or Todo::actionUrl('name')) returns the URL of the action: /lamx/{component}/{action}. Component names follow Blade's <x-name> rules — classes under App\View\Components, Blade::component() aliases and Blade::componentNamespace() prefixes.

Action arguments are resolved by name from the request input (scalar parameters) and from the container (class-typed parameters), so public function add(int $amount, Request $request) just works. Extra parameters given to $this->action('add', ['amount' => 5]) become a query string.

An action may return:

return response
nothing the component, re-rendered
a component, view, Htmlable, string rendered as is
an array of those rendered one after another (use hx-swap-oob)
redirect(...) HX-Redirect header (a plain redirect otherwise)
any response as is

Only public methods declared by your component are callable; the framework's own methods (render, validate, toHtml...) are not.

Validation

$this->validate() validates the request input against rules() (also messages(), validationAttributes(), or pass them explicitly). When it fails, the component is re-rendered with $errors available in the view and old() filled with the submitted input — a classic Laravel form, without the redirect. Form requests injected into actions behave the same way; Xlited\Lamx\Requests\HtmxRequest does it for plain controllers too.

Pages

A component used as a route action is rendered inside a layout: @extends layouts with a @yield('content') section and component layouts (<x-layouts.app> with a $slot) are both supported and detected automatically. Configure the default in config/lamx.php or per component with protected string $layout and layoutParams().

Views

$view defaults to components.<component-name>; set protected string $view or override render() (a view, an Htmlable, an inline Blade string or a closure) for full control. Inside the view $this is the component, and public properties are also available as plain variables, as in any Blade component.

The demo

A complete Todo app built with Lamx: https://github.com/icaliman/laravel-htmx

Testing

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of lamx with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/support Version ^11.0|^10.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 xlited/lamx contains the following files

Loading the files please wait ...