I’m completely new to yii so please pardon my lack of knowledge and information.
I’m practicing web development and I got access to a friend’s website. I wanted to play with it on my localhost (using XAMPP on Windows) and found out that it uses yii. When I try to run index.php, I’m getting a page that just says:
CDbException
CDbConnection failed to open the DB connection.
I think that (obviously) I have to set up the existing database of the website. I’ve done a bit of searching but I’m confused and struggling with where to start. Is there any guide that I can follow to fix the issue? I just want to get it running first.
I have some questions before I start. Would you please answer them?
Do you have full access to the source code of the site of your friend?
Do you want to learn Yii 2.0 or Yii 1.1?
'CDbConnection` is a component of Yii framework 1.1. So the site of your friend is running on Yii 1.1. If you are new to Yii and want to learn it, I would rather recommend you start learning Yii 2.0 from scratch following the definitive guide. https://www.yiiframework.com/doc/guide/2.0/en
As for the current problem, you could check the source code. See config\main.php file for the configuration of db component. It should be something like:
Thank you for your response.
As for the questions,
Yes I do
I’m actually helping my friend developing something for his website, but it’s really not imperative that I have to do it. I’m a student and I just want to get started and develop my skills with a ‘real world’ project, so for now, I would be more interested in Yii 1.1. I might learn Yii 2 afterwards and might learn how to upgrade the website from Yii 1.1 to Yii 2.
Also, as for your answer, I just want to make sure that I have to create the database, grant access to the username and password beforehand right?
Yes, that’s right. If I were you, I would ask your friend for a backup of the relevant db tables, or at least a setup script that would create the necessary tables for the site.
P.S.
I have moved this thread to Yii 1.1 - Installation and Setup
i am completely new to yii as well. i have a complete source code with yii2 framework (version - 2.0.13.1). i have configured the db array with necessary details ( ‘dsn’ => ‘mysql:host=localhost;dbname = yidb’). and tried to launch it using xampp on windows. but when i try to login the application does not seem to work.
all i did was copy the source code into htdocs and tried to access it through chrome via xampp.
i am not sure where i went wrong. your insight would be really helpful.
i am getting several errors like
404 notfound.
from origin ‘http://localhost:8000’ has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http,