Yii2. Access to higher level folder

Step : 1 First create .htaccess file in here yii-application1/.htaccess Options +FollowSymlinks RewriteEngine On # deal with backend first RewriteCond %{REQUEST_URI} /(backend) RewriteRule ^backend/assets/(.*)$ backend/web/assets/$1 [L] RewriteRule ^backend/css/(.*)$ backend/web/css/$1 [L] RewriteRule ^backend/image/(.*)$ backend/web/image/$1 [L] RewriteCond %{REQUEST_URI} !/backend/web/(assets|css|image)/ RewriteCond %{REQUEST_URI} /(backend) RewriteRule ^.*$ backend/web/index.php [L] RewriteCond %{REQUEST_URI} /(assets|css|js|img|font) RewriteRule ^assets/(.*)$ frontend/web/assets/$1 [L] RewriteRule ^css/(.*)$ frontend/web/css/$1 [L] … Read more

LIMIT is not working in ActiveDataProvider

Here is what happens when preparing models in yii\data\ActiveDataProvider: /** * @inheritdoc */ protected function prepareModels() { if (!$this->query instanceof QueryInterface) { throw new InvalidConfigException(‘The “query” property must be an instance of a class that implements the QueryInterface e.g. yii\db\Query or its subclasses.’); } $query = clone $this->query; if (($pagination = $this->getPagination()) !== false) { … Read more

Multiple database connections and Yii 2.0

First you need to configure your databases like below: return [ ‘components’ => [ ‘db1’ => [ ‘class’ => ‘yii\db\Connection’, ‘dsn’ => ‘mysql:host=localhost;dbname=db1name’, //maybe other dbms such as psql,… ‘username’ => ‘db1username’, ‘password’ => ‘db1password’, ], ‘db2’ => [ ‘class’ => ‘yii\db\Connection’, ‘dsn’ => ‘mysql:host=localhost;dbname=db2name’, // Maybe other DBMS such as psql (PostgreSQL),… ‘username’ => … Read more

Enable clean URL in Yii2

I got it working in yii2. Enable mod_rewrite for Apache. For basic template do the following: Create a .htaccess file in web folder and add this 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 Then … Read more