定制 netflie/componentes 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

netflie/componentes

Composer 安装命令:

composer require netflie/componentes

包简介

A PHP compiler to create HTML custom elements

README 文档

README

GitHub Workflow Status Quality Score

This PHP package provides a server-side compiler to render custom HTML components. This package is inspired by the BladeX package for Laravel. From the new 1.0.0 version this package uses the Laravel Blade Compiler. You can now use all the functionalities (non-anonymous components are not supported yet) provided by Laravel Blade Components.

You can write this:

<my-alert type="error" message="I'm an Alert" />

And the output will be:

<div class="alert error">I'm an alert</div>

You can place the content of that alert in a simple Blade view that needs to be registered before using the my-alert component:

<div class="alert {{ $type }}">
  {{ $message }}
</div>

Installation

composer require netflie/componentes

Usage

Setup

Before writting your first component you have to setup the view filesystem, the place where you component templates will be stored:

<?php declare(strict_types=1);

namespace Foo\Bar;

use Netflie\Componentes\Componentes;

$viewPath = realpath(__DIR__ . '/views'); // your project views folder

$componentes = Componentes::create($viewPath);

Writing your first component

Write the content of you component in a Blade template and store it in your project view components folder:

{{-- your_project/views/components/alert.blade.php --}}

<div class="alert {{ $type }}">
  {{ $message }}
</div>

All anonymous components are automatically discovered within the your_project/views/components directory.

And now you can use your custom HTML elements in your views:

<h1>My view</h1>

<x-alert type="error" message="I'm an Alert" />

Compiling

You need compile the HTML to render the HTML elements registered. This HTML code can come already precompilated by a framework or be read directly from an html file:

<?php

namespace Foo\Bar;
$input_html = '<html>'
               .'My webpage code precompiled by my own framework'
               .'<x-alert/>'
            .'</html>';
$ouput_html = $componentes->render($input_html);

More documentation

Check the Laravel Blade Components documentation to full functionalities.

Testing

composer test

In progress

  • Class based component

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-01-29

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固