定制 shadowprince/slimext 二次开发

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

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

shadowprince/slimext

Composer 安装命令:

composer require shadowprince/slimext

包简介

Addon for Slim microframework, adding components and routes prefix support

README 文档

README

SlimExt - monkeypatched extension to slim, that added functionality of nested routes (for easy url prefixing and adding middlewares), component support (not symfony).

Route url prefixes

$app->prefix("/uac", function () use ($app) {
    // Route registered as /uac/login
    $app->get("/login", function () use ($app) {
        $app->render("login", array());
    });
});

or even

$app->prefix("/uac", Middleware::userLogged(), function () use ($app) {
    $app->prefix("/edit", function () use ($app) {
        $app->map("/avatar", function () use ($app) {});
        $app->map("/info", function () use ($app) {});
        $app->prefix("/photos", Middleware::userCanManagePhotos(), function () use ($app) {
            $app->map("/upload", function () use ($app) {});
            $app->map("/delete/:id", function ($id) use ($app) {});
            $app->map("/edit/:id", function ($id) use ($app) {});
        });
    });
});

Middleware

$app->prefix("/admin", Midleware::userAdmin(), function () use ($app) {
    // Routes registered with Middleware::userAdmin() middleware
    $app->get("/", function () use ($app) {/* ... */});
    $app->get("/users", function () use ($app) {/* ... */});
});

Components

// Uac/urls.php
$app->prefix("/uac", function () use ($app) {
    $app->map("/login", function () use ($app) {
        // ...
    });
});
// bootstrap
$app->config("comps", array("Uac"));
$app->loadComponents();

Route /uac/login/ registered and ready.

Another example - integration with autoparis. You can automaticly grab all models (detached to components) just from $app->config("comps").

Services

Service - instance for adding new functionality into $app:

class MyApp extends \SlimExt\SlimExt {
    public function user() {
        return $this->user_service_instance;
    }
}

class UserService extends \SlimExt\SlimService {
    public function __construct($app) {
        $this->defaultConfig($app, array(
            "default config" => "can be here"
        ));
    }

    public function isLogged() {
        // ...
    }
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: BSD
  • 更新时间: 2013-10-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固