---
title: "PHP on the frontend! No more Javascript!"
url: "https://aaronfrancis.com/videos/php-on-the-frontend-no-more-javascript"
path: "/videos/php-on-the-frontend-no-more-javascript"
type: video
author: Aaron Francis
published: 2023-07-07
topic: "Laravel & PHP"
keywords: [livewire, php frontend, laravel, javascript alternatives, reactive components, alpine.js, component state, file uploads, nested components, livewire v3, larajobs]
youtube_url: "https://www.youtube.com/watch?v=VJlpDlxPZ0k"
site_index: "/llms.txt"
keyword_index: "/llms/keywords.txt"
---

# PHP on the frontend! No more Javascript!

## Transcript

**Aaron Francis:** Have you ever had a thought in a moment of deep and quiet reflection? Have you ever thought to yourself, "I wish I could write more PHP?" Same. I've had the same thought. We've been writing PHP on the back end since the dawn of time, but now we get to write PHP on the front end too. There's no more View, there's no more React, there's no more third JavaScript framework.

**Aaron Francis:** There's only PHP. PHP on the back end, PHP on the front end, PHP in the past, PHP in the future. It was as if a million voices cried out, but not in terror, in excitement. We love PHP. What I'm talking about is Laravel Livewire. Livewire allows you to write PHP on the front end.

**Aaron Francis:** Are you actually running PHP in the browser? No. Are you actually running JavaScript in the browser? You bet you are. This is very similar to Phoenix LiveView, or if you're in the Rails ecosystem, it's very similar to Hotwire, or I think it's very similar to React server components. But what do I know about React? Not very much.

**Aaron Francis:** What Live- what Livewire does is it allows you to write your full stack in PHP, and then it manages that network chasm for you. This is what Remix is supposed to do. It's supposed to s- to span that network chasm. So we're not worried about writing controllers, we're not worried about writing API endpoints, we're not worried about sending JSON over the wire.

**Aaron Francis:** We're just writing our, our regular views, and Livewire is gonna bring all of that together for us. Enough of me talking about it. Let me show you how it works. All right, here we go. We're gonna create a Livewire project from scratch from the very beginning, so you can see exactly what we're doing. First thing we're gonna do is we're gonna use Composer to create a new Laravel project called Livewire.

**Aaron Francis:** So we're creating a new Laravel project in a directory called Livewire. It's gonna install a bunch of stuff. So now all of the Laravel packages are in there. We're gonna change into the Livewire directory, and we're gonna say, "Require Livewire Livewire." So this is going to bring down the Livewire package, and now we are good to go.

**Aaron Francis:** I'm gonna open this in the browser just to make sure it is there. At Livewire.wip, we have the standard Laravel start screen, and if you're paying attention, we've got the docs open next to it. Okay, now we're gonna jump over to PhpStorm and start actually doing some Livewire. So far, this is a standard Laravel application. We haven't done anything special. What we're gonna do is we're gonna come in here into this welcome.blade, and we're gonna replace the entire thing with this, uh, default boilerplate here.

**Aaron Francis:** What we're doing is we're including the Livewire-provided styles at the top and the Livewire-provided scripts at the bottom, and we'll say, "Hey, YouTube." We'll put that in and refresh here. Great. Now we're at, "Hey, YouTube." Let's start binding some stuff up together. Let's start making Livewire do its thing. One of the core tenets of Livewire is components.

**Aaron Francis:** Because it's a front-end framework, it has components, just like every other front-end framework, right? It allows you to encapsulate a bit of view, a bit of state, some logic, some actions, all of that into one logical unit. The way that we can make these is by using the command line helper. So we'll say PHP Artisan, and then let's just take a look at what's in the Livewire namespace.

**Aaron Francis:** It looks like we've got Livewire Make down here, and we can create a new Livewire component. So let's do Livewire Make. Let's clear this out. We'll do Livewire Make, and we'll just say, "Hello, world." And it looks like we were created, there was a class created for us and a view created for us. Let's go take a look at both of those.

