定制 tixelrocks/class-constants-helper 二次开发

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

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

tixelrocks/class-constants-helper

Composer 安装命令:

composer require tixelrocks/class-constants-helper

包简介

A tiny package that makes working with PHP class constants easier

README 文档

README

Build Status Total Downloads Latest Stable Version Latest Unstable Version License

A tiny package that makes working with PHP class constants easier

Have you ever noticed yourself doing stuff like this:

<?php

class Artist {
  const ARTIST_TYPE_MUSICIAN = 0;
  const ARTIST_TYPE_COMEDIAN = 1;
  const ARTIST_TYPE_MAGICIAN = 2;
}

And then somewhere later, maybe in the views:

<select>
  <option value="{{ Artist::ARTIST_TYPE_MUSICIAN }}">Musician</option>
  <option value="{{ Artist::ARTIST_TYPE_COMEDIAN }}">Comedian</option>
  <option value="{{ Artist::ARTIST_TYPE_MAGICIAN }}">Magician</option>
</select>

Now, wouldn't you want to just iterate through them instead? They all have the same prefix after all. This package does exactly that:

$ composer require tixelrocks/class-constants-helper

Now you have a new helper function constants() loaded through composer's auto-load. We can simplify our select input now:

<select>
  @foreach (constants(Artist::class, 'ARTIST_TYPE') as $value)
    <option value="{{ $value }}">{{ $value }}</option>
  @endforeach
</select>

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-03-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固