定制 egorogl/laravel-db-blade 二次开发

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

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

egorogl/laravel-db-blade

Composer 安装命令:

composer require egorogl/laravel-db-blade

包简介

Render Blade templates from Eloquent Model Fields

README 文档

README

Build Status Scrutinizer Code Quality

Render Blade templates from Eloquent Model Fields

This package allows you to render Blade templates from a database model instead of files. It is based on Flynsarmy's laravel-db-blade-compiler.

Installation

You can install the package via composer:

composer require kiroushi/laravel-db-blade

Publish the assets using artisan:

php artisan vendor:publish

And then set up your DbView model in the config/db-blade.php configuration file. A default model (Kiroushi\DbBlade\Models\DbView) is included in the package:

return [

    'model_name' => 'Kiroushi\DbBlade\Models\DbView',
    'table_name' => 'db_views',

    /**
     * The default name field used to look up for the model.
     * e.g. DbView::make($viewName) or dbview($viewName)
     */
    'name_field' => 'name',

    /**
     * The default model field to be compiled when not explicitly specified
     * with DbView::field($fieldName) or DbView::model($modelName, $fieldName)
     */
    'content_field' => 'content',

    /**
     * This property will be added to models being compiled with DbView
     * to keep track of which field in the model is being compiled
     */
    'model_property' => '__db_blade_compiler_content_field',

    'cache' => false,
    'cache_path' => 'app/db-blade/cache/views'

];

After the configuration and ensuring that the migration has been published, you can create the database views table by running the migrations:

php artisan migrate

Usage

This package offers a DbView facade with the exact same syntax and functionality than View:

return DbView::make('home')->with(['foo' => 'bar']);

You can also use the dbview() helper matching Laravel's base view() helper functionality. If no arguments are supplied, the factory is returned:

return dbview()->make('home')->with(['foo' => 'bar']);

If a string is supplied, a view with that name will be looked up for and rendered:

return dbview('home')->with(['foo' => 'bar']);

Overriding settings at runtime

You can override individual settings for the model, name field and content field by using associated methods:

return DbView::make('home')->model('App\Template');

return DbView::make('home')->field('template_name');

// You can also pass the model and name field as a shorthand:
return DbView::make('home')->model('App\Template', 'template_name');

// Override content field
return DbView::make('home')->contentField('template_content');

// ... or a combination of these
return DbView::make('home')->model('App\Template', 'template_name')->contentField('template_content');

Cache

By default, cache is disabled in config file. If you enable the setting, a compiled version of the views will be stored at the desired path. If the model is updated, the updated_at field will be checked against the file modification date and the view will be re-rendered and cached.

Changelog

Please see CHANGELOG for more information on what has changed recently.

To do list

  • Expose view finder callback
  • Separate standard view composers from dbview composers.
  • Unit tests

License

laravel-db-blade is open-sourced software licensed under the MIT License (MIT). Please see License File for more information.

egorogl/laravel-db-blade 适用场景与选型建议

egorogl/laravel-db-blade 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 31 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 06 月 10 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「model」 「laravel」 「compiler」 「eloquent」 「blade」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 egorogl/laravel-db-blade 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 egorogl/laravel-db-blade 我们能提供哪些服务?
定制开发 / 二次开发

基于 egorogl/laravel-db-blade 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-06-10