**Aaron Francis:** You see that there's a new directory here called Livewire, and here is the view that was created. So we'll say, "Hello from inside Hello World." Now, if we refresh, you'll see nothing changes. We haven't actually put that component on the page. If we come back to this welcome view, we can drop out this, "Hey, YouTube," and what we're gonna put is we're gonna put Livewire, and then the name of the component that we just created, which is Hello World, and we'll just do a self-closing tag there.

**Aaron Francis:** And if we refresh in the browser, we'll see, "Hello from inside Hello World." So we have a component, but it's basically just a view. That doesn't seem very interesting. I agree, that's not very interesting. What we want to see is we want to see this. We wanna see Hello World, the actual PHP component, because now we can start doing stuff like, let's say, let's put a name of Aaron in here.

**Aaron Francis:** And if we come back to the view, we can say, "Hello," let's just say, "Hello, name." And if we refresh that, okay. Huh, that's interesting. Now we're passing down data from this PHP class into this view, and we're rendering it on the page. That's a better start. So far, we've just been displaying data.

**Aaron Francis:** Well, let's start actually modifying some data. We're gonna say input type equals text, and we're gonna bind this input. We're gonna bind it to the name variable, and the way that we can do that is we can just say wire model equals name. This will be very familiar to you if you're coming from the Vue.js world, where you could say v-model.

**Aaron Francis:** It's the exact same thing. So this binds the input to the name variable in this component. So now, if we were to go back to the browser, refresh. Let me blow this up for you. So if we were to go back to the browser, refresh, and look at that. So now, "Hello, friends." Now, we have bound an input to a PHP variable that lives on the server that's being rendered in the view, but

**Aaron Francis:** we didn't write any JavaScript, right? So, oh, wow, that's pretty cool. How is this actually working? Well- One way that it's not working is there's no, there's no WebSocket running. There's no connection that we're keeping open. It's all just pure HTTP. So that's a good thing. You don't have to have a long-running process for this to work.

**Aaron Francis:** That kind of breaks the spirit of PHP anyway. PHP creates the world and destroys the world all on one request, which is either its great strength or its great weakness, depending on your point of view. But there's no WebSocket to keep running. It actually is all just HTTP. Let's open the Network tab so we can see a little bit about what's going on here. So if we open this up, we'll switch over to the Network tab, and we'll change this to Hello Aaron, and then just for giggles, we'll change it back to Hello YouTube.

**Aaron Francis:** If we look at the Network tab, we see that there are a lot of events that were fired off. So this first one, you'll see that the, the event that was fired off was a sync input with a value of A. So this is Livewire, the front end, telling Livewire, the back end, "Hey, we need to change the name property, and we need to set it to A." Now, remember, there's no long-running connection here.

**Aaron Francis:** So all of this data has been serialized on the front end for this component and then sent back to the back end to be rehydrated and then have the updates applied. And that's why we have this fingerprint here, so we can make sure that nothing was tampered with on the front end, right? So Livewire sends out the data with a fingerprint, and then Livewire, the front end, will send that data back with the fingerprint to make sure that nobody went in and changed anything in, in the front end itself, right?

**Aaron Francis:** So if we keep going, we'll see that now the name, the value over here, value over here is Aaron, the value over here is You, then UT, then YouTube. So this is, as I'm typing, it's firing off events. By default, there is a debounce applied to make sure that you don't just totally spam your server with messages. You can change that.

**Aaron Francis:** You can change that, um, debounce amount. You can also set it to defer. So if you're typing something in and you don't actually wanna fire it off until somebody clicks a button, you can set it to defer, and that will batch up that request with another request and send them both off at the same time. Very cool. Now, this is good to know what is being sent, but what is being sent back from the server?

