Skip to content
This repository has been archived by the owner on Dec 3, 2018. It is now read-only.

2. Advanced Installation

Bizley edited this page Jan 29, 2017 · 2 revisions

Inherited User Identity

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 with user value tells Podium to inherit user identity using user 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.

Other configuration options

Podium under different name

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.

Access checker

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.

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 is user.

  • array with custom configuration.

Remember that user component must contain identityClass key with the class implementing yii\web\IdentityInterface.

RBAC component

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 is authManager.

  • 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.

Formatter 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 is formatter.

  • array with custom configuration.

Set this in case you have got formatter already configured.

DB connection component

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 is db and Podium takes it as it is.

  • array with custom configuration.

Cache component

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 is cache.

  • array with custom configuration.

In case of setting this to default false Podium uses yii\caching\DummyCache to mock all cache calls.

Administrator ID

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 to 10.

adminId is ignored if userComponent is set to true.

Installation on a remote server

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.

Updating inherited user account's profile

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.

Secure identity Cookie

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.

Miscellaneous

Skipping module name in the URLs

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.