承接 vizrex/laraviz 相关项目开发

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

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

vizrex/laraviz

Composer 安装命令:

composer require vizrex/laraviz

包简介

A base package with various helpers and abstract classes, acting as a foundation and a standard for other packages.

README 文档

README

READ THIS FIRST

It is highly recommended for all contributors to update this file whenever there's a major update in source code. Use this tool for easy editing or visit this page for comprehensive guide on markdown syntax.

Introduction

This is base package with various helpers and abstract classes, acting as a foundation and a standard for other packages. It is highly recommended to build future packages and projects on top of this package.

Included Items

Base Classes

BaseCommand

A base class for Console commands of Laravel. It contains three new methods:

  • debug() This method calls info() of base class and outputs the given string in VERY_VERBOSE mode i.e. the given string will be displayed on console only when -vvvv flag will be passed to a command.
  • setNamespace() This is an abstract method. It should set $this->namespace property of command. Ideally its value should be taken from static getNamespace() method of Service Provider class as implemented in BaseServiceProvider and its child classes.
  • setDefaultTranslationFile() This method sets the $defaultTranslationFile property of command. It is the name of file from which the localized strings should be loaded by default.
  • str() This is a helper method that calls __() or trans() method to load localized strings based upon the values of $namespace and $defaultTranslationFile property of command. However, it is overloaded to accept a translations file name other than $defaultTranslationFile.

BaseException

BaseController

BaseServiceProvider

It has a static method getNamespace() that returns the namespace of this service provider in a specific format.

BaseRepository

It has the implementation of basic methods related to a resource:

  • index()
  • find()
  • store()
  • update
  • destroy()

BaseMigration

This class can be extended by Laravel migration classes. Child class would need to implement following three methods:

  • __construct() It should call parent::__construct("my_table") where my_table should be replaced with appropriate table name. It is highly recommended to get this string by calling getTableName() of a model for which this migration is intended.

  • doChanges() This method will get an object of Blueprint. Developer can write the schema related statements straightforwardly without worrying about existence and non-existence of table. Use it as substitute of traditional up() method. However up() method can also be overridden if required.

  • undoChanges() This function gets the table name as parameter. Use it as substitute of traditional down() method. However the later can still be overridden when required.

BaseSeeder

BaseTrait: LaravizModel

Use this trait in Eloquent Models and override findByIdentifier() method. There can be more than one identifiers of a model e.g. a user can be identified by its id as well as by email attribute. So instead of writing orWhere clauses, findByIdentifier() method can be called neatly.

Base Resource

This class has following two additional methods as compared to default Resource of Laravel:

  • toCompactArray
  • toFullArray

There're two properties of this class:

Static: $defaultResponseType

Default response type can be set with this property (default is ResponseType::FULL)

Non-static: $responseType

This property overrides the $defaultResponseType and can be set only via constructor.

Default Routes

Following open routes will be added to the application using this package:

/time

It returns current datetime with timezone details as JSON string.

/info

It returns the output of phpinfo()

These routes can be customized using config/laraviz.php file. Execute the following command to publish this config file:

php artisan vendor:publish --tag=Vizrex_Laraviz

Added Helpers

Eloquent Helpers

get_fillables()

It returns the fillable attributes as an associative array having key and value.

Html Helpers

public_url()

Returns base URL of application.

css($absolutePathOrArray)

Adds the HTML tag for including CSS. You can pass either an string, an array or an associative array where the key should contain the URL of CSS and the value should contain an expression such that CSS would be included only when the expression yields to true.

css("http://sample-cdn.com/example.css");
css(["http://abc.com/first.css", "http://abc.com/second.css"]);
css(["http://abc.com/first.css", ["http://abc.com/second.css" => 1 > 2], "http://www.example.com/main.css"]);

public_css($relativePath)

Adds the HTML tag for including css relative to public/css folder.

js($absolutePathOrArray)

Adds the HTML tag for including Javascript file. See the description of css() method. This method works exactly like that.

public_js($relativePath)

Adds the HTML tag for including js relative to public/js

Path Helpers

merge_url()

Currently it simply concatenates two string and adds a forward slash / between them. It can be enhanced to handle more complex situations.

String Helpers

str_concat()

This function accepts variable number of parameters and concatenates.

s()

This helper method is a wrapper on trans() and __() methods of Laravel. Using this method will eliminate the need of specifying language/translations file name every time. Simply specify a default language file in config/laraviz.php file and only pass the key to s() method. It will simply concatenate the configured file name to the given key and pass it to trans() method.

System Helpers

Following methods have very basic implementation. They're sort of thin wrappers. However there's a lot of room for enhancements

  • v_echo()
  • v_info()
  • v_debug
  • v_error()

To-dos

Following are the approved items:

  • Improve merge_url() to handle complex situations e.g. concatenate relative urls to create an absolute one.
  • Improve SystemHelpers. Ideally there should be a separate package for logging and SystemHelpers should only be thin wrappers on top of our custom logger.

Wishlist

Add the suggestions in this wishlist. Only approved wishlist items can be moved to To-dos list:

  • Item-1

vizrex/laraviz 适用场景与选型建议

vizrex/laraviz 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 642 次下载、GitHub Stars 达 1, 最近一次更新时间为 2019 年 01 月 16 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 vizrex/laraviz 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 2
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: proprietary
  • 更新时间: 2019-01-16