What is WebForms Core?
WebForms Core is a new web development technology that gives you the power to build modern applications without the need for front-end frameworks like Vue, React, or Angular. It provides native module import, direct JavaScript execution, and DOM event handling, allowing developers to build dynamic, efficient applications by focusing only on server-side coding. WebForms Core is a complete, integrated server-side solution that also covers the client side, eliminating the need for third-party tools.
WebForms Core 2 in PHP
WebForms Core version 2 has been recently released and is now available for PHP, in addition to other languages. The framework allows developers to implement DOM events, data handling, and server-side interactions in a simple and powerful way. In this article, we will explore how to use WebForms Core in PHP with a practical example.
How to use WebForms Core?
Two steps are required:
1- On the client side : Add the WebFormsJS script to your HTML page.
<script type="module" src="/script/web-forms.js"></script>Get the WebFormsJS script from the following link:
https://github.com/webforms-core/Web_forms/blob/elanat_framework/web-forms.js
2- On the server side: Import the WebForms class for your programming language.
Get the WebForms class associated with the server programming language from the following link:
https://github.com/webforms-core/Web_forms_classes
Custom Event in WebForms Core
Custom Events in WebForms Core are a feature that allows you to define specific behaviors and conditions for DOM elements. With this feature, you can dynamically create events such as a field value changing, text or number reaching a certain condition, or even data comparisons, and then connect them to server-side handlers. This approach allows for intelligent and controllable user interactions with the UI, without the need for complex JavaScript or PHP coding.
Getting Started
To get started, simply import the main WebForms file into your project:
include "WebForms.php";
use WebFormsCore\WebForms;
use WebFormsCore\InputPlace;
use WebFormsCore\Fetch;Defining Events and Handlers
In this example, three paths are defined for handling events:
path-of-handling → Check the value entered by the user in the text field
path-of-handling2 → Check the price value and display a message
increase_value → Increase the price value dynamically
Sample Code:
if (isset($_GET["path-of-handling"])) {
nameBox_nameMatched();
return;
}
if (isset($_GET["path-of-handling2"])) {
price_npriceHigh();
return;
}
if (isset($_GET["increase_value"])) {
increase_value();
return;
}Implementing Functions
Each route has a dedicated function that performs the desired operation using the WebForms class:
function nameBox_nameMatched() {
$form = new WebForms();
$form->setBackgroundColor(InputPlace::tag("body"), "lightgreen");
echo $form->response();
exit();
}
function price_npriceHigh() {
$form = new WebForms();
$form->message(Fetch::getText("price"));
echo $form->response();
exit();
}
function increase_value() {
$form = new WebForms();
$form->increase("price", 1);
$form->setCacheNoTime();
echo $form->response();
exit();
}


Join the conversation! Your thoughts help the community grow.