{"id":15984907,"url":"https://github.com/divineomega/thisishowirole","last_synced_at":"2025-08-19T11:09:54.832Z","repository":{"id":56969693,"uuid":"60843819","full_name":"DivineOmega/ThisIsHowIRole","owner":"DivineOmega","description":"PHP role management system","archived":false,"fork":false,"pushed_at":"2018-01-27T00:02:19.000Z","size":29,"stargazers_count":2,"open_issues_count":1,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-02T11:36:27.488Z","etag":null,"topics":["php","php-library","role-manager","roles"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DivineOmega.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}},"created_at":"2016-06-10T11:44:27.000Z","updated_at":"2020-03-25T15:21:31.000Z","dependencies_parsed_at":"2022-08-21T06:40:16.667Z","dependency_job_id":null,"html_url":"https://github.com/DivineOmega/ThisIsHowIRole","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/DivineOmega/ThisIsHowIRole","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DivineOmega%2FThisIsHowIRole","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DivineOmega%2FThisIsHowIRole/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DivineOmega%2FThisIsHowIRole/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DivineOmega%2FThisIsHowIRole/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DivineOmega","download_url":"https://codeload.github.com/DivineOmega/ThisIsHowIRole/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DivineOmega%2FThisIsHowIRole/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271143398,"owners_count":24706346,"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-08-19T02:00:09.176Z","response_time":63,"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":["php","php-library","role-manager","roles"],"created_at":"2024-10-08T02:11:14.625Z","updated_at":"2025-08-19T11:09:54.802Z","avatar_url":"https://github.com/DivineOmega.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# This Is How I Role (TIHIR)\n\n'This Is How I Role' is a PHP role management system that can be applied to any\nclass.\n\n## Installation\n\nYou can use `composer` to install this package. \nJust run `composer require divineomega/thisishowirole`.\n\n## Setup\n\n### Table creation\n\nFirst, create a new table in your application's database to store the TIHIR\nroles. You can use the following SQL snippet to create the table.\n\n```sql\nCREATE TABLE IF NOT EXISTS `tihir_roles` (\n  `id` int(11) NOT NULL AUTO_INCREMENT,\n  `class_name` varchar(1000) NOT NULL,\n  `foreign_id` bigint(20) NOT NULL,\n  `roles` text NOT NULL,\n  PRIMARY KEY (`id`)\n) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;\n```\n\nIf you're using Laravel, you can use the following database migration to\ncreate the TIHIR roles table.\n\n```php\n\u003c?php\n\nuse Illuminate\\Database\\Schema\\Blueprint;\nuse Illuminate\\Database\\Migrations\\Migration;\n\nclass CreateThisIsHowIRoleRolesTable extends Migration\n{\n    /**\n     * Run the migrations.\n     *\n     * @return void\n     */\n    public function up()\n    {\n        Schema::create('tihir_roles', function (Blueprint $table) {\n            $table-\u003eincrements('id');\n            $table-\u003estring('class_name');\n            $table-\u003ebigInteger('foreign_id');\n            $table-\u003etext('roles');\n        });\n    }\n\n    /**\n     * Reverse the migrations.\n     *\n     * @return void\n     */\n    public function down()\n    {\n        Schema::drop('tihir_roles');\n    }\n}\n```\n\n### Database connection configuration\n\nIf you're using Laravel, TIHIR will automatically use the database you've\nconfigured for your application, so you don't need to do anything here. \nWe'll also use Eloquent to communicate with your database.\n\nOtherwise, you need to set some environmental variables to point TIHIR towards your\ndatabase. Something similar to the following will do the trick. If you're using\na framework that supports it, you can put this in your `.env` file. If not, \nyou can use PHP's built in `putenv` function.\n\n```\nTIHIR_DB_TYPE=mysql\nTIHIR_DB_NAME=tihir_test\nTIHIR_DB_HOST=192.168.1.44\nTIHIR_DB_USER=tihir_test\nTIHIR_DB_PASSWORD=PAMBSHcHssQqpw4A\n```\n\n## Usage\n\nThis Is How I Role works by enhancing existing classes. This will work on any\nPHP class, be it a manually created class or a Laravel Eloquent model. The only\nrequirement is that the class must have an accessible, numeric `id` property.\n\nAll you need to do is add two extra `use` lines to your class. This is shown in\nthe example `User` class shown below.\n\n```php\nrequire 'vendor/autoload.php';\n\nuse DivineOmega\\ThisIsHowIRole\\RolesTrait as Roles; // \u003c-- Line 1\n\nclass User\n{\n  use Roles; // \u003c-- Line 2\n\n  public $id = 123;\n\n}\n```\n\nThis `User` class now has the TIHIR roles system available to it. You can now\nuse various methods to add, remove or check for roles against this class. The\nsnippet below shows how roles can be manipulated.\n\n```php\n$user = new User;\n\n$user-\u003eroles-\u003eadd('can_eat_cake');\n$user-\u003eroles-\u003eadd('can_eat_cookies');\n$user-\u003eroles-\u003eremove('can_eat_cookies');\n\necho 'This user can ';\n\nif ($user-\u003eroles-\u003ehas('can_eat_cake')) {\n  echo 'eat cakes... ';\n}\n\nif ($user-\u003eroles-\u003ehas('can_eat_cookies')) {\n  echo 'eat cookies... ';\n}\n\necho \"\\n\";\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdivineomega%2Fthisishowirole","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdivineomega%2Fthisishowirole","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdivineomega%2Fthisishowirole/lists"}