**Aaron Francis:** So what is being sent back from the server is in this effects, you'll see HTML. It's actually sending back HTML over the wire. So this is why it's like LiveView or Hotwire or I don't know what React server components is. Um, but you'll see here it sends back Hello YouTube. So it sends back the rendered version of this component with the new data, and then it intelligently walks the tree of the DOM and swaps out anything that has changed.

**Aaron Francis:** So that's why it's like writing PHP on the front end. But really, it's sending the data over the wire. It's executing on the back end. It's rendering that component, that view on the back end with the new data, sending that HTML back over the wire along with that new serialized data and that new fingerprint. That's data binding. Let's look at calling methods on the back end from the front end.

**Aaron Francis:** I always love this because there is no controller that you have to write. There's no controller you have to write. There's no API route that you have to write. You just have your component, and your component is fully encapsulated. We're gonna change some stuff here. Let's go back to Hello World. Let's do, um, instead of public name, let's do public count equals zero.

**Aaron Francis:** We will switch back to the view. Um, we will say that the count is the count. And then we will, instead of having that, we'll do button type button, and we'll say increment. And what we're gonna put on here is we're gonna put an attribute called, you probably guessed it, wire click.

**Aaron Francis:** Now, what are we gonna use as the actual action here? Let's just call it increment. Now, this is not a JavaScript method. This is a PHP method. So even though we're writing wire click on the front end, we need to implement the increment function on the back end. So we're gonna go back to Hello World. We'll come in here, and we'll say public function increment.

**Aaron Francis:** And we will-- We don't even have to return anything. We'll just say this count plus plus. That should be good enough, right? Let's check it in the browser. Close out that. Come over here and look at that. We are now incrementing a counter on the back end that is actually on the front end. It's showing up on the front end, but it's being sent over the wire. So let's open up the Network tab and watch a few of those, and it'll be basically exactly what you expect.

**Aaron Francis:** So if we check in the server memo of the payload, we'll check in the updates, call method, and the method is increment. So Livewire, the front end, is sending this over the wire to Livewire, the back end, telling Livewire, the back end, what to do, and then it sends back out the new HTML, and it will increment the value on the back end.

**Aaron Francis:** This is an incredibly quick overview of just, like, the first two percent of Livewire. Livewire is incredibly feature robust. So we looked at, uh, data binding and actions. That's kind of table stakes. You would kind of expect that. There's also an inventing system, nested components. Um, there's also file uploads already built in.

**Aaron Francis:** So if you're worried about, um, how do I upload a file with this non-JavaScript framework, it's done. Y- y- you don't, you don't have to do anything. They already handled it for you. It also has, um, built-in support for redirects and pagination and query strings and all sorts of stuff that you would expect out of a JavaScript framework, but you don't have to write any JavaScript.

**Aaron Francis:** Now, there are some things that you shouldn't send a network, network request for. I know that. Livewire knows that. The same person that wrote Livewire, Caleb Porzio, also wrote a package or, or a framework, a JavaScript framework, called Alpine.js. So what Alpine.js is, is it is a very, very lightweight way to do basically on-page stuff, like you're trying to, um, open a, a dropdown or show a modal or something

**Aaron Francis:** like that. So Livewire and Alpine pair really, really nicely together, and honestly, they're, they're meant to be used together. So the dream of writing exactly zero JavaScript may be out of reach, but you can have your entire stack be PHP with just sprinkling in just a little bit of Alpine, and it's nice because the two are meant to work together.

**Aaron Francis:** There are sections in the Livewire docs talking about how you can, um, integrate with Alpine and keep that state in sync between, uh, Laravel Livewire and Alpine.js. It's very well thought through. Livewire has been around for years. It predates Rails' Hotwire, and it predates React server components by a long time.

**Aaron Francis:** It was inspired by Phoenix Live View, um, and it is currently-- Livewire is currently on major version number two. There are a ton of production apps written on Livewire, and major version number three is coming sometime in the summer of 2023. And from what I've seen publicly on Twitter and on GitHub, it somehow brings even more, um, developer experience, thoughtfulness, performance, and productivity boosts.

