小编ran*_*yup的帖子

在yii2中放置beforesave函数的位置,如何在控制器中访问

我想在我的应用程序中使用make signup功能,如何使用yii2创建哈希密码.

这是我的user.php

<?php

namespace app\models;

use Yii;
use yii\base\NotSupportedException;
use yii\db\ActiveRecord;
use yii\base\Security;
use yii\web\IdentityInterface;
/**
 * This is the model class for table "users".
 *
 * @property string $userid
 * @property string $username
 * @property string $password
 */

class User extends ActiveRecord  implements IdentityInterface
    {

        public static function tableName()
        {
            return 'users';
        }

        /**
         * @inheritdoc
         */
        public function rules()
        {
            return [
                [['username', 'password', 'password_hash','auth_key', 'password_reset_token'], 'required'],
                [['username', 'password'], 'string', 'max' => 45],
                [['auth_key'], 'string', 'max' => …
Run Code Online (Sandbox Code Playgroud)

php authentication yii2

10
推荐指数
1
解决办法
2万
查看次数

如何删除url(/web/index.php)yii 2并使用带有干净url的参数设置路由?

第一个问题:我已经删除了index.php,但我/web也想删除.这是我的.htaccess

RewriteEngine on
# If a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward it to index.php
RewriteRule . index.php
Run Code Online (Sandbox Code Playgroud)

这是 config/web.php

'urlManager' => [
            'class' => 'yii\web\UrlManager',
            // Disable index.php
            'showScriptName' => false,
            // Disable r= routes
            'enablePrettyUrl' => true,
            'rules' => array(
                    '<controller:\w+>/<id:\d+>' => '<controller>/view',
                    '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
                    '<controller:\w+>/<action:\w+>' => '<controller>/<action>',
            ),
        ],
Run Code Online (Sandbox Code Playgroud)

它工作正常,但它仍在使用/web.可以删除/web吗?

第二个问题:

我无法使用干净的网址,我的路线设置带参数的路线 Url::toRoute(['transaction/getrequestdetail/', 'id' => 1 …

php .htaccess clean-urls yii2 yii-url-manager

4
推荐指数
1
解决办法
1万
查看次数