rootwork/phalcon-extras
Composer 安装命令:
composer require rootwork/phalcon-extras
包简介
Phalcon Extras
README 文档
README
A growing collection of useful Phalcon classes
Installation
composer require rootwork/phalcon-extras:dev-master
Authorization Component
Uses Phalcon\Acl, see acl.example.php.
<?php
cp acl.example.php app/config/acl.php
The AuthComponent uses events for your custom logic after allowing or denying a session role.
<?php /** * Setup the auth component */ $di->setShared('auth', function () { /** @var \Phalcon\Config $aclConfig */ $aclConfig = include APP_PATH . '/config/acl.php'; $auth = new AuthComponent($aclConfig->toArray()); $eventsManager = new EventsManager(); $eventsManager->attach('auth:afterAllowed', function (Event $event, AuthComponent $auth) { if ($auth->persistent->role == 'Guest') { return true; // If the ACL allows a Guest at this route, no additional steps } // Load authorized user from the DB if ($user = User::findFirstById($auth->persistent->userId)) { $auth->di->setShared('user', $user); return true; } return false; }); $eventsManager->attach('auth:afterDenied', function (Event $event, AuthComponent $auth) { // Redirect unathorized users $auth->response->redirect('/login'); $auth->response->send(); return false; }); $auth->setEventsManager($eventsManager); return $auth; }); /** * Register a dispatcher */ $di->setShared('dispatcher', function () use ($config, $di) { $eventsManager = new EventsManager(); $eventsManager->attach('dispatch:beforeExecuteRoute', $di->get('auth')); $dispatcher = new Dispatcher(); $dispatcher->setDefaultNamespace('App\Controller'); $dispatcher->setEventsManager($eventsManager); return $dispatcher; }); /** * Make the current user available to the app */ $di->setShared('user', function () { return null; });
Create an authorized session
In your login code, you must set the user role. You can optionally persist other auth data.
<?php // In a login action... $auth = $this->getDI()->get('auth'); $auth->setRole($user->role); // Optional persisted auth data $auth->persistent->userId = $user->id; $auth->persistent->name = $user->name;
TODO
- Document usage with Micro app
rootwork/phalcon-extras 适用场景与选型建议
rootwork/phalcon-extras 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8.34k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2016 年 06 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「library」 「Extras」 「phalcon」 「rootwork」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 rootwork/phalcon-extras 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 rootwork/phalcon-extras 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 rootwork/phalcon-extras 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Experimental features for the Rubix ML library.
Inbox pattern process implementation for your Laravel Applications
Uniondrug Trace Client Component for uniondrug/framework
Core library that defines common interfaces used by the rest of the intahwebz..
Amqp classes
Библиотека для работы с BigQuery
统计信息
- 总下载量: 8.34k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2016-06-20