**Aaron Francis:** So major version number three is going to be even more amazing than version number two somehow. So if you love PHP, and let's be honest, who doesn't love PHP? I think everyone loves PHP. I never see anything online about how people don't like PHP. I never see anything about people saying like, "Oh, you're such an idiot, PHP is dead," or people saying like, "Oh, PHP is so slow.

**Aaron Francis:** Oh, welcome to the nineties." Like, I never see that, so everyone must love PHP. So if you love PHP like I love PHP, like everyone on YouTube loves PHP, and you wanna write more PHP, check out Livewire. It allows you to write PHP on the front end. So please, if you liked this video, leave a comment.

**Aaron Francis:** Um, if you didn't like the video, make sure you hit that dislike button twice so that YouTube knows you really, really disliked it. Until then, stay tuned to this channel for more videos about PHP. See ya.

---

## Related on aaronfrancis.com

- [Biggest Week In Laravel History](/podcast/biggest-week-in-laravel-history-cfbcddfa) *(Podcast · 2026-11-24 · shared: laravel, larajobs)*
- [Oops!...Ian Did It Again](/podcast/oopsian-did-it-again-8cf7ed7d) *(Podcast · 2026-11-17 · shared: larajobs, laravel)*
- [You Can Just Do Things](/about/speaking/you-can-just-do-things-laracon-2025) *(Talk · 2025-07-29 · shared: livewire, php frontend)*
- [Aaron Francis is putting PHP in Your JS Files](/podcast/aaron-francis-is-putting-php-in-your-js-files-6f3117a7) *(Podcast · 2025-03-05 · shared: laravel, livewire)*
- [Robber Baron Mentality](/podcast/robber-baron-mentality-deab4467) *(Podcast · 2025-02-18 · shared: laravel, larajobs)*

## Relevant Resources from Aaron Francis

- **[Solo](https://soloterm.com)** (overview on site: [/software](/software)): All-in-one agentic development platform and terminal workspace built by Aaron Francis for orchestrating processes and AI coding agents.
- **[Screencasting.com](https://screencasting.com)** (overview on site: [/courses](/courses)): Practical video course on recording high-quality technical screencasts, lighting, audio, studio setup, and publishing faster.

## Search aaronfrancis.com (2-Hop Static Keyword Index)

Pick the alphabetical shard matching any topic to find exact pages across all articles, newsletters, videos, talks, and podcast transcripts (every shard is < 40 KB):
[A-B](/llms/keywords/a-b.txt) · [C](/llms/keywords/c.txt) · [D-E](/llms/keywords/d-e.txt) · [F-G](/llms/keywords/f-g.txt) · [H-J](/llms/keywords/h-j.txt) · [K-L](/llms/keywords/k-l.txt) · [M-N](/llms/keywords/m-n.txt) · [O-P](/llms/keywords/o-p.txt) · [Q-R](/llms/keywords/q-r.txt) · [S](/llms/keywords/s.txt) · [T-Z](/llms/keywords/t-z.txt) · [Directory](/llms/keywords.txt) · [Site Map](/llms.txt)

Shards for this page's topics: `livewire` ([K-L](/llms/keywords/k-l.txt)), `php frontend` ([O-P](/llms/keywords/o-p.txt)), `javascript alternatives` ([H-J](/llms/keywords/h-j.txt)), `reactive components` ([Q-R](/llms/keywords/q-r.txt)).

## About Aaron Francis (Current Context)

Aaron Francis is VP of Marketing and Community at [Laravel](https://laravel.com), founder of [Try Hard Studios](https://tryhardstudios.com), creator of [Solo](https://soloterm.com), co-host of [Mostly Technical](/podcast), and author of [Mastering Postgres](/courses), [High Performance SQLite](/courses), [MySQL for Developers](/courses), and [Screencasting.com](/courses). Full bio: [/about](/about) · Current focus: [/now](/now).
