krishnapawar/php-html-builder

PHP HTML Builder - A Lightweight Alternative to LaravelCollective/HTML and Spatie/Laravel-HTML With the release of Laravel 11, support for laravelcollective/html has been discontinued, leaving many developers searching for a modern, simple solution to generate HTML and form elements. PHP HTML Builde

v1.0.0 2025-02-18 19:50 UTC

This package is auto-updated.

Last update: 2025-07-18 21:04:04 UTC


README

With the release of Laravel 11, support for laravelcollective/html has been discontinued, leaving many developers searching for a modern, simple solution to generate HTML and form elements. PHP HTML Builder is here to fill that gap — offering a streamlined, intuitive alternative compatible with Laravel 9, 10, and 11.

This package provides an easy-to-use, fluent API that replicates the functionality of laravelcollective/html and spatie/laravel-html, enabling developers to effortlessly create HTML components, forms, inputs, checkboxes, radio buttons, dropdowns, links, images, and more.

Built with simplicity and flexibility in mind, PHP HTML Builder is a lightweight, PHP-first solution for building and managing dynamic user interfaces in Laravel applications.

📌 Features

  • 🏗 Alternative to laravelcollective/html for Laravel 11+
  • ✨ Simple and clean syntax for generating HTML and form elements
  • 📝 Supports forms, inputs, selects, checkboxes, buttons, and modals
  • 🌍 Works in both Laravel and standalone PHP projects
  • 🎨 Fully customizable with attributes

🔧 Installation

composer require krishnapawar/php-html-builder

🚀 Usage Examples

1️⃣ Generating Basic HTML Elements

use KrishnaPawar\HtmlBuilder\Html;

// Link
echo Html::link("https://example.com", "Visit Website", ["target" => "_blank"]);

// Image
echo Html::image("logo.png", "Website Logo");

// Inline CSS
echo Html::style("body { background-color: #f4f4f4; }");

// Inline JavaScript
echo Html::script("console.log('Hello, World!');");

// External CSS
echo Html::stylesheet("https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css");

// External JavaScript
echo Html::scriptSrc("https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js");

2️⃣ Generating Forms and Inputs

use KrishnaPawar\HtmlBuilder\Form;

// Open Form
echo Form::open("submit.php", "POST");

// Input Fields
echo Form::input("name", "text", "", ["placeholder" => "Enter Name"]);
echo Form::input("email", "email", "", ["placeholder" => "Enter Email"]);

// Select Dropdown
echo Form::select("role", ["admin" => "Admin", "user" => "User"], "user");

// Checkbox
echo Form::checkbox("subscribe", "yes", true);

// Submit Button
echo Form::submit("Send");

// Close Form
echo Form::close();

3️⃣ Creating a Modal

use KrishnaPawar\HtmlBuilder\Form;

// Modal Example
echo Form::modal(
    "myModal",
    "My Modal Title",
    "<p>This is a simple modal body.</p>",
    "<button class='btn btn-primary'>Save Changes</button>"
);

Output HTML:

<div id='myModal' class='modal'>
    <div class='modal-dialog'>
        <div class='modal-content'>
            <div class='modal-header'>
                <h5 class='modal-title'>My Modal Title</h5>
                <button type='button' class='close' data-dismiss='modal'>&times;</button>
            </div>
            <div class='modal-body'>
                <p>This is a simple modal body.</p>
            </div>
            <div class='modal-footer'>
                <button class='btn btn-primary'>Save Changes</button>
            </div>
        </div>
    </div>
</div>

📜 License

This package is open-source and available under the MIT License.

🤝 Contributing

Feel free to submit issues, feature requests, or contribute to improving this package!

🏷 Tags

Laravel, HTML Builder, PHP Forms, HTML Generator, LaravelCollective Alternative, Web Development, PHP Package, kp, krishnapawar,krishna pawar,Alternative,