A component-centric backend communication layer for Alpine.js

Overview

Package banner

Tests passing Laravel v8.x Alpine.js v2.x PHP 8.0

A component-centric backend communication layer for Alpine.js.

Installation

Install using the following command:

composer require radio/radio

Install the @radioScripts into your Blade template, along with Alpine.js:

<html>
    <head>
        ...
        
        <script src="https://cdn.jsdelivr.net/gh/alpinejs/[email protected]/dist/alpine.min.js" defer></script>
    </head>
    
    <body>
        ...
    
        @radioScripts
    </body>
</html>

Usage

  1. Create a new component class, and apply the Radio\Radio trait. The class may be located anywhere in your codebase, we recommend App\Http\Components:
<?php

namespace App\Http\Components;

use Radio\Radio;

class MyComponent
{
    use Radio;
    
    // ...
}
  1. Use the @radio Blade directive to connect your Alpine.js component to your Radio PHP class:
<div x-data="@radio(App\Http\Components\MyComponent::class)">
    ...
</div>
  1. Use your PHP class with Alpine.js!

    • Interact with public methods and properties:

      public $name = '';
      
      public function saveName()
      {
          auth()->user()->update([
              'name' => $this->name,
          ]);
      
          return $this->name;
      }
      <input x-model="name" type="text" />
      
      <button @click="await saveName()">Save name</button>
    • Dispatch browser events:

      use Radio\Concerns\WithEvents;
      
      public function closeUser($userId)
      {
          $this->dispatchEvent('closeUser', [
              'id' => $userId,
          ]);
      }
    • Render validation errors:

      <template x-if="$radio.errors.has('name')">
          <p x-text="$radio.errors.get('name')[0]"></p>
      </template>
    • Interact with PHP object properties:

      // `Collection`s and `EloquentCollection`s are automatically cast using property type hinting. Note: objects within a collection are not cast with it.
      public Collection $users;
      
      // ...as well as `Stringable` objects.
      public Stringable $slug;
      
      // Implement the `Radio\Contracts\Castable` interface on any object for custom DTO support using `fromRadio()` and `toRadio` for hydration and dehydration.
      public CustomObject $dto;
    • Define computed properties:

      #[Computed('getWelcomeMessage')]
      public $welcomeMessage;
      
      public function getWelcomeMessage()
      {
          $name = auth()->user()->name;
      
          return "Welcome {$name}!";
      }

Need Help?

🐞 If you spot a bug with this package, please submit a detailed issue, and wait for assistance.

🤔 If you have a question or feature request, please start a new discussion.

🔐 If you discover a vulnerability within the package, please review our security policy.

You might also like...
This website built for practice using HTML,CSS , Js and PHP - MySQL for backend
This website built for practice using HTML,CSS , Js and PHP - MySQL for backend

SammysBarbeque This website built for practice using HTML,CSS , Js and PHP - MySQL for backend Features added in the website: User:- Authentic and att

Examination tasks to test backend knowledge (for junior level)
Examination tasks to test backend knowledge (for junior level)

