-
Notifications
You must be signed in to change notification settings - Fork 59
2. Advanced Installation
By default Podium takes care of user identity which means that users can register and sign in independently from the main application - remember that user signed in to the application will not be signed in to the Podium and vice versa.
This configuration is useful for applications where the forum should be separated from the rest of the modules or, in most cases, Podium should be the main application.
If you would like Podium to inherit user application's identity (so users signed in to the application will be signed in to the Podium as well) modify the application configuration as following:
'bootstrap' => ['log', 'podium'],
'components' => [
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=host_address;dbname=database_name',
'username' => 'username',
'password' => 'password',
'charset' => 'utf8',
],
],
'modules' => [
'podium' => [
'class' => 'bizley\podium\Podium',
'userComponent' => 'user',
'adminId' => 1,
],
],
-
userComponent
withuser
value tells Podium to inherit user identity usinguser
component already defined in the configuration, -
adminId
is the database ID of existing user that should be the main Podium administrator - in most cases it should be the ID of your application's account.
Like with any other Yii 2 component or module you can rename Podium to whatever you want. For example if podium
should be identified by name chimichanga
modify the configuration:
'bootstrap' => ['log', 'chimichanga'], // <------------------------ here
'modules' => [
'chimichanga' => [ // <------------------------------------ and here
'class' => 'bizley\podium\Podium', <------ DON'T change it here!
],
],
Remember that now all the URLs are renamed as well so instead of going to podium/install/run
you should type chimichanga/install/run
.
The same applies to the console configuration but you are not required to change it in both places.
accessChecker
option allows to set Podium access for user. This is anonymous function with signature function ($user)
where $user
is the User component and it should return integer
value indicating one of the following access types:
-
1
for "member" access where viewing, signing in and registering is allowed (default type). -
0
for "guest" access where only anonymous viewing is allowed. -
-1
for no access.
In addition denyCallback
option can be set to be called when access is denied. This is also anonymous function with signature function ($user)
where $user
is the User component.
userComponent
option configures Podium's identity mechanism and can take three types of values:
-
boolean
true
for own Podium component configuration (default):
[
'class' => 'bizley\podium\web\User',
'identityClass' => 'bizley\podium\models\User',
'enableAutoLogin' => true,
'loginUrl' => $this->loginUrl,
'identityCookie' => [
'name' => 'podium',
'httpOnly' => true,
'secure' => $this->secureIdentityCookie,
],
'idParam' => '__id_podium',
]
-
string with inherited component ID:
Usually this component's ID isuser
. -
array with custom configuration.
Remember that user component must contain identityClass
key with the class implementing yii\web\IdentityInterface
.
rbacComponent
option configures Podium's Role-Based Access Control mechanism and can take three types of values:
-
boolean
true
for own Podium component configuration (default):
[
'class' => 'yii\rbac\DbManager',
'db' => $this->db,
'itemTable' => '{{%podium_auth_item}}',
'itemChildTable' => '{{%podium_auth_item_child}}',
'assignmentTable' => '{{%podium_auth_assignment}}',
'ruleTable' => '{{%podium_auth_rule}}',
'cache' => $this->cache
]
-
string with inherited component ID:
Usually this component's ID isauthManager
. -
array with custom configuration.
In case of using custom component Podium adds its own roles and permissions to existing DB tables. Because of that Podium supports only DbManager
type of this component.
formatterComponent
option configures Podium's time zones converting mechanism and can take three types of values:
-
boolean
true
for own Podium component configuration (default):
[
'class' => 'yii\i18n\Formatter',
'timeZone' => 'UTC',
]
-
string with inherited component ID:
Usually this component's ID isformatter
. -
array with custom configuration.
Set this in case you have got formatter
already configured.
dbComponent
option configures Podium's database connection mechanism and can take two types of values:
-
string with inherited component ID (default with value
db
):
Usually this component's ID isdb
and Podium takes it as it is. -
array with custom configuration.
cacheComponent
option configures Podium's cache mechanism and can take three types of values:
-
boolean
false
for not using any cache (default): -
string with inherited component ID:
Usually this component's ID iscache
. -
array with custom configuration.
In case of setting this to default false
Podium uses yii\caching\DummyCache
to mock all cache calls.
adminId
option can be used in case of setting custom user component.
During the Podium installation new Administrator account is being connect with the existing user account of this ID.
Notice: if exisiting account with this ID cannot be found Administrator account is not created. The only option to add Administrator account in such case is to visit any Podium page while being logged in so Podium account will be automatically created and then to update this account's database row with
role
set to10
.
adminId
is ignored if userComponent
is set to true
.
allowedIPs
option holds the list of IP addresses that are allowed to access Installation mode of Podium.
Default value is ['127.0.0.1', '::1']
so only local addresses are permitted.
In case of installing Podium on a remote server add you IP address to this list.
userPasswordField
option holds the name of database field where the existing user account's password hash is stored.
In case of inherited user identity there is no option to change user's data but changing the forum profile is still possible. Since every change must be confirmed by entering account's password Podium needs to know this field's name.
Default value is password_hash
.
userPasswordField
is ignored if userComponent
is set to true
.
secureIdentityCookie
is boolean option for the identity cookie being sent as secure or not in case of setting userComponent
to true
.
Default value is false
.
You can set urlManager to skip module name part of the URL (default podium
) if Podium is your main application.
Add '' => 'podium',
to the components > urlManager > rules
part of the configuration file.
See The Definitive Guide to Yii 2.0: URL Rules for more information.
yii2-podium | Yii 2 Forum module | Basic Installation | Advanced Installation