lyrasoft / warder
A use package for Windwalker.
Installs: 14 012
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 4
Forks: 1
Open Issues: 30
Requires
- lyrasoft/unidev: ~1.0
- windwalker/phoenix: ~1.0
Suggests
- hybridauth/hybridauth: Install 2.* to support social login.
- 1.7.18
- 1.7.17
- 1.7.16
- 1.7.15
- 1.7.14
- 1.7.13
- 1.7.12
- 1.7.11
- 1.7.10
- 1.7.9
- 1.7.8
- 1.7.7
- 1.7.6
- 1.7.5
- 1.7.4
- 1.7.3
- 1.7.2
- 1.7.1
- 1.7
- 1.6.3
- 1.6.2
- 1.6.1
- 1.6
- 1.5.1
- 1.5
- 1.4.5
- 1.4.4
- 1.4.3
- 1.4.2
- 1.4.1
- 1.4
- 1.3.6
- 1.3.5
- 1.3.4
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3
- dev-master / 1.2.x-dev
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2
- 1.1.6
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1
- 1.1-alpha
- 1.0.12
- 1.0.11
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- 1.0.0-beta
- dev-3to4
This package is auto-updated.
Last update: 2024-10-13 18:15:53 UTC
README
Installation Via Composer
Add this to composer.json
and run composer update
.
{ "windwalker/warder": "1.*" }
Register Package
Register warder to Windwalker, you can prepare an admin
and front
package to support backend and frontend.
// src/Windwalker/Windwalker.php use Phoenix\PhoenixPackage; use Lyrasoft\Warder\WarderPackage; // ... public static function loadPackages() { return array( 'system' => new SystemPackage, 'phoenix' => new PhoenixPackage, // You must install phoenix first 'warder' => new WarderPackage, // Add warder package // Prepare an admin and frontend package 'admin' => AdminPackage, 'front' => FrontPackage ); } // ...
Migration
Run php bin/console migration migrate -p=warder --seed
Or copy vendor/windwalker/warder/src/Migration
and vendor/windwalker/warder/src/Seed
files to
resources/migration
and resources/seed
You can add your own columns to support more profiles.
Copy Config
Copy vendor/windwalker/warder/src/config.dist.yml
to etc/package/warder.yml
.
Or copy this config code:
user: login_name: username default_group: registered session_name: user table: users: users user_socials: user_socials groups: groups user_group_maps: user_group_maps actions: actions methods: warder: \Lyrasoft\Warder\Authentication\Method\WarderMethod # social: \Lyrasoft\Warder\Authentication\Method\SocialMethod frontend: package: front view: extends: _global.html redirect: login: home logout: login forget: login login: return_key: return language: prefix: warder. admin: package: admin view: extends: _global.admin.admin redirect: login: home logout: login login: return_key: return language: prefix: warder. class: handler: Lyrasoft\Warder\Handler\UserHandler data: Lyrasoft\Warder\Data\UserData
If your package not named admin
and front
, set the package alias in this config.
Register Routing
Add Warder's routing config and namespace aliases to your package that your package can auto fetch Warder pages.
// src/Front/FrontPackage.php use Lyrasoft\Warder\Helper\WarderHelper; // ... // ... public function loadRouting() { // ... $routes = array_merge($routes, WarderHelper::getFrontendRouting()); return $routes; }
Now go to /{front@routing}/login
your will see a login page auto fetched.
You can do same thing to admin
package
// src/Admin/AdminPackage.php // ... public function loadRouting() { // ... $routes = array_merge($routes, WarderHelper::getAdminRouting()); return $routes; } // ...
Then you can see User admin at /{admin@routing}/users
:
Override Objects and Templates
You can override warder's objects in your package. For example, create Front/Controller/User/LoginGetController.php
will load priority than Windwalker/Warder/Controller/User/LoginGetController.php
. You can override something in this class.
<?php namespace Front\Controller\User; class LoginGetController extends \Lyrasoft\Warder\Controller\User\LoginGetController { protected function prepareModelState(Model $repository) { // Do something parent::prepareModelState($repository); } }
These files can be override:
Front:
# Controller
src/Controller/User/AuthController.php
src/Controller/User/Forget/CompleteGetController.php
src/Controller/User/Forget/ConfirmGetController.php
src/Controller/User/Forget/ConfirmSaveController.php
src/Controller/User/Forget/RequestGetController.php
src/Controller/User/Forget/RequestSaveController.php
src/Controller/User/Forget/ResetGetController.php
src/Controller/User/Forget/ResetSaveController.php
src/Controller/User/LoginGetController.php
src/Controller/User/LoginSaveController.php
src/Controller/User/LogoutSaveController.php
src/Controller/User/Profile/GetController.php
src/Controller/User/Profile/SaveController.php
src/Controller/User/Registration/ActivateSaveController.php
src/Controller/User/Registration/RegistrationGetController.php
src/Controller/User/Registration/RegistrationSaveController.php
src/Controller/User/SocialLoginController.php
# Form
src/Form/Profile/EditDefinition.php
src/Form/User/ForgetConfirmDefinition.php
src/Form/User/ForgetRequestDefinition.php
src/Form/User/LoginDefinition.php
src/Form/User/RegistrationDefinition.php
src/Form/User/ResetDefinition.php
# Model
src/Model/ProfileModel.php
src/Model/UserModel.php
# Template
src/Templates/profile/profile.blade.php
src/Templates/user/forget/complete.blade.php
src/Templates/user/forget/confirm.blade.php
src/Templates/user/forget/request.blade.php
src/Templates/user/forget/reset.blade.php
src/Templates/user/login.blade.php
src/Templates/user/mail/forget.blade.php
src/Templates/user/mail/registration.blade.php
src/Templates/user/registration.blade.php
# View
src/View/Profile/ProfileHtmlView.php
src/View/User/UserHtmlView.php
Admin:
# Controller
src/Admin/Controller/User/GetController.php
src/Admin/Controller/User/LoginGetController.php
src/Admin/Controller/User/LoginSaveController.php
src/Admin/Controller/User/LogoutSaveController.php
src/Admin/Controller/User/SaveController.php
src/Admin/Controller/Users/Batch/ActivateController.php
src/Admin/Controller/Users/Batch/BlockController.php
src/Admin/Controller/Users/Batch/UnblockController.php
src/Admin/Controller/Users/Batch/UpdateController.php
src/Admin/Controller/Users/BatchController.php
src/Admin/Controller/Users/CopyController.php
src/Admin/Controller/Users/DeleteController.php
src/Admin/Controller/Users/FilterController.php
src/Admin/Controller/Users/GetController.php
# Form
src/Admin/Form/User/EditDefinition.php
src/Admin/Form/User/LoginDefinition.php
src/Admin/Form/Users/BatchDefinition.php
src/Admin/Form/Users/FilterDefinition.php
# Model
src/Admin/Model/UserModel.php
# Templates
src/Admin/Templates/user/login.blade.php
src/Admin/Templates/user/toolbar.blade.php
src/Admin/Templates/user/user.blade.php
src/Admin/Templates/users/batch.blade.php
src/Admin/Templates/users/modal.blade.php
src/Admin/Templates/users/toolbar.blade.php
src/Admin/Templates/users/users.blade.php
# View
src/Admin/View/User/UserHtmlView.php
src/Admin/View/Users/UsersHtmlView.php
Override UserHandler and UserData
Change class.data
in config file that you can add some new methods:
# etc/package/warder.yml # ... class: handler: Lyrasoft\Warder\Handler\UserHandler data: MyUserData
class MyUserData extends \Lyrasoft\Warder\Data\UserData { const CUSTOMER = 0; const FREELANCER = 1; public function isFreelancer() { return (bool) $this->freelancer == static::FREELANCER; } }
$user = User::get($id); $user->isFreelancer();
Social Login
Warder use Hybrid Auth to support multiple OAuth social login.
Please install "hybridauth/hybridauth": "^2.6"
first.
After composer updated, copy vendor/wainwaler/warder/src/secret.dist.yml
to etc/secret.yml
#Social Login social_login: facebook: enabled: false id: secret: scope: email twitter: enabled: false key: secret: scope: google: enabled: false id: secret: scope: 'https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email' yahoo: enabled: false key: secret: scope: github: enabled: false id: secret: scope:
Currently Warder only support facebook, twitter, google, yahoo and github.
Go to Documentation to see how to register apps and get API key and secret code.
When a social provider set to enabled, the button will auto appear to login page:
If you use
Additional Providers
likeGitHub
, you must copy provider class file fromvendor/hybridauth/hybridauth/additional-providers
tovendor/hybridauth/hybridauth/hybridauth/Hybrid/Providers