{"id":20459512,"url":"https://github.com/ahsankhatri/wordpress-auth-driver-laravel","last_synced_at":"2025-08-21T07:32:51.522Z","repository":{"id":48530648,"uuid":"106423161","full_name":"ahsankhatri/wordpress-auth-driver-laravel","owner":"ahsankhatri","description":"A package to provide wordpress users in laravel authentication system.","archived":false,"fork":false,"pushed_at":"2021-07-21T12:33:32.000Z","size":25,"stargazers_count":52,"open_issues_count":3,"forks_count":36,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-08-13T20:10:47.234Z","etag":null,"topics":["laravel","laravel-authorization","laravel-guard","laravel-package","php","wordpress"],"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/ahsankhatri.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2017-10-10T13:46:45.000Z","updated_at":"2024-05-15T03:28:34.000Z","dependencies_parsed_at":"2022-09-22T14:25:43.843Z","dependency_job_id":null,"html_url":"https://github.com/ahsankhatri/wordpress-auth-driver-laravel","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/ahsankhatri/wordpress-auth-driver-laravel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahsankhatri%2Fwordpress-auth-driver-laravel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahsankhatri%2Fwordpress-auth-driver-laravel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahsankhatri%2Fwordpress-auth-driver-laravel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahsankhatri%2Fwordpress-auth-driver-laravel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ahsankhatri","download_url":"https://codeload.github.com/ahsankhatri/wordpress-auth-driver-laravel/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahsankhatri%2Fwordpress-auth-driver-laravel/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271444409,"owners_count":24760799,"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-21T02:00:08.990Z","response_time":74,"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":["laravel","laravel-authorization","laravel-guard","laravel-package","php","wordpress"],"created_at":"2024-11-15T12:16:19.298Z","updated_at":"2025-08-21T07:32:51.251Z","avatar_url":"https://github.com/ahsankhatri.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Wordpress Auth Driver for Laravel\n\n[![Latest Stable Version](https://poser.pugx.org/ahsankhatri/wordpress-auth-provider/v/stable)](https://packagist.org/packages/ahsankhatri/wordpress-auth-provider) [![Total Downloads](https://poser.pugx.org/ahsankhatri/wordpress-auth-provider/downloads)](https://packagist.org/packages/ahsankhatri/wordpress-auth-provider) [![Build Status](https://scrutinizer-ci.com/g/ahsankhatri/wordpress-auth-driver-laravel/badges/build.png?b=master)](https://scrutinizer-ci.com/g/ahsankhatri/wordpress-auth-driver-laravel/build-status/master) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/ahsankhatri/wordpress-auth-driver-laravel/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/ahsankhatri/wordpress-auth-driver-laravel/?branch=master) [![Code Intelligence Status](https://scrutinizer-ci.com/g/ahsankhatri/wordpress-auth-driver-laravel/badges/code-intelligence.svg?b=master)](https://scrutinizer-ci.com/code-intelligence) [![License](https://poser.pugx.org/ahsankhatri/wordpress-auth-provider/license)](https://packagist.org/packages/ahsankhatri/wordpress-auth-provider)\n\n| **Laravel**  |  **wordpress-auth-driver-laravel** |\n|---|---|\n| 5.2 to 5.5    | ^1.0  |\n| 5.6 to 8.x  | ^2.0  |\n\n## Installation\n\nTo install this package you will need\n  - At least Laravel 5.6 ([for older versions of laravel](https://github.com/ahsankhatri/wordpress-auth-driver-laravel/tree/v1))\n  - PHP 7.1 (or depending on your Laravel version)\n\nThe best way to install this package is with the help of composer. Run\n```\ncomposer require ahsankhatri/wordpress-auth-provider\n```\n\nor install it by adding it to `composer.json` then run `composer update`\n```\n\"require\": {\n    \"ahsankhatri/wordpress-auth-provider\": \"^2.0\",\n}\n```\n\n## Setup\n\nOnce you have installed this package from the [composer](https://packagist.org/packages/ahsankhatri/wordpress-auth-provider), make sure to follow the below steps to configure.\n\nTo register authentication guard.\n\n##### config/auth.php\n```php\n'guards' =\u003e [\n    ...,\n    'wordpress' =\u003e [\n        'driver' =\u003e 'session',\n        'provider' =\u003e 'wordpress',\n    ],\n```\n\n```php\n'providers' =\u003e [\n    ...,\n    'wordpress' =\u003e [\n        'driver' =\u003e 'eloquent.wordpress',\n        'model' =\u003e MrShan0\\WordpressAuth\\Models\\WordpressUser::class,\n    ],\n```\n\n```php\n'passwords' =\u003e [\n    ...,\n    'wordpress' =\u003e [\n        'provider' =\u003e 'wordpress',\n        'table' =\u003e 'password_resets',\n        'expire' =\u003e 60,\n    ],\n```\n\n#### Publish config file (optional)\n```bash\nphp artisan vendor:publish --provider=\"MrShan0\\WordpressAuth\\WordpressAuthServiceProvider\"\n```\n\nIt will publish config file (`config/wordpress-auth.php`) where you can define your own connection type e.g `wp-mysql`. Make sure to fill `prefix` in `config/database.php` for `wp_` prefix in your tables if you're using prefix in wordpress tabels.\n\nFor example:\n```php\n'wp-mysql' =\u003e [\n    'driver' =\u003e 'mysql',\n    'host' =\u003e env('WP_DB_HOST', '127.0.0.1'),\n    'port' =\u003e env('WP_DB_PORT', '3306'),\n    'database' =\u003e env('WP_DB_DATABASE', 'forge'),\n    'username' =\u003e env('WP_DB_USERNAME', 'forge'),\n    'password' =\u003e env('WP_DB_PASSWORD', ''),\n    'unix_socket' =\u003e env('WP_DB_SOCKET', ''),\n    'charset' =\u003e 'utf8mb4',\n    'collation' =\u003e 'utf8mb4_unicode_ci',\n    'prefix' =\u003e 'wp_',\n    'prefix_indexes' =\u003e true,\n    'strict' =\u003e true,\n    'engine' =\u003e null,\n],\n```\n\nAdd following option along if using Laravel v7 (optional)\n```php\n    // ...\n    'url' =\u003e env('DATABASE_URL'),\n    'options' =\u003e extension_loaded('pdo_mysql') ? array_filter([\n        PDO::MYSQL_ATTR_SSL_CA =\u003e env('MYSQL_ATTR_SSL_CA'),\n    ]) : [],\n```\n\n## Configuration\n\n`password_resets` table (from Laravel default auth mechanism) is required to hold reset password token. If you do not have `password_resets` table then use this migration instead\n```\n\u003c?php\n\nuse Illuminate\\Support\\Facades\\Schema;\nuse Illuminate\\Database\\Schema\\Blueprint;\nuse Illuminate\\Database\\Migrations\\Migration;\n\nclass CreatePasswordResetsTable extends Migration\n{\n    /**\n     * Run the migrations.\n     *\n     * @return void\n     */\n    public function up()\n    {\n        Schema::create('password_resets', function (Blueprint $table) {\n            $table-\u003estring('email')-\u003eindex();\n            $table-\u003estring('token');\n            $table-\u003etimestamp('created_at')-\u003enullable();\n        });\n    }\n\n    /**\n     * Reverse the migrations.\n     *\n     * @return void\n     */\n    public function down()\n    {\n        Schema::dropIfExists('password_resets');\n    }\n}\n```\n\n## Extension\nAlternatively, if you want to use a custom user model, you should have it extend `MrShan0\\WordpressAuth\\Models\\WordpressUser` and specify the name of your model in `config/auth.php` under `providers` -\u003e `wordpress` -\u003e `model`.\n\n## Customization\nIf you've renamed your `user_email` column of wordpress database, you need to first publish configurations of this package if you've not already, extend the model as mentioned above and make sure you've override your changes in your `$fillable` property and `config/wordpress-auth.php` config file which is being used for authentication scaffolding and sending notifications.\n\n## Usage\nYou need to define `wordpress` **guard** explicitly to load the driver.\n### Examples\n```php\nAuth::guard('wordpress')-\u003eloginUsingId(5);\n\n// or login using email and password\nAuth::guard('wordpress')-\u003eattempt([\n    'user_email' =\u003e 'demo@example.com',\n    'user_pass' =\u003e 'quickbrownfox'\n]);\n\n// get user object\nAuth::guard('wordpress')-\u003euser();\n\n// Update wordpress compatible password\n$user-\u003euser_pass = app('wordpress-auth')-\u003emake('new_password');\n$user-\u003esave();\n\n// logout\nAuth::guard('wordpress')-\u003elogout();\n```\n\nYou may also change default guard in `config/auth.php` then your code will look like\n```php\nAuth::loginUsingId(5);\n```\n\nIf you haven't set default guard and wanted to take advantage of **Password Resets** (Auth Scaffolding) in laravel. You may need to define `guard` and `broker` explicitly in `Auth/ForgotPasswordController.php` and `Auth/ResetPasswordController.php` as\n\n```php\n/**\n * Get the broker to be used during password reset.\n *\n * @return \\Illuminate\\Contracts\\Auth\\PasswordBroker\n */\npublic function broker()\n{\n    return \\Password::broker('wordpress');\n}\n\n/**\n * Get the guard to be used during password reset.\n *\n * @return \\Illuminate\\Contracts\\Auth\\StatefulGuard\n */\nprotected function guard()\n{\n    return \\Auth::guard('wordpress');\n}\n```\n\n## Changelog\n\n[CHANGELOG](CHANGELOG.md)\n\n## Credits\n\nThanks to the community of [Laravel](https://www.laravel.com/).\n\n## Copyright and License\n\nCopyright (c) 2016 [Ahsaan Muhammad Yousuf](http://ahsaan.me/), [MIT](LICENSE) License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahsankhatri%2Fwordpress-auth-driver-laravel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fahsankhatri%2Fwordpress-auth-driver-laravel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahsankhatri%2Fwordpress-auth-driver-laravel/lists"}