stats4sd/laravel-shiny-loader 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

stats4sd/laravel-shiny-loader

Composer 安装命令:

composer require stats4sd/laravel-shiny-loader

包简介

This is my package laravel-shiny-loader

README 文档

README

Latest Version on Packagist Total Downloads

A Laravel package that lets you embed Shiny apps into your Laravel application with iFrames.

...But surely that doesn't need a package? You're right - you can just use an iFrame and point it at your Shiny app (as long as the app is publicly accessible).

This package does more than that - it provides a way for Laravel to communicate with the Shiny app to:

  • pass initialisation data into the app
  • ensure that the current user is authenticated before loading the app.

How does it work?

TODO: Update and bring over documentation from : https://github.com/stats4sd/shiny-laravel-auth-example

Installation

You can install the package via composer. You will also need to publish the config file, so you can specify the urls of the Shiny apps to embed:

composer require stats4sd/laravel-shiny-loader
php artisan vendor:publish --tag shiny-loader-config

Add the following properties to your .env file:

## Path to the directory where shiny apps are served from. For example, if you have shiny apps in /srv/shiny-server/app1 and /srv/shiny-server/app2, set this to /srv/shiny-server
SHINY_APP_PATH="/path/to/shiny/app/container"

## A secret key that both the Laravel app and the Shiny app know. This is used to authenticate requests from Laravel to the Shiny app
## This can be literally any string; the only requirement is that it is also included in the Shiny app's configuration
SHINY_AUTH_KEY="change-me"

## Then add the URL of every shiny app to be embedded. E.g., to match the 'example' entries in the config file you just published:
SHINY_APP_URL_MONITORING="http://127.0.0.1:7008"
SHINY_APP_URL_ANALYSIS="http://127.0.0.1:7009"

Note

The shiny app needs to be available at the given url independantly of your Laravel app. This doesn't mean users can actually reach the app at this url; we recommend that you use some approach to prevent users just going directly to this url. The most secure approach is to develop your Shiny app to require POST data from the Laravel app before rendering sensitive content.

TODO: tidy up R Shiny side of this interaction and share documentation

Use

To enable authentication, you need to set up a route in your Laravel app.

This package provides a Route Macro to make this easy. In your main routes/web.php (or where-ever you register your routes), add the following:

use Illuminate\Support\Facades\Route;

Route::shiny()

If you want to add extra middleware to the route (for example, to ensure the user is authenticated, or has a specific role), you can do so by wrapping the Route::shiny() call in a middleware group. E.g:

use Illuminate\Support\Facades\Route;

Route::middleware(['auth', 'role:admin'])->group(function () {
    Route::shiny();
});

This will ensure that, even if the user could somehow get to the page that renders the Shiny app, the app will not receive the POST request to confirm the user is authenticated unless your middleware is passed.

The main way to use the package is by adding the ShinyIframe component to your page. It requires a $shinyAppUrl - the url of the Shiny app you want to embed. You may optionally add $postData - an array of data to pass to the Shiny app when it loads.

    <x-shiny-loader::shiny-iframe
        :shiny-app-url="$shinyAppUrl"
        :post-data="['foo' => 'bar']"
        />

You can use the $postData to pass any data you want from Laravel to the Shiny app. For example:

  • The current user's ID or email address;
  • The ID of a resource the user is viewing in Laravel, so the Shiny app can load data related to that resource;
  • Any other arbitrary data you want to pass to the Shiny app.

TODO: add refs to documentation on how to setup the Shiny app to receive the postData.

Changelog

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

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

stats4sd/laravel-shiny-loader 适用场景与选型建议

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

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-09-11