Download the PHP package yuga/livecomponent without Composer

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

Yuga Live Components

Yuga Live Components (YLC) adds server-rendered, reactive components to the Yuga Framework. Component state stays on the server and is synchronized in the browser through the Yuga JavaScript runtime.

Requirements

Installation

Install the package with Composer:

YlcProvider is registered through Composer package discovery. It adds the Live Component endpoints and discovers components configured by the application.

Publish or copy the browser plugin into the application's public assets using the Yuga publishing mechanism and the ylc-assets tag. The package asset is public/plugins/ylc-live-plugin.js.

Register YLCPlugin with the Yuga JavaScript runtime after loading the runtime and the published plugin. Use the normal Yuga plugin registration API used by the application:

The plugin communicates with these routes, which are registered automatically by YlcProvider:

Method Route Purpose
POST /ylc/message Component updates and actions
POST /ylc/lazy Lazy component loading
GET /ylc/stream Stream refresh notifications
POST /ylc/upload Temporary file uploads
GET /ylc/temp-upload/{token} Temporary upload preview

Configuration

Add a ylc configuration entry to the Yuga application's configuration. Each discovery source needs a filesystem path and the namespace used by the PHP classes:

Components are named from their class path. For example, App\Live\Shopping\Cart becomes shopping.cart. Set #[Live(name: 'cart')] to choose an explicit name.

Creating a component

Create a class that extends Yuga\Live\Component:

Public properties are included in the component snapshot and can be bound from the browser. Public methods can be invoked with ylc:click.

To disable discovery for a class, use #[Live(discover: false)]. Discovery options can also be set on the attribute:

Mounting a component

Mount a component from a Yuga view with the ylc helper:

Pass parameters to mount() and per-instance options as the second and third arguments:

The component receives mount parameters in mount():

Bindings and actions

Use ylc:model for state bindings and ylc:click for actions:

Supported model values include text inputs, checkboxes, radios, multiple selects, numeric inputs, ranges, and file inputs. Model updates are sent to the server automatically.

Loading state can also be reflected in attributes:

Action parameters use JavaScript expressions inside the attribute, for example remove(42, 'archive').

Forms and validation

Typed public properties extending Form are initialized automatically. Define the form fields and validation rules in a form class:

Use it on a component and bind nested fields with dot notation:

URL state

Mark a public property with #[Url] to synchronize it with the query string:

Array properties are JSON-encoded in the query string. URL-backed state is restored on the initial request and when the browser history changes.

Computed and locked properties

Computed properties are exposed through a get<Name>Property() method:

Use #[Computed(cache: false)] when the value must be recalculated each time it is read. Use #[Locked] on a public property when browser updates must not change it.

JavaScript API

The plugin exposes components through window.YLC:

Other helpers include YLC.find(id), YLC.all(), and component.refresh().

Register named JavaScript actions from application code:

Then queue one from a component with $this->js('notify', ['message' => 'Saved']);.

Component lifecycle

Components may define these hooks:

Use stream: true for server-sent refresh notifications or poll: true for periodic refreshes. The client falls back to polling after repeated stream failures when fallback is enabled.

License

Yuga Live Components is open-sourced under the MIT license.


All versions of livecomponent with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2 || ^8.3 || ^8.4
yuga/framework Version ^5.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 yuga/livecomponent contains the following files

Loading the files please wait ...