{"id":43003386,"url":"https://github.com/michelphp/php-user-authentication","last_synced_at":"2026-01-31T04:33:10.223Z","repository":{"id":49499615,"uuid":"138482835","full_name":"michelphp/php-user-authentication","owner":"michelphp","description":"a simple user authentication","archived":false,"fork":false,"pushed_at":"2021-01-28T11:23:18.000Z","size":20,"stargazers_count":8,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-12-21T16:07:42.460Z","etag":null,"topics":["authentication","authentification","php","session","user-interface","user-management"],"latest_commit_sha":null,"homepage":"","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/michelphp.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":"2018-06-24T13:09:40.000Z","updated_at":"2025-10-31T14:04:48.000Z","dependencies_parsed_at":"2022-08-21T06:10:21.958Z","dependency_job_id":null,"html_url":"https://github.com/michelphp/php-user-authentication","commit_stats":null,"previous_names":["phpdevcommunity/php-user-authentication","devcoder-xyz/php-user-authentication","michelphp/php-user-authentication"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/michelphp/php-user-authentication","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michelphp%2Fphp-user-authentication","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michelphp%2Fphp-user-authentication/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michelphp%2Fphp-user-authentication/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michelphp%2Fphp-user-authentication/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/michelphp","download_url":"https://codeload.github.com/michelphp/php-user-authentication/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michelphp%2Fphp-user-authentication/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28929701,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-31T04:05:25.756Z","status":"ssl_error","status_checked_at":"2026-01-31T04:02:35.005Z","response_time":128,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["authentication","authentification","php","session","user-interface","user-management"],"created_at":"2026-01-31T04:33:09.433Z","updated_at":"2026-01-31T04:33:10.214Z","avatar_url":"https://github.com/michelphp.png","language":"PHP","readme":"# PHP-user-authentication\n[![Latest Stable Version](https://poser.pugx.org/devcoder-xyz/php-user-authentication/v)](//packagist.org/packages/devcoder-xyz/php-user-authentication) [![Total Downloads](https://poser.pugx.org/devcoder-xyz/php-user-authentication/downloads)](//packagist.org/packages/devcoder-xyz/php-user-authentication) [![Latest Unstable Version](https://poser.pugx.org/devcoder-xyz/php-user-authentication/v/unstable)](//packagist.org/packages/devcoder-xyz/php-user-authentication) [![License](https://poser.pugx.org/devcoder-xyz/php-user-authentication/license)](//packagist.org/packages/devcoder-xyz/php-user-authentication)\n\n*PHP version required 7.3*\n\n**How to use ?**\n\n***Registration***\n```php\n\u003c?php\n\nuse DevCoder\\Authentication\\Core\\UserManager;\nuse DevCoder\\Authentication\\User;\n\n// register\n$userManager = new UserManager();\n\n$password = $userManager-\u003ecryptPassword($_POST['password']);\n$user = (new User())\n    -\u003esetUserName($_POST['username'])\n    -\u003esetPassword($password)\n    -\u003esetRoles(['ROLE_USER']);\n\n$userManager-\u003ecreateUserToken($user);\n\n// check Token in Session\nvar_dump($userManager-\u003egetUserToken());\n// object(DevCoder\\Authentication\\Token\\UserToken)[4]\n//  private 'user' =\u003e \n//    object(DevCoder\\Authentication\\User)[5]\n//      private 'userName' =\u003e string 'username' (length=8)\n//      private 'password' =\u003e string '$2y$10$iWdcmebmikUFlgKMqW7/rOmUp1DjFAuWKqdUHBhL08FZ7LL6bwRey' (length=60)\n//      private 'roles' =\u003e \n//        array (size=1)\n//          0 =\u003e string 'ROLE_USER' (length=9)\n//      private 'enabled' =\u003e boolean true\n\n```\n\n***Connected or not***\n```php\n\u003c?php\n\nuse DevCoder\\Authentication\\Core\\UserManager;\nuse DevCoder\\Authentication\\User;\n\n$userManager = new UserManager();\nif ($userManager-\u003ehasUserToken()) {\n    // connected\n\n    $token = $userManager-\u003egetUserToken();\n    $user = $token-\u003egetUser();\n    var_dump($user);\n// object(DevCoder\\Authentication\\User)[5]\n//  private 'userName' =\u003e string 'username' (length=8)\n//  private 'password' =\u003e string '$2y$10$OBobeLhdvdiftuedlv1a6e4.qF6sCG/usq5WEV4E3uB.UiS1egv/m' (length=60)\n//  private 'roles' =\u003e \n//    array (size=1)\n//      0 =\u003e string 'ROLE_USER' (length=9)\n//  private 'enabled' =\u003e boolean true\n\n}else {\n    // not connected\n}\n```\n***Access management***\n\n```php\n$userManager = new UserManager();\nif ($userManager-\u003eisGranted(['ROLE_ADMIN'])) {\n    //is admin\n    // return Response 200\n}else {\n    //is not admin\n    // return Response 403\n}\n```\n\n***Logout***\n\n```php\n$userManager = new UserManager();\n$userManager-\u003elogout();\n```\n\n***Login***\n\n```php\n\u003c?php\n\nuse DevCoder\\Authentication\\Core\\UserManager;\n\n$stmt = $pdo-\u003eprepare(\"SELECT * FROM users WHERE username=?\");\n$stmt-\u003eexecute([$_POST['username']]);\n$userFromDataBase = $stmt-\u003efetch();\n/**\n * Hydration\n */\n$user = (new \\Test\\DevCoder\\Authentication\\User())\n    -\u003esetUserName($userFromDataBase['username'])\n    -\u003esetPassword($userFromDataBase['password'])\n    -\u003esetRoles(json_decode($userFromDataBase['roles']))\n    -\u003esetEnabled($userFromDataBase['active']);\n\n$userManager = new UserManager();\nif ($userManager-\u003eisPasswordValid($user, $_POST['password'])) {\n\n    // login OK, set Token in session\n    $userManager-\u003ecreateUserToken($user);\n\n}else {\n // login failed , return error\n}\n```\n\nIdeal for small project\nSimple and easy!\n[https://github.com/devcoder-xyz/php-user-authentication](https://github.com/devcoder-xyz/php-user-authentication)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichelphp%2Fphp-user-authentication","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmichelphp%2Fphp-user-authentication","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichelphp%2Fphp-user-authentication/lists"}