定制 fewfar/laravel-frontend 二次开发

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

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

fewfar/laravel-frontend

Composer 安装命令:

composer require fewfar/laravel-frontend

包简介

Frontend Build Framework for Laravel Projects

README 文档

README

Laravel Frontend

Build Status Total Downloads Latest Stable Version License

Laravel package to provide frontend template routes for non-production environments.

Installation

composer require fewfar/laravel-frontend

The package's service provider will be autoloaded on startup.

Next publish the templates and config file:

php artisan vendor:publish --provider="FewFar\LaravelFrontend\ServiceProvider"

The files published this way are examples of structure and are not enforced by the package. Edit config/vendor/fewfar/frontend.php to change the paths of these files.

Basic Usage

Add the following key to your .env file to enable the frontend routes (typically, local and staging):

FRONTEND_ENABLED=true

If this key is already in use for your project, you can change this in the config/vendor/fewfar/frontend.php file.

Now you can visit /templates/ and see the templates.

Page Defaults

Often within an app, it is useful to have view composers that load fallback variables from a configuration or the database when not provided by the controller explicitly. An example of this could be the page title in the HTML <head> for example. Depending on the setup you might not have a database defined when building the frontend templates, or you might not even want the database involved. In this case you still want your layout templates to recieve this variables, but it would be nice to hard code them for all the frontend templates.

To do this you can subclass the PageDefaultsViewComposer and add register it within a service provider:

Subclass the View Composer implementing your own values

<?php

namespace App\Providers;

use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;

use FewFar\LaravelFrontend\PageDefaultsViewComposer as BaseViewComposer;

class PageDefaultsViewComposer extends BaseViewComposer
{
    /**
     * Gets frontend default variables.
     *
     * @return array
     */
    protected function defaultsForFrontend()
    {
        return [
            'page' => [
                'title' => 'HTML Meta Title',
                'description' => 'HTML Meta Description',
                ...
            ],
        ];
    }

    /**
     * Gets application default variables (i.e. ones used when not in the
     * frontend templates.)
     *
     * @return array
     */
    protected function defaultsForApp()
    {
        return [
            'page' => [
                'title' => config('app.name'),
                ...
            ],
        ];
    }
}

Register your View Composer

<?php

namespace App\Http\ViewComposers;

use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;

use App\Http\ViewComposers\PageDefaultsViewComposer;

class ViewComposerServiceProvider extends ServiceProvider
{
    /**
     * Register bindings in the container.
     *
     * @return void
     */
    public function boot()
    {
        // Here the 'app/' directory is assumed to be all the individual pages,
        // and does not contain partials, or layouts. This is because the
        // composer will be ran multiple times if the Blade template extends
        // from files also in the 'app/' directory.
        View::composer('app/*', PageDefaultsViewComposer::class);
    }
}

Config Customisation

This package uses Laravel Config Provider to allow you customise how we interact with config, you can find more details over there on how to customise it there.

Laravel Compatibility

Development

This package provides a docker setup to develop and test itself. From the root of this directory you can run:

$ scripts/composer install
$ scripts/test

License

Laravel Frontend is open-sourced software licensed under the MIT license.

fewfar/laravel-frontend 适用场景与选型建议

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-06-28