How to Create Custom Component in Yii Framework
Yii framework having default application components and it is giving different type services.
#Example: ‘urlManager’ component, ‘db’ component etc.
Every application component has an uniqueID and will call through expression format.
We can create Application components like global or local variables.
You may also like - Yii Interview Questions Answers
- Core Components
- Custom Components
Core Application Components Examples
- Create a folder named "components" in the project common folder.
- Now create one class FullStackTutorialsComponent with extends class ‘Component’ inside the components folder.Using this component, we will display message.
- Please see the below code to create a custom component class.
- Config Component In Yii2 We have to register 'FullStackTutorialsComponent' inside the common/config/main.php or common/config/main-local.php file.
- Call Yii2 Custom Component Function in Yii Framework Now we can access this component using ‘Yii::$app->fullstacktutorials’ expression
You may also like - PHP Interview Questions Answers