{"id":22568408,"url":"https://github.com/nullrefexcep/yii2-core","last_synced_at":"2025-10-13T02:47:05.887Z","repository":{"id":34329054,"uuid":"38248611","full_name":"NullRefExcep/yii2-core","owner":"NullRefExcep","description":"Base for fast and efficient website development","archived":false,"fork":false,"pushed_at":"2021-04-29T19:09:36.000Z","size":119,"stargazers_count":4,"open_issues_count":8,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-08-23T09:53:38.881Z","etag":null,"topics":["yii2"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NullRefExcep.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-29T13:17:42.000Z","updated_at":"2022-07-19T22:54:11.000Z","dependencies_parsed_at":"2022-08-08T00:16:13.279Z","dependency_job_id":null,"html_url":"https://github.com/NullRefExcep/yii2-core","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/NullRefExcep/yii2-core","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NullRefExcep%2Fyii2-core","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NullRefExcep%2Fyii2-core/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NullRefExcep%2Fyii2-core/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NullRefExcep%2Fyii2-core/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NullRefExcep","download_url":"https://codeload.github.com/NullRefExcep/yii2-core/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NullRefExcep%2Fyii2-core/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279014019,"owners_count":26085347,"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","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["yii2"],"created_at":"2024-12-08T00:13:05.594Z","updated_at":"2025-10-13T02:47:05.838Z","avatar_url":"https://github.com/NullRefExcep.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Yii2-core\n\n[![Latest Stable Version](https://poser.pugx.org/nullref/yii2-core/v/stable)](https://packagist.org/packages/nullref/yii2-core) [![Total Downloads](https://poser.pugx.org/nullref/yii2-core/downloads)](https://packagist.org/packages/nullref/yii2-core) [![Latest Unstable Version](https://poser.pugx.org/nullref/yii2-core/v/unstable)](https://packagist.org/packages/nullref/yii2-core) [![License](https://poser.pugx.org/nullref/yii2-core/license)](https://packagist.org/packages/nullref/yii2-core)\n\nWIP\n\nModule for administration\n\n## Installation\n\nThe preferred way to install this extension to use [composer](http://getcomposer.org/download/).\n\nEither run\n\n```\nphp composer.phar require --prefer-dist nullref/yii2-core \"*\"\n```\n\nor add\n\n```\n\"nullref/yii2-core\": \"*\"\n```\n\nto the require section of your `composer.json` file.\n\n### Config structure\n\nThis module designed to work with special config file.\n\nIn case when you use `module/install` command it creates `installed_modules.php` file in condif folder if it doesn't exist.\n\nThis file will contain config array of installed modules (obviously).\n\nYou need to merge this config with your applications config (web, console, etc). \n\nI recommend using the structure that described below, it used at our [application template](https://github.com/NullRefExcep/yii2-boilerplate).\n\n- installed_modules.php\n```php\n\u003c?php return [];\n```\n- modules.php\n```php\n\u003c?php \n$config = require(__DIR__ . '/installed_modules.php');\nreturn array_merge($config, []);\n```\n- web.php\n```php\n\u003c?php\n$modules = require(__DIR__ . '/modules.php');\n$config = [\n//...\n    'modules' =\u003e $modules,\n//...\n];\nreturn $config;\n```\n\nWhen you are using this config structure you are able to override installed modules cofiguration in `modules.php`.\n\nAlso, `modules.php` file could be included to `console.php` config file.\n\nApp-specific configs could be added directly in corresponding config file.\n\n### Modules system\n\nThis module provides basic tools for creating system of modules.\n\nAvailable modules:\n\n - [admin](https://github.com/NullRefExcep/yii2-admin)\n - [cms](https://github.com/NullRefExcep/yii2-cms)\n - [category](https://github.com/NullRefExcep/yii2-category)\n - [product](https://github.com/NullRefExcep/yii2-product)\n - [geo](https://github.com/NullRefExcep/yii2-geo)\n - [blog](https://github.com/NullRefExcep/yii2-blog)\n - [multisite](https://github.com/NullRefExcep/yii2-multisite)\n - [eav](https://github.com/NullRefExcep/yii2-eav)\n \nFor full integration, you have to run console command:\n\n```\nphp yii module/install \u003cmodule-name\u003e\n```\n\n### Content\n\nCore module for fast web development based on Yii2.\nThis package contains:\n\n- components:\n    * EntityManager - component for simple managing of entities (models)\n\n- interfaces:\n    * IAdminModule - interface for modules which can be used by [nullref\\yii2-admin](https://github.com/NullRefExcep/yii2-admin)\n    * IRoleContainer - interface which provide roles for RBAC\n    * IEntityManager - interface EntityManager\n    * IEntityManageble - interface for classes which contain EntityManager\n \n\n### Translation overriding\n\nCore package contain [PhpMessageSource](https://github.com/NullRefExcep/yii2-core/blob/master/src/components/i18n/PhpMessageSource.php) class that allows to merge default module's and application's messages.\nExample for [admin](https://github.com/NullRefExcep/yii2-admin) module\n```php\n[\n /** App config **/\n 'components' =\u003e [\n  'i18n' =\u003e [\n      'translations' =\u003e [\n          '*' =\u003e ['class' =\u003e 'yii\\i18n\\PhpMessageSource'],\n          'admin' =\u003e ['class' =\u003e 'nullref\\core\\components\\i18n\\PhpMessageSource'],\n      ],\n  ],\n ]\n]\n```\n\nIn this case messages from category `admin` from application directory will be merged with default messages from module.\n\n### Modules migrations\n\nModule contains `MigrateController` controller which allows work with migrations of modules.\n\ne.g.:\n\n`php yii core/module --moduleId=admin` -- apply migrations for module with id `admin`\n\nKeep in mind: Migrations should have namespaces\n\nAlso, is possible work with migrations off all modules:\n\n`php yii core/module` -- collect all possible places of migrations.\n\nBy default, migrations are looked for directory `migrations` in directory of module class.\n\nIf you want to override this behavior, you can implement `IHasMigrateNamespace` interface by module class.\n\n\n### EntityManager\n\nComponent for simple work with models, which have soft delete and typification.\n\nConfig:\n```php\n/** module config **/\n'productManager' =\u003e [\n    \"class\" =\u003e \"nullref\\\\product\\\\components\\\\EntityManager\",\n    'hasImage' =\u003e false,\n    'hasStatus' =\u003e false,\n    'model' =\u003e [\n        'class' =\u003e 'app\\\\models\\\\Product',\n        'relations' =\u003e [\n            'category' =\u003e 'nullref\\\\category\\\\behaviors\\\\HasCategory',\n            'vendor' =\u003e 'app\\\\behaviors\\\\HasVendor',\n        ],\n    ],\n    'searchModel' =\u003e 'app\\\\models\\\\ProductSearch',\n],\n/** ... **/\n```\n\nAvailable methods:\n\n- `createModel()` - create new model\n- `createSearchModel()` - create new search model\n- `findOne($condition)` - find one model by condition\n- `findAll($condition)` - find all models by condition\n- `find($condition = [])` - create ActiveQuery with condition\n- `getMap($index = 'id', $value = 'title', $condition = [], $asArray = true)` - get key=\u003evalue array of model by condition\n- `delete($model)` - delete model\n- `decorateQuery($query)` decorate query by settings of entity manger\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnullrefexcep%2Fyii2-core","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnullrefexcep%2Fyii2-core","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnullrefexcep%2Fyii2-core/lists"}