teepluss / component
组件用于从主视图中分离小部分,同时仍然可以完美工作。
1.0.1
2015-07-28 05:00 UTC
Requires
- php: >=5.4.0
- illuminate/support: >=5.0.1
This package is not auto-updated.
Last update: 2024-09-14 17:42:43 UTC
README
组件用于从主视图中分离小部分,同时仍然可以完美工作。
安装
Composer
要获取主题的最新版本,只需在您的 composer.json
文件中引入它。
"teepluss/component": "dev-master"
然后您需要运行 composer update
来下载它,并更新自动加载器。
Laravel
在您的 config/app.php
文件中,将 'Teepluss\Component\ComponentServiceProvider'
添加到 providers
数组的末尾
'providers' => [ ... 'Teepluss\Component\ComponentServiceProvider', ]
发布配置
php artisan vendor:publish --provider="Teepluss\Component\ComponentServiceProvider"
用法
创建组件
使用 artisan CLI 创建组件,然后您可以在 app/Components
中找到您的组件。
php artisan component:make LiveChatBox
命令将生成如下结构
root |- app |--- Components |----- LiveChatbox |------- assets |--------- css |------------ style.css |--------- img |--------- js |------------ script.js |------- lang |--------- en |------------ messages.php |------- views |--------- index.blade.php |------- LiveChatbox.php |----- gulp.js
渲染组件。
{!! component()->uses('LiveChatBox', ['args' => '1'])->render() !!}
与资产一起工作。
安装 gulp
npm install gulp
使用 gulp 发布组件资产。
$ cd app/Components/
$ gulp
$ gulp watch
从主布局渲染所有组件脚本和样式。
// Display component scripts and styles. {!! component()->scripts() !!} {!! component()->styles() !!} // Locate to asset path. {!! component()->uses('LiveChatBox')->asset('img/someimage.png') !!}
翻译
{!! component()->trans('message') !!}
支持或联系
如果您遇到问题,请联系 teepluss@gmail.com