关于Yii2 前后台分离的讨论
Yii2 的高级应用程序模板是前后台分离的,我认真的研究了,我发现yii2 内置了User 组件,以及RBAC组件,该组件系统内置,我现在的需求是 前后台分离,那么后台用户和前台用户以及RBAC都是要分离的,可是我发现我分离后在后台无法管理前台的用户啊,总么办?
回复内容:
Yii2 的高级应用程序模板是前后台分离的,我认真的研究了,我发现yii2 内置了User 组件,以及RBAC组件,该组件系统内置,我现在的需求是 前后台分离,那么后台用户和前台用户以及RBAC都是要分离的,可是我发现我分离后在后台无法管理前台的用户啊,总么办?
可是我发现我分离后在后台无法管理前台的用户啊
不明白为什么管理不了~
好吧,从公用一个 User
组件说起:
yii\web\User
这个组件是可以分开使用的。例如你前后台分别有两个表对应两个ActiveRecord:
<code>class FrontUser extends ActiveRecord implements IdentityInterface { } class BackendUser extends ActiveRecord implements IdentityInterface { } </code>
那从配置开始我们就可以分别在前后台进行区分:
例如,后台配置 user
组件:
<code>'user' => [ 'identityClass' => 'common\models\BackendUser', //指定为后台用户AR ]</code>
而前台则需要指定 identityClass => 'common\models\FrontUser'
即可。
我就是按照你说的这样设置的,但是还是会出现问题,具体表现:前台已登录的用户退出之后,后台已登录的账户也跟着退出了。相应的,后台已登录的账户退出之后,前台已登录的用户也跟着退出了。请问,这是哪里错了?

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



PHP is used to build dynamic websites, and its core functions include: 1. Generate dynamic content and generate web pages in real time by connecting with the database; 2. Process user interaction and form submissions, verify inputs and respond to operations; 3. Manage sessions and user authentication to provide a personalized experience; 4. Optimize performance and follow best practices to improve website efficiency and security.

PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning.

PHP uses MySQLi and PDO extensions to interact in database operations and server-side logic processing, and processes server-side logic through functions such as session management. 1) Use MySQLi or PDO to connect to the database and execute SQL queries. 2) Handle HTTP requests and user status through session management and other functions. 3) Use transactions to ensure the atomicity of database operations. 4) Prevent SQL injection, use exception handling and closing connections for debugging. 5) Optimize performance through indexing and cache, write highly readable code and perform error handling.

PHP is a server-side scripting language used for dynamic web development and server-side applications. 1.PHP is an interpreted language that does not require compilation and is suitable for rapid development. 2. PHP code is embedded in HTML, making it easy to develop web pages. 3. PHP processes server-side logic, generates HTML output, and supports user interaction and data processing. 4. PHP can interact with the database, process form submission, and execute server-side tasks.

PHP is suitable for web development and content management systems, and Python is suitable for data science, machine learning and automation scripts. 1.PHP performs well in building fast and scalable websites and applications and is commonly used in CMS such as WordPress. 2. Python has performed outstandingly in the fields of data science and machine learning, with rich libraries such as NumPy and TensorFlow.

You can query the Docker container name by following the steps: List all containers (docker ps). Filter the container list (using the grep command). Gets the container name (located in the "NAMES" column).

Steps to create a Docker image: Write a Dockerfile that contains the build instructions. Build the image in the terminal, using the docker build command. Tag the image and assign names and tags using the docker tag command.

The process of starting MySQL in Docker consists of the following steps: Pull the MySQL image to create and start the container, set the root user password, and map the port verification connection Create the database and the user grants all permissions to the database
