定制 awkwardideas/switchblade 二次开发

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

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

awkwardideas/switchblade

Composer 安装命令:

composer require awkwardideas/switchblade

包简介

Extended blade directives for laravel

README 文档

README

Latest Stable Version Total Downloads Latest Unstable Version License

Install Via Composer

$ composer require awkwardideas/switchblade

Add to config/app.php

Under Package Service Providers Add

AwkwardIdeas\SwitchBlade\SwitchBladeServiceProvider::class,

Available Directives

Switch via Blade

A php switch statement implemented via blade.

The switch statement is similar to a series of IF statements on the same expression. In many occasions, you may want to compare the same variable (or expression) with many different values, and execute a different piece of code depending on which value it equals to. This is exactly what the switch statement is for.

  • @switch(expression, caseStatement1 [, caseStatement2, caseStatement3...])
    • This is the blade call to start the switch. It requires the expression and the first case statement. Optionally you can add as many case statements as you would like, which would all execute the code between the start of the switch and the first @endcase call.
  • @endcase
    • Add this to end the case statement. Only one is needed to stop all prior cases.
  • @case(caseStatement1 [, caseStatement2, caseStatement3...])
    • Add this to start a case statement. Optionally you can add as many case statements as you would like, which would all execute the code between the @caseand next @endcase call.
  • @defaultcase
    • Add this near the bottom of the switch to handle any variants of the expression which may not have been captured by a case statement. No end case is necessary since it will end with @endswitch
  • @endswitch
    • Add this to end your switch statement

Variable Modification

Set, increment or decrement variables without having to go in and out of php.

  • @set(variable, value)
  • @increment(variable)
  • @decrement(variable)

Variable Output

  • @htmlAttribute(value)
    • Echos the value safe for use in html attributes like id
  • @explode(delimiter, string, index)
    • Echos the index of the exploded result of the string, split by the delimiter
  • @implode(delimiter, array)
    • Echos the string result of the array joined by the delimiter

Debug Tools

  • @dd(variable)
    • Does a dump and die on the variable
  • @varDump(variable)
    • Does a dump of the variable
  • @getenv(ENV_VAR_NAME)
    • Echos the environment variable

Other helpful directives

  • @continue
    • Adds a php continue; tag to skip the rest of the current loop iteration
  • @break
    • Adds a php break; tag which ends the execution of a for, foreach, do-while or switch structure

If empty

  • @ifempty(variable)
    • If count of variable == 0
  • @endifempty
    • Ends if empty statement

If null

  • @ifnull(variable)
    • If variable is null
  • @endifnull
    • Ends if null statement

Not Null

  • @notnull(variable)
    • If variable is not null
  • @endnotnull
    • Ends not null statement

Optional Yield

  • @optional('section')
    • Outputs the content wrapped only if the referenced section has value
  • @endoptional
    • Ends optional output statement

File exists

  • @iffileexists(filepath)
    • Tests file path, continuing only if file exists
  • @endiffileexists
    • Ends file exists condition

Has Count

  • @hascount(variable)
    • Obtains the count of the variable, continuing if it is greater than 0
  • @endhascount
    • Ends has count condition

##Lang Modification

  • @lang(key[, replace, locale])
    • Modified to pass through to choice of 1, allowing plurals to be put in without having to have all singular usages changed to choice.

##Bag

  • @bag(variable[,value])
    • Appends a variable to a bag, or echos the bag as a list

Init Script

  • @initScript([scriptName])
    • Adds the script name to a bag if a parameter is passed. If no parameter is passed, the contents of the bag are dumped into a javascript window property.

awkwardideas/switchblade 适用场景与选型建议

awkwardideas/switchblade 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.1k 次下载、GitHub Stars 达 10, 最近一次更新时间为 2016 年 12 月 29 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-12-29