Saturday, April 21, 2012

Step by step guide – Setup the Yii framework

Hello everyone. In this tutorial we will be looking at setting up the Yii framework and create our skeleton app step by step. Lets begin.
Firstly, we need to download the Yii framework. This can be done from the Yii Framework website. When the download is complete, unzip the file and you will see a folder containing:

  • demos
  • framework
  • requirements
  • and some legal mumbo jumbo & other stuff
The only folder we are interested in is the framework folder. Copy this folder and go to your localhost. Paste the yii framework folder in a new folder where we are going to setup our application, in this tutorial we are using: localhost/yiitard
Cool, pasted. Now the fun part. Open up your command prompt and navigate to the localhost/yiitard/framework (for those of you born after 1990 type in:
c:\wamp\www\yiitard\framework
Now type in:  yiic webapp c:\wamp/www/yiitard
This will ask you if you want to “Create we application under ‘C:\wamp\www\yiitard’? [Yes:No]“
We do want to so type in “yes”. Some of you might get an error at this point saying something about php or something like that (great tutorial right?). That simply means you don’t have php setup as an environment variable.
To fix this:
“Open the Environment Variables window by going to: Start -> My Computer (right click!) -> Advanced Tab -> Environment Variables -> Click Path in System variables -> Edit.
In Windows 7, press the Win key and type “env”. You should see a control panel section with a shortcut to “Edit the system environment variables”. Select it and then click on “Environment Variables…”
Click on the variable called PATH and click “Edit…”. Do not delete the paths already there! Separate each path with semicolons.
Now you have to add the following PATHs in Windows: “C:\wamp\bin\php\php5.2.8″ and “C:\wamp\www\framework”. The former path should lead where your php.exe resides, and the latter where your yiic.bat resides.”
That bit is stolen from the Yii wiki page, thanks.
So we have type yes (or simply Y) and we should see a whole bunch of lines of stuff happening and the message “Your application has been created under C:\wamp\www\yiitard”. We have now created our skeleton app.
If you point your browser at localhost/yiitard you should see the Yii skleton app. Well done, you have just installed Yii.

No comments: