You are here
Home > Yii Framework > Fix PDO Error Exception Yii Framework 2

Fix PDO Error Exception Yii Framework 2

You can install Yii in two ways, using the Composer package manager or by downloading an archive file. The former is the preferred way, as it allows you to install new extensions or update Yii by simply running a single command.

Standard installations of Yii result in both the framework and a project template being downloaded and installed. A project template is a working Yii project implementing some basic features, such as login, contact form, etc. Its code is organized in a recommended way. Therefore, it can serve as a good starting point for your projects.

With Composer installed, you can install Yii by running the following commands under a Web-accessible folder:

The first command installs the composer asset plugin which allows managing bower and npm package dependencies through Composer. You only need to run this command once for all. The second command installs the latest stable version of Yii in a directory named basic. You can choose a different directory name if you want.

Verifying the Installation

After installation is done, either configure your web server (see next section) or use the built-in PHP web server by running the following console command while in the project web directory:

By default the HTTP-server will listen to port 8080. However if that port is already in use or you wish to serve multiple applications this way, you might want to specify what port to use. Just add the –port argument:

Problem: After installing the framework we have experienced this PDOException issue.
fix pdo error exception yii framework 2
Solution: To solve this we have changed the parameter localhost to in db.php file under config folder & that looks like below: