承接 sdailover/yii2-phpsessconnector 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

sdailover/yii2-phpsessconnector

Composer 安装命令:

composer require sdailover/yii2-phpsessconnector

包简介

The SDaiLover PHP Session Connector extension for the Yii framework

README 文档

README

SDaiLover PHPSessionConnector for Yii 2


yii2-phpsessconnector

Runtime database helper to choose PHP Session or another database without change structure model of Yii framework 2.0.

For license information check the LICENSE-file.

Documentation is at docs/guide/README.md.

PHP Language Code Editor PHP Framework CSS Bootstrap JS jQuery

Latest Stable Version Total Downloads GitHub watchers GitHub Repo stars GitHub issues

GitHub contributors GitHub pull requests GitHub issues GitHub Discussions GitHub last commit (by committer)

Report Bug · Request Feature · Provide Feedback · Ask Question

Love the project? Please consider donating or give ⭐ to help it improve!

Copyright © ID 2024 SDaiLover (www.sdailover.com)

All rights reserved.

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist sdailover/yii2-phpsessconnector

or add

"sdailover/yii2-phpsessconnector": "~1.0.0"

to the require section of your composer.json.

App Configuration

To use this extension, simply add the following code in your application configuration:

return [
    //....
    'components' => [
        'db' => [
            'class' => '\sdailover\yii\phpsessconnector\SDConnection',
            'dsn' => 'phpsession:sdailover',
            // prefix name of session
            'tablePrefix' => 'sd_'
        ],
    ],
];

Model Usage

To connect a database using ActiveRecord into a Model class:

namespace app\models;

use sdailover\yii\phpsessconnector\SDActiveRecord;

class ModelClass extends SDActiveRecord
{
    //....

    /* Create list attribute or name's field of database. */
    public $attribute;

    /**
     * Default data imported into the php session,
     * this data only load to php session and not
     * import data to real database (mysql, sqlite, others).
     */
    private static $data = [
        [
            'attribute' => 'value',
            //....
        ]
    ];

    /**
     * Set the name of the database table or table session.
     */
    public static function tableName()
    {
        return '{{tablename}}';
    }

    /**
     * Load and import default data to php session.
     */
    public static function loadTable()
    {
        parent::records(static::$data);
    }

    //....
}

Provider Usage

Data Providers are usually used to search in Models or display Models in the form of widgets such as GridView and other extensions. To implement it into the application created, we can configure it as follows:

namespace app\models;

use app\models\ModelClass;
use sdailover\yii\phpsessconnector\SDActiveProvider;

class ModelSearchClass extends ModelClass
{
    //....

    public function search($params)
    {
        $query = ModelClass::find();

        $dataProvider = new SDActiveProvider([
            'query' => $query
        ]);

        if (!($this->load($params) && $this->validate())) {
            return $dataProvider;
        }

        // Add filter condition
        if ($this->attribute !== null && !empty($this->attribute))
            $query->andFilterWhere(['attribute' => $this->attribute]);
        return $dataProvider;
    }

    //....
}

Controller Usage

To use the SDActiveRecord and SDDataProvider that have been created, we can implement them into the Controller that will be used as follows:

namespace app\controllers;

use yii\web\Controller;
use app\models\ModelClass;
use app\models\ModelSearchClass;

class SiteController extends Controller
{
    //....

    /**
     * Display model from SDActiveRecord.
     */
    public function actionView()
    {
        $pkId = Yii::$app->request->isGet ? Yii::$app->request->get('attribute') : Yii::$app->request->post('attribute');
        $model = ModelClass::findOne($pkId);

        return $this->render('view', ['model'=>$model]);
    }

    /**
     * Display many model from SDActiveRecord with Data Provider.
     */
    public function actionSearch()
    {
        $searchModel = new ModelSearchClass();
        $searchParams = Yii::$app->request->isGet ? Yii::$app->request->get() : Yii::$app->request->post();
        $dataProvider = $searchModel->search($searchParams);

        return $this->render('search', ['dataProvider'=>$dataProvider]);
    }

    //....
}

Support the project

We open-source almost everything We can and try to reply to everyone needing help using these projects. Obviously, this takes time. You can use this service for free.

If you are using this project and are happy with it or just want to encourage us to continue creating stuff, there are a few ways you can do it:

  • Giving proper credit on the GitHub Sponsors page. Static Badge
  • Starring and sharing the project ⭐
  • You can make one-time donations via PayPal. I'll probably buy a coffee ☕ or tea 🍵 or cake 🍰
    paypal.me/sdailover
  • It’s also possible to support mine financially by becoming a backer or sponsor through
    opencollective.com/sdailover

However, we also provide software development services. You can also invite us to collaborate to help your business in developing the software you need. Please contact us at:
team@sdailover.com

🙏 Thanks for your contribute and support! 😍 ❤️

Any Questions & Other Supports? see Support please.

Visit Website · Global Issues · Global Discussions · Global Wiki

Copyright © ID 2024 by SDaiLover (www.sdailover.com)

SDaiLover License

All rights reserved.

sdailover/yii2-phpsessconnector 适用场景与选型建议

sdailover/yii2-phpsessconnector 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 36 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 03 月 01 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 sdailover/yii2-phpsessconnector 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2024-03-01