{"id":15169522,"url":"https://github.com/sdailover/yii2-phpsessconnector","last_synced_at":"2026-02-02T05:06:01.877Z","repository":{"id":225730527,"uuid":"766698079","full_name":"SDaiLover/yii2-phpsessconnector","owner":"SDaiLover","description":"The SDaiLover PHP Session Connector extension for the Yii 2.0 Framework","archived":false,"fork":false,"pushed_at":"2024-03-04T00:12:49.000Z","size":22,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-02-16T09:41:51.414Z","etag":null,"topics":["active-record","php-session","phpsessconnector","sdailover","yii2","yii2-extension"],"latest_commit_sha":null,"homepage":"https://www.sdailover.com","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SDaiLover.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-03-04T00:11:26.000Z","updated_at":"2024-03-04T00:13:39.000Z","dependencies_parsed_at":"2024-03-04T01:27:43.821Z","dependency_job_id":"7545afdd-72f3-441c-8cd6-39badddf6d16","html_url":"https://github.com/SDaiLover/yii2-phpsessconnector","commit_stats":null,"previous_names":["sdailover/yii2-phpsessconnector"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SDaiLover%2Fyii2-phpsessconnector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SDaiLover%2Fyii2-phpsessconnector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SDaiLover%2Fyii2-phpsessconnector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SDaiLover%2Fyii2-phpsessconnector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SDaiLover","download_url":"https://codeload.github.com/SDaiLover/yii2-phpsessconnector/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248824662,"owners_count":21167343,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["active-record","php-session","phpsessconnector","sdailover","yii2","yii2-extension"],"created_at":"2024-09-27T07:03:14.674Z","updated_at":"2026-02-02T05:06:01.848Z","avatar_url":"https://github.com/SDaiLover.png","language":"PHP","funding_links":["https://opencollective.com/sdailover","https://github.com/sponsors/sdailover","https://www.paypal.me/sdailover","https://www.opencollective.com/sdailover"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://www.sdailover.com/\" target=\"_blank\"\u003e\n        \u003cimg src=\"https://sdailover.github.io/images/logo.png\" width=\"128px\"\u003e\n    \u003c/a\u003e\n    \u003ch1 align=\"center\"\u003eSDaiLover PHPSessionConnector for Yii 2\u003c/h1\u003e\n    \u003cbr\u003e\n\u003c/p\u003e\n\n# yii2-phpsessconnector\n\nRuntime database helper to choose PHP Session or another database without change structure model of  [Yii framework 2.0](https://www.yiiframework.com).\n\nFor license information check the [LICENSE](LICENSE.md)-file.\n\nDocumentation is at [docs/guide/README.md](docs/guide/README.md).\n\n[![PHP Language](https://img.shields.io/badge/%20Lang%20-%20PHP%208.1%20-gray.svg?colorA=2C5364\u0026colorB=0F2027\u0026style=flat\u0026logo=php\u0026logoColor=white)](https://github.com/sdailover/yii2-phpsessconnector)\n[![Code Editor](https://img.shields.io/badge/%20IDE%20-%20Visual%20Code%20-gray.svg?colorA=2C5364\u0026colorB=0F2027\u0026style=flat\u0026logo=visualstudio\u0026logoColor=white)](https://github.com/sdailover/yii2-phpsessconnector)\n[![PHP Framework](https://img.shields.io/badge/%20Framework%20-%20Yii%202.0%20-gray.svg?colorA=2C5364\u0026colorB=0F2027\u0026style=flat\u0026logo=framework\u0026logoColor=white)](https://github.com/sdailover/yii2-phpsessconnector)\n[![CSS Bootstrap](https://img.shields.io/badge/%20CSS%20-%20Bootstrap%205.3%20-gray.svg?colorA=2C5364\u0026colorB=0F2027\u0026style=flat\u0026logo=bootstrap\u0026logoColor=white)](https://github.com/sdailover/yii2-phpsessconnector)\n[![JS jQuery](https://img.shields.io/badge/%20JS%20-%20jQuery%203.2%20-gray.svg?colorA=2C5364\u0026colorB=0F2027\u0026style=flat\u0026logo=jquery\u0026logoColor=white)](https://github.com/sdailover/yii2-phpsessconnector)\n\n\n[![Latest Stable Version](https://poser.pugx.org/sdailover/yii2-phpsessconnector/v/stable.png)](https://packagist.org/packages/sdailover/yii2-phpsessconnector)\n[![Total Downloads](https://poser.pugx.org/sdailover/yii2-phpsessconnector/downloads.png)](https://packagist.org/packages/sdailover/yii2-phpsessconnector)\n[![GitHub watchers](https://img.shields.io/github/watchers/sdailover/yii2-phpsessconnector)](https://github.com/sdailover/yii2-phpsessconnector)\n[![GitHub Repo stars](https://img.shields.io/github/stars/sdailover/yii2-phpsessconnector)](https://github.com/sdailover/yii2-phpsessconnector)\n[![GitHub issues](https://img.shields.io/github/forks/sdailover/yii2-phpsessconnector)](https://github.com/sdailover/yii2-phpsessconnector)\n\n[![GitHub contributors](https://img.shields.io/github/contributors/sdailover/yii2-phpsessconnector)](https://github.com/sdailover/yii2-phpsessconnector)\n[![GitHub pull requests](https://img.shields.io/github/issues-pr/sdailover/yii2-phpsessconnector)](https://github.com/sdailover/yii2-phpsessconnector/pulls)\n[![GitHub issues](https://img.shields.io/github/issues/sdailover/yii2-phpsessconnector)](https://github.com/sdailover/yii2-phpsessconnector/issues)\n[![GitHub Discussions](https://img.shields.io/github/discussions/sdailover/yii2-phpsessconnector)](https://github.com/sdailover/yii2-phpsessconnector/discussions)\n[![GitHub last commit (by committer)](https://img.shields.io/github/last-commit/sdailover/yii2-phpsessconnector)](https://github.com/sdailover/yii2-phpsessconnector)\n\n\n[Report Bug](https://github.com/sdailover/yii2-phpsessconnector/issues/new?assignees=\u0026labels=bug\u0026projects=\u0026template=bug_report.yml)\n·\n[Request Feature](https://github.com/sdailover/yii2-phpsessconnector/issues/new?assignees=\u0026labels=enhancement\u0026projects=\u0026template=feature_request.yml)\n·\n[Provide Feedback](https://github.com/sdailover/yii2-phpsessconnector/discussions/new?category=ideas\u0026title=Suggest%20for%20SDaiLover%20Yii2%20PhpSessConnector)\n·\n[Ask Question](https://github.com/sdailover/yii2-phpsessconnector/discussions/new?category=q-a\u0026title=Ask%20Question%20for%20SDaiLover%20Yii2%20PhpSessConnector)\n\nLove the project? Please consider [donating](https://opencollective.com/sdailover) or give :star: to help it improve!\n\nCopyright \u0026copy; ID 2024 SDaiLover \u0026#40;[www.sdailover.com](https://sdailover.com)\u0026#41;\n\nAll rights reserved.\n\n***\n\nInstallation\n------------\n\nThe preferred way to install this extension is through [composer](https://getcomposer.org/download/).\n\nEither run\n\n```\nphp composer.phar require --prefer-dist sdailover/yii2-phpsessconnector\n```\n\nor add\n\n```json\n\"sdailover/yii2-phpsessconnector\": \"~1.0.0\"\n```\n\nto the `require` section of your `composer.json`.\n\nApp Configuration\n-----\n\nTo use this extension, simply add the following code in your application configuration:\n\n```php\nreturn [\n    //....\n    'components' =\u003e [\n        'db' =\u003e [\n            'class' =\u003e '\\sdailover\\yii\\phpsessconnector\\SDConnection',\n            'dsn' =\u003e 'phpsession:sdailover',\n            // prefix name of session\n            'tablePrefix' =\u003e 'sd_'\n        ],\n    ],\n];\n```\n\nModel Usage\n-----\n\nTo connect a database using ActiveRecord into a Model class:\n\n```php\nnamespace app\\models;\n\nuse sdailover\\yii\\phpsessconnector\\SDActiveRecord;\n\nclass ModelClass extends SDActiveRecord\n{\n    //....\n\n    /* Create list attribute or name's field of database. */\n    public $attribute;\n\n    /**\n     * Default data imported into the php session,\n     * this data only load to php session and not\n     * import data to real database (mysql, sqlite, others).\n     */\n    private static $data = [\n        [\n            'attribute' =\u003e 'value',\n            //....\n        ]\n    ];\n\n    /**\n     * Set the name of the database table or table session.\n     */\n    public static function tableName()\n    {\n        return '{{tablename}}';\n    }\n\n    /**\n     * Load and import default data to php session.\n     */\n    public static function loadTable()\n    {\n        parent::records(static::$data);\n    }\n\n    //....\n}\n```\n\nProvider Usage\n-----\n\nData 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:\n\n```php\nnamespace app\\models;\n\nuse app\\models\\ModelClass;\nuse sdailover\\yii\\phpsessconnector\\SDActiveProvider;\n\nclass ModelSearchClass extends ModelClass\n{\n    //....\n\n    public function search($params)\n    {\n        $query = ModelClass::find();\n\n        $dataProvider = new SDActiveProvider([\n            'query' =\u003e $query\n        ]);\n\n        if (!($this-\u003eload($params) \u0026\u0026 $this-\u003evalidate())) {\n            return $dataProvider;\n        }\n\n        // Add filter condition\n        if ($this-\u003eattribute !== null \u0026\u0026 !empty($this-\u003eattribute))\n            $query-\u003eandFilterWhere(['attribute' =\u003e $this-\u003eattribute]);\n        return $dataProvider;\n    }\n\n    //....\n}\n```\n\nController Usage\n-----\n\nTo use the `SDActiveRecord` and `SDDataProvider` that have been created, we can implement them into the Controller that will be used as follows:\n\n```php\nnamespace app\\controllers;\n\nuse yii\\web\\Controller;\nuse app\\models\\ModelClass;\nuse app\\models\\ModelSearchClass;\n\nclass SiteController extends Controller\n{\n    //....\n\n    /**\n     * Display model from SDActiveRecord.\n     */\n    public function actionView()\n    {\n        $pkId = Yii::$app-\u003erequest-\u003eisGet ? Yii::$app-\u003erequest-\u003eget('attribute') : Yii::$app-\u003erequest-\u003epost('attribute');\n        $model = ModelClass::findOne($pkId);\n\n        return $this-\u003erender('view', ['model'=\u003e$model]);\n    }\n\n    /**\n     * Display many model from SDActiveRecord with Data Provider.\n     */\n    public function actionSearch()\n    {\n        $searchModel = new ModelSearchClass();\n        $searchParams = Yii::$app-\u003erequest-\u003eisGet ? Yii::$app-\u003erequest-\u003eget() : Yii::$app-\u003erequest-\u003epost();\n        $dataProvider = $searchModel-\u003esearch($searchParams);\n\n        return $this-\u003erender('search', ['dataProvider'=\u003e$dataProvider]);\n    }\n\n    //....\n}\n```\n\n# Support the project\n\nWe 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.\n\nIf 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:\n\n- Giving proper credit on the GitHub Sponsors page. [![Static Badge](https://img.shields.io/badge/%20Sponsor%20-gray.svg?colorA=EAEAEA\u0026colorB=EAEAEA\u0026style=fat\u0026logo=githubsponsors\u0026logoColor=EA4AAA)](https://github.com/sponsors/sdailover)\n- Starring and sharing the project :star:\n- You can make one-time donations via PayPal. I'll probably buy a coffee :coffee: or tea :tea: or cake :cake: \u003cbr\u003e\n  [![paypal.me/sdailover](https://img.shields.io/badge/%20Donate%20Now%20-gray.svg?colorA=2C5364\u0026colorB=0F2027\u0026style=for-the-badge\u0026logo=paypal\u0026logoColor=white)](https://www.paypal.me/sdailover)\n- It’s also possible to support mine financially by becoming a backer or sponsor through\u003cbr\u003e\n  [![opencollective.com/sdailover](https://img.shields.io/badge/%20Donate%20Now%20-gray.svg?colorA=355C7D\u0026colorB=2980B9\u0026style=for-the-badge\u0026logo=opencollective\u0026logoColor=white)](https://www.opencollective.com/sdailover)\n  \nHowever, 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:\u003cbr\u003e\n[![team@sdailover.com](https://img.shields.io/badge/%20Send%20Mail%20-gray.svg?colorA=EA4335\u0026colorB=93291E\u0026style=for-the-badge\u0026logo=gmail\u0026logoColor=white)](mailto:team@sdailover.com)\n\n## :pray: Thanks for your contribute and support! :heart_eyes: :heart:\n\n\u003e Any Questions \u0026 Other Supports? see [Support](https://github.com/sdailover/.github/blob/master/SUPPORT.md) please.\n\n***\n\n[Visit Website](https://www.sdailover.com)\n·\n[Global Issues](https://github.com/sdailover/.github/issues/new/choose)\n·\n[Global Discussions](https://github.com/sdailover/.github/discussions)\n·\n[Global Wiki](https://github.com/sdailover/.github/wiki)\n\n\nCopyright \u0026copy; ID 2024 by SDaiLover \u0026#40;[www.sdailover.com](https://sdailover.com)\u0026#41;\n\n[![SDaiLover License](https://upload.wikimedia.org/wikipedia/commons/thumb/1/18/Bsd-license-icon-120x42.svg/120px-Bsd-license-icon-120x42.svg.png)](https://github.com/sdailover/.github/blob/master/LICENSE.md)\n\nAll rights reserved.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsdailover%2Fyii2-phpsessconnector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsdailover%2Fyii2-phpsessconnector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsdailover%2Fyii2-phpsessconnector/lists"}