承接 cyberwolf888/html 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

cyberwolf888/html

最新稳定版本:8.0.0

Composer 安装命令:

composer require cyberwolf888/html

包简介

HTML and Form Builders for the Laravel Framework

README 文档

README

HTML and Form Builders for the Laravel Framework — a maintained fork of LaravelCollective/html.

Latest Stable Version Total Downloads License PHP Laravel

✨ Features

  • 🏗️ Form Builder — open/close forms, model binding, CSRF tokens, and all input types
  • 🔗 HTML Builder — generate links, scripts, styles, lists, images, meta tags, and more
  • Macro & Component support — extend both builders with your own methods
  • 🔄 Laravel auto-discovery — no manual provider/alias registration needed
  • 🧪 Laravel 6–12 compatible with PHP 8.2+

📦 Installation

composer require cyberwolf888/html

Laravel's auto-discovery will register the service provider and facades automatically.

If you prefer manual registration, add to config/app.php:

'providers' => [
    Collective\Html\HtmlServiceProvider::class,
],

'aliases' => [
    'Form' => Collective\Html\FormFacade::class,
    'Html' => Collective\Html\HtmlFacade::class,
],

🚀 Usage

Form Builder

{{-- Open a form --}}
{!! Form::open(['url' => '/login', 'method' => 'POST']) !!}

{{-- Model-bound form --}}
{!! Form::model($user, ['route' => ['users.update', $user->id], 'method' => 'PUT']) !!}

{{-- Common inputs --}}
{!! Form::label('email', 'E-Mail Address') !!}
{!! Form::email('email', null, ['class' => 'form-control', 'placeholder' => 'you@example.com']) !!}

{!! Form::label('password', 'Password') !!}
{!! Form::password('password', ['class' => 'form-control']) !!}

{!! Form::label('role', 'Role') !!}
{!! Form::select('role', ['admin' => 'Admin', 'user' => 'User'], 'user') !!}

{!! Form::checkbox('remember', 1, true) !!} Remember me

{!! Form::submit('Login', ['class' => 'btn btn-primary']) !!}

{!! Form::close() !!}

Available Form Methods

Method Description
Form::open() / Form::close() Open and close a form tag
Form::model($model, $options) Model-bound form
Form::token() CSRF hidden input
Form::label($name, $value) Label element
Form::text/email/password/number/... Standard text inputs
Form::textarea($name) Textarea
Form::select($name, $list) Select dropdown
Form::selectRange/selectYear/selectMonth Range/year/month selects
Form::checkbox/radio Checkbox and radio inputs
Form::file($name) File upload input
Form::submit/button/reset Submit, button and reset
Form::hidden($name, $value) Hidden input
Form::date/time/datetime/... Date/time inputs
Form::color/range/search/tel/url/week Specialized HTML5 inputs
Form::datalist($id, $list) Datalist element

HTML Builder

{{-- Scripts and styles --}}
{!! Html::script('js/app.js') !!}
{!! Html::style('css/app.css') !!}

{{-- Links --}}
{!! Html::link('https://example.com', 'Visit Site', ['class' => 'btn']) !!}
{!! Html::linkRoute('home', 'Home') !!}
{!! Html::mailto('hello@example.com', 'Contact Us') !!}

{{-- Images --}}
{!! Html::image('img/logo.png', 'Logo', ['width' => 100]) !!}
{!! Html::favicon('img/favicon.ico') !!}

{{-- Lists --}}
{!! Html::ul(['Apple', 'Banana', 'Cherry']) !!}
{!! Html::ol(['First', 'Second', 'Third']) !!}

{{-- Meta tags --}}
{!! Html::meta('description', 'My awesome page') !!}

{{-- Arbitrary tag --}}
{!! Html::tag('span', 'Hello', ['class' => 'badge']) !!}

Macros

Extend either builder with custom macros:

// AppServiceProvider::boot()
Form::macro('phone', function ($name, $value = null, $options = []) {
    return Form::tel($name, $value, array_merge(['pattern' => '[0-9]{10,15}'], $options));
});

Html::macro('badge', function ($text, $class = 'primary') {
    return new \Illuminate\Support\HtmlString(
        "<span class=\"badge badge-{$class}\">{$text}</span>"
    );
});

🤝 Contributing

Please read CONTRIBUTING.md before submitting pull requests.

📄 License

This package is open-sourced software licensed under the MIT license.

统计信息

  • 总下载量: 82
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-03-27