{"id":13395986,"url":"https://github.com/clarkeash/doorman","last_synced_at":"2025-05-14T00:09:59.368Z","repository":{"id":41514127,"uuid":"87339908","full_name":"clarkeash/doorman","owner":"clarkeash","description":"Limit access to your Laravel applications by using invite codes","archived":false,"fork":false,"pushed_at":"2025-05-02T14:34:22.000Z","size":288,"stargazers_count":1030,"open_issues_count":0,"forks_count":45,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-05-10T08:38:28.912Z","etag":null,"topics":["doorman","invite","laravel","laravel-package","php"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/clarkeash/doorman","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/clarkeash.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,"publiccode":null,"codemeta":null}},"created_at":"2017-04-05T17:53:41.000Z","updated_at":"2025-05-02T14:32:08.000Z","dependencies_parsed_at":"2024-01-15T05:09:47.787Z","dependency_job_id":"7a628dde-8e4f-4dae-b19c-62821665a9be","html_url":"https://github.com/clarkeash/doorman","commit_stats":{"total_commits":138,"total_committers":13,"mean_commits":"10.615384615384615","dds":0.4565217391304348,"last_synced_commit":"e55ea3207577be2752bf61571ee2929a966a3407"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clarkeash%2Fdoorman","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clarkeash%2Fdoorman/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clarkeash%2Fdoorman/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clarkeash%2Fdoorman/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/clarkeash","download_url":"https://codeload.github.com/clarkeash/doorman/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254044238,"owners_count":22005108,"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":["doorman","invite","laravel","laravel-package","php"],"created_at":"2024-07-30T18:00:37.110Z","updated_at":"2025-05-14T00:09:54.351Z","avatar_url":"https://github.com/clarkeash.png","language":"PHP","funding_links":[],"categories":["Popular Packages","PHP","Paquetes utiles"],"sub_categories":[],"readme":"# Doorman\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/clarkeash/laravel-http-stats/actions?query=workflow%3ACI\"\u003e\n    \u003cimg alt=\"GitHub Workflow Status\" src=\"https://img.shields.io/github/actions/workflow/status/clarkeash/doorman/tests.yml?logo=github\u0026style=for-the-badge\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/clarkeash/doorman/blob/master/LICENSE\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/license/clarkeash/doorman.svg?style=for-the-badge\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://packagist.org/packages/clarkeash/doorman\"\u003e\n    \u003cimg alt=\"GitHub release (latest SemVer)\" src=\"https://img.shields.io/github/v/release/clarkeash/doorman?sort=semver\u0026style=for-the-badge\"\u003e\n  \u003c/a\u003e  \n  \u003ca href=\"https://twitter.com/clarkeash\"\u003e\n    \u003cimg src=\"http://img.shields.io/badge/author-@clarkeash-blue.svg?style=for-the-badge\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\nDoorman provides a way to limit access to your Laravel applications by using invite codes.\n\nInvite Codes:\n* Can be tied to a specific email address.\n* Can be available to anyone (great for sharing on social media).\n* Can have a limited number of uses or unlimited.\n* Can have an expiry date, or never expire.\n\n## Laravel Support\n\n Laravel  | Doorman\n:---------|:----------\n 5.x      | 3.x\n 6.x      | 4.x\n 7.x      | 5.x\n 8.x      | 6.x\n 9.x      | 7.x\n 10.x     | 8.x\n 11.x     | 9.x\n 12.x     | 10.x\n\n## Installation\n\nYou can pull in the package using [composer](https://getcomposer.org):\n\n```bash\n$ composer require \"clarkeash/doorman=^10.0\"\n```\n\nNext, migrate the database:\n\n```bash\n$ php artisan migrate\n```\n\n## Usage\n\n### Generate Invites\n\nMake a single generic invite code with 1 redemption, and no expiry.\n```php\nDoorman::generate()-\u003emake();\n```\n\nMake 5 generic invite codes with 1 redemption each, and no expiry.\n```php\nDoorman::generate()-\u003etimes(5)-\u003emake();\n```\n\nMake an invite with 10 redemptions and no expiry.\n```php\nDoorman::generate()-\u003euses(10)-\u003emake();\n```\n\nMake an invite with unlimited redemptions and no expiry.\n```php\nDoorman::generate()-\u003eunlimited()-\u003emake();\n```\n\nMake an invite that expires on a specific date.\n```php\n$date = Carbon::now('UTC')-\u003eaddDays(7);\nDoorman::generate()-\u003eexpiresOn($date)-\u003emake();\n```\n\nMake an invite that expires in 14 days.\n```php\nDoorman::generate()-\u003eexpiresIn(14)-\u003emake();\n```\n\nMake an invite for a specific person.\n```php\nDoorman::generate()-\u003efor('me@ashleyclarke.me')-\u003emake();\n```\n\nAlternatively instead of calling `make()` which will return a collection of invites you can call `once()` if you only want a single invite generated.\n```php\n$invite = Doorman::generate()-\u003efor('me@ashleyclarke.me')-\u003eonce();\ndd($invite-\u003ecode);\n```\n\n\n### Redeem Invites\n\nYou can redeem an invite by calling the ````redeem```` method. Providing the invite code and optionally an email address.\n\n```php\nDoorman::redeem('ABCDE');\n// or\nDoorman::redeem('ABCDE', 'me@ashleyclarke.me');\n```\n\nIf doorman is able to redeem the invite code it will increment the number of redemptions by 1, otherwise it will throw an exception.\n\n* ````InvalidInviteCode```` is thrown if the code does not exist in the database.\n* ````ExpiredInviteCode```` is thrown if an expiry date is set and it is in the past.\n* ````MaxUsesReached```` is thrown if the invite code has already been used the maximum number of times.\n* ````NotYourInviteCode```` is thrown if the email address for the invite does match the one provided during redemption, or one was not provided during redemption.\n\nAll of the above exceptions extend ````DoormanException```` so you can catch that exception if your application does not need to do anything specific for the above exceptions.\n\n```php\ntry {\n    Doorman::redeem(request()-\u003eget('code'), request()-\u003eget('email'));\n} catch (DoormanException $e) {\n    return response()-\u003ejson(['error' =\u003e $e-\u003egetMessage()], 422);\n}\n```\n\n### Check Invites without redeeming them\n\nYou can check an invite by calling the ````check```` method. Providing the invite code and optionally an email address. (It has the same signature as the ````redeem```` method except it will return ````true```` or ````false```` instead of throwing an exception.\n\n```php\nDoorman::check('ABCDE');\n// or\nDoorman::check('ABCDE', 'me@ashleyclarke.me');\n```\n\n### Change Error Messages (and translation support)\n\nIn order to change the error message returned from doorman, we need to publish the language files like so:\n\n```bash\n$ php artisan vendor:publish --tag=doorman-translations\n```\n\nThe language files will then be in ````/resources/lang/vendor/doorman/en```` where you can edit the ````messages.php```` file, and these messages will be used by doorman. You can create support for other languages by creating extra folders with a ````messages.php```` file in the ````/resources/lang/vendor/doorman```` directory such as ````de```` where you could place your German translations. [Read the localisation docs for more info](https://laravel.com/docs/localization).\n\n### Validation\n\nIf you would perfer to validate an invite code before you attempt to redeem it or you are using [Form Requests](https://laravel.com/docs/5.4/validation#form-request-validation) then you can validate it like so:\n\n```php\npublic function store(Request $request)\n{\n    $this-\u003evalidate($request, [\n        'email' =\u003e 'required|email|unique:users',\n        'code' =\u003e ['required', new DoormanRule($request-\u003eget('email'))],\n    ]);\n\n    // Add the user to the database.\n}\n```\n\nYou should pass the email address into the constructor to validate the code against that email. If you know the code can be used with any email, then you can leave the parameter empty.\n\n### Config - change table name\n\nFirst publish the package configuration:\n\n```bash\n$ php artisan vendor:publish --tag=doorman-config\n```\n\nIn `config/doorman.php` you will see:\n\n```php\nreturn [\n    'invite_table_name' =\u003e 'invites',\n];\n```\n If you change the table name and then run your migrations Doorman will then use the new table name.\n \n ### Console\n \n To remove used and expired invites you can use the `cleanup` command:\n \n ```bash\n$ php artisan doorman:cleanup\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclarkeash%2Fdoorman","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclarkeash%2Fdoorman","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclarkeash%2Fdoorman/lists"}