Posts Tagged with name

Displaying 1-7 of 7 results.
Resolved: Yii2 showScriptName remove index.php Not Found apache
posted by admin on June 2, 2017
I tried to remove index.php from url by many ways, but without results.
My OS is Ubuntu Linux.
Server Apache.
In web.php in config directory

$config = [
'components' => [
'urlManager' => [
'class' => 'yii\web\UrlManager',
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
'/' => 'site/index',
'login' => 'site/login',
'<controller:\w+>/<id:\d+>' => '<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',

Still not working
I try to created .htaccess in web direcory

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

Still without result
In result
404 Not Found

Not Found

The requested URL /login was not found on this server.

Apache/2.4.18 (Ubuntu) Server at Port 80

Please help me to resolve problemRead more
Resolved: Yii2 Error Exception: Class 'Custom class' not found
posted by admin on February 15, 2017
I use in migration classes custom helper class Table, and in migration up process got an error like

./yii migrate

Result until error

Yii Migration Tool (based on Yii v2.0.11.2)

Total 2 new migrations to be applied:

Apply the above migrations? (yes|no) [no]:yes
*** applying m170213_124818_init

Error Message:

Exception: Class 'yii\helpers\Table' not found (/var/www/html/basic/migrations/m170213_124818_init.php:10)

My class is in root directory in helpers directory

namespace yii\helpers;
class Table
public static $user = 'user';
public static $role = 'role';
public static $status = 'status';
public static $domain = 'domain';

In migration class

use yii\db\Migration;
use yii\helpers;

class m170213_124818_init extends Migration
public function safeUp()
/** User Create*/
$this->createTable('{{%'.helpers\Table::$user.'}}', [
'id' => $this->primaryKey(10)->notNull()->unsigned(),
. . .
], 'ENGINE=InnoDB');

How to resolve itRead more
Resolved: Yii2 Helper folder, helper namespace, helper class
posted by admin on February 14, 2017
In yii1 I created helpers folder in public and move all my helper classes and autoload them from main.php setting file

// autoloading model and component classes

I have three questions

  1. Where create helpers classes folder
  2. How to create helpers classes
  3. How to autoload or use helpers classes
Read more
Resolved: Yii2 slash 2f url problem
posted by admin on February 6, 2017
After installation Yii2, I try to navigate with pages of application, and in url I have problem with slashes

I want to slashes in url in place of %2FRead more
Resolved: Laravel check database connection
posted by admin on January 24, 2017
How to check database connection status?

Read more
Resolved: Yii get value from url GET name
posted by admin on March 30, 2016
I'd like to know if there is an Yii function to get a value from url. The url that I have is:

I need to get the value '111' before it gets to the update action, is there an Yii method to do it?Read more
Wiki: Yii 1.1 Аутентификация и авторизация. Authentication and authorization. UserIdentitywiki
posted by admin on March 24, 2016
1. Определение класса Identity. Defining Class Identity
Edit your components/UserIdentity.php

class UserIdentity extends CUserIdentity
private $_id;
public function authenticate()
else if(!CPasswordHelper::verifyPassword($this->password,$record->password))
$this->setState('title', $record->title);
return !$this->errorCode;

public function getId()
return $this->_id;

2. controllers/SiteController.php, add

class SiteController extends Controller
public function filters()
return array(

3.Check models/LoginForm.php


* LoginForm class.
* LoginForm is the data structure for keeping
* user login form data. It is used by the 'login' action of 'SiteController'.
class LoginForm extends CFormModel
public $username;
public $password;
public $rememberMe;

private $_identity;

* Declares the validation rules.
* The rules state that username and password are required,
* and password needs to be authenticated.
public function rules()
return array(
// username and password are required
array('username, password', 'required'),
// rememberMe needs to be a boolean
array('rememberMe', 'boolean'),
// password needs to be authenticated
array('password', 'authenticate'),

* Declares attribute labels.
public function attributeLabels()
return array(
'rememberMe'=>'Remember me next time',

* Authenticates the password.
* This is the 'authenticate' validator as declared in rules().
public function authenticate($attribute,$params)
$this->_identity=new UserIdentity($this->username,$this->password);
$this->addError('password','Incorrect username or password.');

* Logs in the user using the given username and password in the model.
* @return boolean whether login is successful
public function login()
$this->_identity=new UserIdentity($this->username,$this->password);
$duration=$this->rememberMe ? 3600*24*30 : 0; // 30 days
return true;
return false;

4. Create models/User.php
4.1. Activate GII module
Go to config/main.php and uncomment the following rows

// If removed, Gii defaults to localhost only. Edit carefully to taste.

4.2. Go to GII module

4.3. Generate your User.php model, from your users table

4.4. Add to User.php

public function validatePassword($password)
return CPasswordHelper::verifyPassword($password,$this->password);

public function hashPassword($password)
return CPasswordHelper::hashPassword($password);

5. Insert user to your users table and enjoy
For example, insert into your users table row
Username: admin
Password HASH: $2y$13$imm.m0q9qN/IrWF4AtmH4ejHyS3d.ElmkayY3vQ69DTApgEY4ne36

6. Login to your website
Go to your_website/index.php?r=site/login and login
Username: admin
Password HASH: 123

Enjoy ;)Read more