.httaccess configuration changes

This is to disable accessing INDEX

and enabling a redirection of the root to a subdirectory

for example when a user accesses lists.my , it will forward the user to lists.my/wp/

# Do not remove this line or mod_rewrite rules and search engine friendly URLs will stop working
RewriteBase /
Options -Indexes
RewriteEngine On
RewriteRule ^$ /wp [L]

Initial Yii Installation Env Path + running INIT (important!)

  1. After instaling WAMP, the location of the PHP binary needs to be added to the path.
  2. Then the Yii2 installation needs to be initialized.

c:\wamp\www\advanced>yii init
Could not open input file: c:\wamp\www\advanced\yii

c:\wamp\www\advanced>php yii init
Could not open input file: yii

c:\wamp\www\advanced>php init
Yii Application Initialization Tool v1.0

Which environment do you want the application to be initialized in?

[0] Development
[1] Production

Your choice [0-1, or “q” to quit] 0

Initialize the application under ‘Development’ environment? [yes|no] yes


  1. Then the DB needs to be initialized (matching the config)


Without running this step, Yii cant be accessed  (index.php will be missing).


Then the migration script needs to be run.

c:\wamp\www\advanced>php yii migrate
Yii Migration Tool (based on Yii v2.0.10)

Creating migration history table “migration”…Done.
Total 1 new migration to be applied:

Apply the above migration? (yes|no) [no]:yes
*** applying m130524_201442_init
> create table {{%user}} … done (time: 0.032s)
*** applied m130524_201442_init (time: 0.169s)
1 migration was applied.

Migrated up successfully.



Yii2 Error (after installing or after migration)

This issue keeps happening to me and i tend to forget the resolution.

arning: include(C:\wamp\www\backup\basic2\vendor\yiisoft\yii2/base/Component.php): failed to open stream: No such file or directory in C:\wamp\www\backup\basic2\vendor\yiisoft\yii2\BaseYii.php on line 290


So the system complained failed to open stream.

THE SOLUTION IS: CHECK THE db.php connection details.

This issue is caused by Yii2 not being able to connect to DB.


And make sure you change the right db.php file (check the directory of the file and check the URL you are accessing).


JAVA Compiling via CMD

An issue i keep having is Compiling Java project created on IDE (Eclipse or Netbeans) on CMD line (Windows). I keep getting the issue


Error: Could not find or load main class <ClassName>


The thing is that, since it was built in IDE, and IDE would like to package it, it cannot be run on the .class directory.


Steps to follow.


  1. Make sure the PATH (Windows Env Variable) has JAVA bin path. If not, add it
  2. Try running javac from the command line. If succeed, you can compile using cmd line.
  3. Go to the src directory, up to the .java file.
  4. Compile it there
    1. javac MiniMusicCmdLine.java
  5. Then to run it, go back to the src (source) directory, and then run command java packageName.ClassName .
  6. It should work

Directory of C:\Users\MM\Google Drive\PROGRAMMING\Java\MiniMusicCmdLine\src\minimusiccmdline

01/11/2017 07:31 AM <DIR> .
01/11/2017 07:31 AM <DIR> ..
01/11/2017 07:31 AM 1,203 MiniMusicCmdLine.class
01/09/2017 11:04 PM 1,377 MiniMusicCmdLine.java
2 File(s) 2,580 bytes
2 Dir(s) 904,655,876,096 bytes free

C:\Users\MM\Google Drive\PROGRAMMING\Java\MiniMusicCmdLine\src\minimusiccmdline>
java MiniMusicCmdLine
Error: Could not find or load main class MiniMusicCmdLine

C:\Users\MM\Google Drive\PROGRAMMING\Java\MiniMusicCmdLine\src\minimusiccmdline>
cd ..

C:\Users\MM\Google Drive\PROGRAMMING\Java\MiniMusicCmdLine\src>java minimusiccmd
Don’t forget the instrument and note args

C:\Users\MM\Google Drive\PROGRAMMING\Java\MiniMusicCmdLine\src>java minimusiccmdline.MiniMusicCmdLine

Installing Yii2 Advanced Template

Go to the advanced directory and run the following command:

C:\wamp\www\<  >\advanced>php yii migrate
Yii Migration Tool (based on Yii v2.0.8)

Creating migration history table “migration”…Done.
Total 1 new migration to be applied:

Apply the above migration? (yes|no) [no]:yes
*** applying m130524_201442_init
> create table {{%user}} … done (time: 0.378s)
*** applied m130524_201442_init (time: 0.650s)

1 migration was applied.

Migrated up successfully.

(02) The basic config of Yii2

  1. Please read the manual/documentation – this will help you to understand the structure of Yii2 framework – how files are stored/organized, and how the framework hangs together. I made a mistake trying to jump in without having the basic knowledge of what Yii2 is about.
  2. The concept of MVC (Model View Controller) has to be understood as well. The video tutorial in the previous post should give you an idea. Any MVC tutorial on Youtube would suffice as well.
  3. Gii is a very important tool – if you want to use Yii with Database. Make sure Gii is working – else you will have to create lots of code from scratch. Gii is already pre-installed with Yii2 basic.
  4. Some issues when trying to access Gii:

A. Database Exception

This issue is actually caused by the config in the file db.php
(C:\Users\<Yii Path>\basic\config\db.php)


return [
‘class’ => ‘yii\db\Connection’,
// ‘dsn’ => ‘mysql:host=localhost;dbname=yii2basic’,
// ‘username’ => ‘root’,
// ‘password’ => ”,
‘dsn’ => ‘mysql:host=localhost;dbname=uXXXXX_yyyyy1’,
‘username’ => ‘uXXXXXX_aYYYYY’,
‘password’ => ‘XXXXXXyyyyyyyy’,
‘charset’ => ‘utf8’,

B. Forbidden 403

This is caused by Gii config that only allows certain IPs to access it (security purpose). To fix this issue, check your external IP (how internet sees your machine – either using sites like whatismyip.com ) and then add it to Gii config.

C:\Users\<Yii Path> \basic\vendor\yiisoft\yii2-gii\Module.php


class Module extends \yii\base\Module implements BootstrapInterface
* @inheritdoc
public $controllerNamespace = ‘yii\gii\controllers’;
* @var array the list of IPs that are allowed to access this module.
* Each array element represents a single IP filter which can be either an IP address
* or an address with wildcard (e.g. 192.168.0.*) to represent a network segment.
* The default value is `[‘’, ‘::1’]`, which means the module can only be accessed
* by localhost.

public $allowedIPs = [‘’, ‘::1’, ‘1XX.1XX.1X.1XX’,’6X.XX.1XX.1XX’,’6X.XX.1XX.2XX’];

(01) The basics of installing Yii

This is a simple blog of the journey learning and using PHP Yii2.

Download: http://www.yiiframework.com/
Unofficial video tutorial: (DoingItEasy Channel) https://www.youtube.com/watch?v=z1xtFbO9jgQ&list=PLRd0zhQj3CBmusDbBzFgg3H20VxLx2mkF

1. Server with PHP capability
2. Server with DB capability (MySQL is the easiest)

Extract the Yii2 Basic from the archive. Upload to server (if the server is not the local machine).

FTP tips: if using FTP application, try to find a way to autosych the local folder with the folder on the FTP server. This will help in the organisation of the files, especially when editing files. For FILEZILLA, there is a way to do a SYNCHRONIZED BROWSING.