iankov/control-panel-static

该软件包最新版本(v1.0.2)没有可用的许可证信息。

iankov/control-panel 的静态页面模块

v1.0.2 2018-07-19 11:02 UTC

This package is not auto-updated.

Last update: 2024-09-29 04:31:26 UTC


README

composer require iankov/control-panel-static
  • 发布迁移

    php artisan vendor:publish --tag=icp_static_migrations
  • 运行迁移

    php artisan migrate
  • 将项目添加到 icp-menu.php 配置文件

    [
        'icon' => 'file-text',
        'title' => 'Static',
        'link' => icp_route('static')
    ]

用法

在您的 routes/web.php 文件的末尾添加新的路由。这将尝试通过 StaticPageController 处理任何与正则表达式匹配的请求。如果请求的路由与数据库中存储的路由相等,您将获得通过 icp-static 模块设置的响应。

Route::get('{route}', ['as' => 'any', 'uses' => '\Iankov\ControlPanelStatic\Controllers\StaticPageController@index'])->where('route', '[0-9a-zA-Z\-\_\.]+');

示例:添加新静态页面,将路由字段设置为 custom_page.html,设置任何内容如 <b>Hello</b> World,使其生效并保存。现在打开您的浏览器并尝试请求 http://your-website.com/**custom_page.html**。您的屏幕必须显示此内容

Hello World

StaticPageController 将尝试通过 route 字段确定 mime-type 并返回包含在头部的页面内容。
这意味着如果您创建名为 page.html 的路由,您将通过此路由获得 html 类型的页面。 ...data.xml 将返回带有 xml 内容类型头部的页面内容。
如果无法定义 mime-type,则使用 text/html

配置

您可以通过将它们添加到 config/icp.php 来修改配置选项。
软件包配置位于 vendor/iankov/control-panel-static/src/config.php
不要更改此文件,只需将其用作可配置选项的示例。