Task 1 The website of one of our old clients was hacked. After hacking, a strange red bar appeared on the site at the bottom of the page (https://imgu

¡BACKEND OVER APP! API REST IMPLEMENTANDO CONCEPTOS DE ARQUITECTURA HEXAGONAL, DDD, TDD Y SOLID. HECHO EN LARAVEL & PHP
¡BACKEND OVER APP! API REST IMPLEMENTANDO CONCEPTOS DE ARQUITECTURA HEXAGONAL, DDD, TDD Y SOLID. HECHO EN LARAVEL & PHP

¡BACKEND OVER APP! API REST IMPLEMENTANDO CONCEPTOS DE ARQUITECTURA HEXAGONAL, DDD, TDD Y SOLID. HECHO EN LARAVEL & PHP

This is a Reddit-like clone named Scroller, made for the project component of COSC 360 - Web Programming.

The COSC 360 Project Due Dates: See Milestone Dates Overview: The project is designed to help develop your skills for full stack development. With thi

A dynamic Laravel Livewire component for tab forms
A dynamic Laravel Livewire component for tab forms

Livewire component that provides you with a tabs that supports multiple tabs form while maintaining state.

Livewire component to show records according to their current status
Livewire component to show records according to their current status

Livewire Status Board Livewire component to show records/data according to their current status Preview Installation You can install the package via c

Pimcore Bundle that enbable pimcore to expose webook for communication to third parties
Pimcore Bundle that enbable pimcore to expose webook for communication to third parties

WebHookBundle Plugin This extention provide an easy way to send dataobjects to an external sites via json, whenever a pimcore event occurs on a specif

Pretty Good Privacy (PGP) is an encryption program that provides cryptographic privacy and authentication for data communication.

Pretty Good Privacy (PGP) is an encryption program that provides cryptographic privacy and authentication for data communication. PGP is used for signing, encrypting, and decrypting texts, e-mails, files, directories, and whole disk partitions and to increase the security of e-mail communications. Phil Zimmermann developed PGP in 1991.

A WordPress plugin for managing user permission, education, and communication.

A WordPress plugin for managing user permission, education, and communication. Texas A&M University System

An online communication application that provides a real-time or live transmission of text messages from sender to receiver.

Realtime-chat-application An online communication application that provides a real-time or live transmission of text messages from sender to receiver.

Friendica is a decentralised communications platform that integrates social communication
Friendica is a decentralised communications platform that integrates social communication

Friendica is a decentralised communications platform that integrates social communication. Our platform links to independent social projects and corporate services.

API abstracting communication with SQL providers (eg: MySQL) on top of PDO inspired by Java JDBC

SQL Data Access API Table of contents: About Configuration Execution Installation Unit Tests Examples Reference Guide About This API is a ultra light

The HttpFoundation component defines an object-oriented layer for the HTTP specification.

HttpFoundation Component The HttpFoundation component defines an object-oriented layer for the HTTP specification. Resources Documentation Contributin

A lightweight full-stack component layer that doesn't dictate your front-end framework

Airwire A lightweight full-stack component layer that doesn't dictate your front-end framework Demo Introduction Airwire is a thin layer between your

👨🏻‍🚀 A command-line tool that gives you the Alpine Day 2021 schedule in your timezone. 🚀
👨🏻‍🚀 A command-line tool that gives you the Alpine Day 2021 schedule in your timezone. 🚀

Alpine Day Schedule a command-line tool that gives you the Alpine Day 2021 schedule in your timezone. 🚀 Quick start Requires PHP 7.4+ # First, instal

A magic PHP framework. Build reactive web apps without writing HTML, CSS, or JavaScript! Powered by Tailwind, Alpine, Laravel, & Livewire.
A magic PHP framework. Build reactive web apps without writing HTML, CSS, or JavaScript! Powered by Tailwind, Alpine, Laravel, & Livewire.

Malzahar A magic PHP framework. Build reactive web apps without writing HTML, CSS, or JavaScript! Powered by Tailwind, Alpine, Laravel, & Livewire. Re

The slides and demo files for my Alpine Day 2021 talk

Building a Better Dialog Austen Cameron - @austencam This repository contains the slides and demos for my talk from Alpine Day 2021. Below, you'll fin

A TALL (Tailwind CSS, Alpine.js, Laravel and Livewire) Preset for Laravel
A TALL (Tailwind CSS, Alpine.js, Laravel and Livewire) Preset for Laravel

Laravel TALL Preset A front-end preset for Laravel to scaffold an application using the TALL stack, jumpstarting your application's development. If yo

Releases(v0.1.1)
Owner
Radio.js
A component-centric backend communication layer for Alpine.js.
Radio.js
Workout application with fully functional Frontend and Backend.

Fit_Me_Application About Application: This FIT-ME management system is an easy way to use gym and health membership system. It can help to keep the re

Talha 3 Feb 20, 2022
A simple, beautiful, mobile-first instant messaging web application backend build with ThinkPHP6 and Swoole.

OnChat A simple, beautiful, mobile-first instant messaging progressive web application build with ThinkPHP6 and Swoole. You can click here to view the

HyperLifelll9 138 Dec 26, 2022
Backend of the Articly wiki/cms project

Documentation | Changelog | Roadmap Currently under heavy development & testing. Fast, easy and reliable wiki software running in the web. What is Art

null 4 Feb 14, 2022
Official backend for VideoStream Android app.

About VideoStream Backend Official backend for VideoStream Android app, which is the CMS for VideoStream Android app. This backend is public for testi

Jesse Keskelä 1 Jan 30, 2022
Backend for honkCDN.

ServerGoose - the backend for honkCDN Written in PHP. Some parts of the code were not included for security reasons. Some parts of the code were locat

honkdev 1 Oct 29, 2021
Blog dengan framework laravel 8 sebagai backend dan tailwind sebagai frontend

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Muh Nur Afrizal 2 Dec 24, 2021
Backend to apuntate in globalEmergency.online

APÚNTATE - Global Emergency Resumen Apúntate es una aplicación enfocada en la gestión de los diferentes servicios disponibles dentro de una agrupación

Global Emergency 4 Nov 19, 2022
Esta es la plicacion de digital-solutions backend de laravel

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

null 0 Dec 25, 2021
DBase - An easy-to-use backend for mobile and web applications

DBase DBase is an easy-to-use backend for your mobile and web applications, host the files in an Ubuntu server and use the SDKs to perform CRUD operat

Frank Eno ~ XSGames 39 May 25, 2022
Sistema web para la administracion de una clinica veterinaria, Frontend y Backend

Clinica-Veterinaria-Web Se desea desarrollar un sistema Web para la administración de una clínica veterinaria. Se desea recolectar información sobre l

ErickBuster 1 Jan 15, 2022