Pages

Wednesday, November 27, 2013

Creating your Web Application with yiic

Command Line Tool

To create your new web application in yii, you need to use this powerful little tool called yiic. Yiic, is a command-line tool that you can use to quickly start a brand new Yii application. This tool is not mandatory to start a Yii application, but this tool allows you to save time and assures you of a correct directory and file structure.

In order to use this tool, you need to open up your command line and navigate to the directory you want to create your application's directory structure. 

For demonstration purposes, we will assume the following:
  • YiiDir is the name of the directory where you placed the Yii framework files. (see How to Install Yii)
  • WebDir is the document root of your web server.
From the command line, go to WebDir and execute the yiic command
  • Linux
    • % YiiDir/framework/yiic webapp <name_of_application>
  • Windows
    • C:\WebDir\> YiiDir\framework\yiic webapp <name_of_application>
After pressing the Return key, this message will be displayed:

     Create a Web application under 'WebDir/<name_of_application>'? [Yes|No]
     Type in Yes, press Return key.

                 mkdir /WebRoot/helloworld
                 mkdir /WebRoot/helloworld/assets
                 mkdir /WebRoot/helloworld/css
            generate css/bg.gif
            generate css/form.css
            generate css/main.css

           Your application has been created successfully under /Webroot/<name_of_application>.

Now your new web application has been created and the directories and files have been generated to provide a skeleton for a default Yii application. Let's see the list of directories and files below:
  • index.php - Web application entry script file
  • index-test.php - Entry script file for loading a test configuration
  • assets/ - Contains published resource files
  • css/ - Contains the CSS files
  • images/ - Contains the image files
  • themes/ - Contains the application themes
  • protected/ - Contains the protected (private) application files
Make sure your web server is running and you should be able to open up your browser and go to the URL http://localhost/<name_of_application>/index.php. Once you see the My Web Applicaiton page then you are good to go.

HAPPY DAYS!!!

No comments:

Post a Comment