Yii2 starts the Restful style API interface, which is used for front-end and back-end separation projects or external third-party API interfaces.

Use advanced Yii2 template: yii2-app-advanced Reason: Establishing Restful’s Api is equivalent to an independent project, such as backend (backend) and frontend (frontend). Because the Api and the backend project are familiar with each other, only the encapsulation method is exposed to the outside world, so you need to copy the backend and re- Name it […]

Yii caching mechanism yii\caching\Cache

1: Cache component configuration Commonly used caching methods in Yii include yii\caching\FileCache: file cache yii\caching\ApcCache: APC cache, you need to install the APC extension of PHP yii\caching\DbCache: database cache, you need to create a cache table /** * {@inheritdoc} */ public function safeUp() { $this->createTable(‘{<!– –>{?che}}’, [ ‘id’ => $this->char(128)->defaultValue(”)->comment(‘cache ID’), ‘expire’ => $this->integer()->defaultValue(0)->comment(‘Expiration time’), […]

Yii2 query data and export Excel code example

The requirement is to query the summary of order overdue fees in the timeout record information table (one order generates multiple overdue fees, and sum the overdue fees into one) and left-link the order table to query whether the order is out of the warehouse Export Excel plug-in installation: composer require phpoffice/phpspreadsheet Controller: <?php namespace […]

[Solved] The solution of jquery.yiitab.js error report in yii1.1

This problem exists in all versions of yii1.1 activate(href) is modified to activate(‘>ul a[href=”‘ + href + ‘”]’); activate(id) is modified to activate(‘>ul a[href=”‘ + id + ‘”]’); Modified as follows /** * jQuery Yii plugin file. * * @author Qiang Xue , beauty of code * @link http://www.yiiframework.com/ * @copyright 2008-2013 Yii Software LLC […]

[Solved] Solve the error Call to a member function redirect() on string after Yii2 framework upgrade – Yii2 v2.0.36

After the Yii2 framework was upgraded to a new version, when I inherited init in the controller and wrote some custom code public function init() { $someCondition = myBoolFunction(); if ($someCondition) { return $this->redirect(‘my/url’)); } } prompt error Call to a member function redirect() on string Look at the init method of the parent class […]

[Solved] Install yii2 problems & solutions

Install yii via composer Install composer first: 1. Download and run Composer-Setup.exe 2. Run the following script in the terminal php -r “copy(‘https://getcomposer.org/installer’, ‘composer-setup.php’);” php -r “if (hash_file(‘sha384’, ‘composer-setup.php’) === ’55ce33d7678c5a611085589f1f3ddf8b3c52d662cd01d4ba75c0ee0459970c2200a51f492d557530c71c15d8dba01eae’) { echo ‘Installer verified’; } else { echo ‘Installer corrupt’; unlink(‘composer-setup. php’); } echo PHP_EOL;” php composer-setup.php php -r “unlink(‘composer-setup.php’);” The installation in windows […]