enlivenapp/hello-world-plugin 问题修复 & 功能扩展

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

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

enlivenapp/hello-world-plugin

最新稳定版本:0.2.0

Composer 安装命令:

composer require enlivenapp/hello-world-plugin

包简介

Reference FlightPHP plugin demonstrating proper MVC structure for FlightSchool

README 文档

README

Stable? Not Quite Yet License PHP Version Monthly Downloads Total Downloads GitHub Issues Contributors Latest Release Contributions Welcome

Hello World Plugin

A reference plugin for FlightPHP apps using the FlightSchool plugin loader. Use it as a starting point when building your own plugin.

What it demonstrates

  • Returning config values with auto-prefixed keys (Config/Config.php)
  • Defining routes that get auto-prefixed by the PluginLoader (Config/Routes.php)
  • Three different ways to get a config value into a controller method
  • Providing views that the host app can override
  • Creating runway commands

Config and route prefixes

The PluginLoader auto-prefixes config keys and routes based on the package name so plugins don't step on each other. This plugin's defaults are:

Default With override uncommented
Config key enlivenapp.hello-world-plugin hello-world
Route prefix /enlivenapp_hello_world_plugin /hello-world

To use the shorter versions, set configPrepend and routePrepend inside the returned array in src/Config/Config.php.

Plugin structure

src/
  Plugin.php                  <- Optional. Called after Config/ files are loaded.
  commands/
    HelloWorldCommand.php   <- Runway CLI command (must be lowercase, see below).
  Config/
    Config.php              <- Config values and optional prepend overrides. Loaded first.
    Services.php            <- Documentation only. Services use Composer autoloading.
    Routes.php              <- Routes. Auto-wrapped in a prefix group by the PluginLoader.
  Controllers/
    HelloController.php     <- Handles requests. Three methods, three patterns.
  Views/
    index.php               <- Default view for the /hello route.
    app-override-index.php  <- Copy this to override the view (see below).

Note: commands/ must be lowercase. Runway discovers command files by scanning the filesystem directly, not through Composer's autoloader. All other directories follow PSR-4 convention (uppercase).

Installation

composer require enlivenapp/hello-world-plugin

Configuration

When Composer installs the plugin, FlightSchool adds an entry to app/config/config.php:

'enlivenapp/hello-world-plugin' => [
    'enabled' => false,
    'priority' => 50,
],

To activate the plugin, change 'enabled' to true.

Config values live in src/Config/Config.php. The PluginLoader stores the returned array on $app under the config prepend key. To change a value, edit that file directly.

Flight School config

This package uses Flight School's return-array config format. src/Config/Config.php returns the package defaults as an array, Flight School stores that array under enlivenapp.hello-world-plugin on $app, and prepend overrides belong inside that returned array instead of as standalone variables.

The current example uses:

return [
    // 'configPrepend' => 'hello-world',
    'routePrepend' => 'hello-world',
    'greeting' => 'Hello from a vendor plugin!',
];

Reading config

$app is available in Config/ files, route files, and controllers (passed to the constructor). Read the full config array, then index into it:

$config = $app->get('enlivenapp.hello-world-plugin');
$greeting = $config['greeting'];

Models and services don't receive $app automatically — pass the values they need as parameters.

Routes

The PluginLoader wraps all routes in a prefix group automatically. With the default prefix:

Route Response How it gets the greeting
GET /enlivenapp_hello_world_plugin HTML view Passed as a method parameter from Routes.php
GET /enlivenapp_hello_world_plugin/hola JSON Reads $this->config (set in the constructor)
GET /enlivenapp_hello_world_plugin/hello HTML view Passed as a method parameter from Routes.php
GET /enlivenapp_hello_world_plugin/hallo JSON Reads config from $app->get() in the method

With 'routePrepend' => 'hello-world' set in the returned config array, routes become /hello-world, /hello-world/hola, etc.

Overriding views

The plugin includes a ready-to-use override template. Copy it to your app's views directory:

cp vendor/enlivenapp/hello-world-plugin/src/Views/app-override-index.php \
   app/views/enlivenapp/hello-world-plugin/index.php

You may need to create the directory first:

mkdir -p app/views/enlivenapp/hello-world-plugin

Once the override is in place, the plugin will use your version instead of its own.

License

MIT

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固