Chitika

Thursday, January 5, 2012

Creating the controller Yii FrameWork

To create a new application, we are going to use a little powerhouse of a tool known
as yiic that comes packaged with the framework. This is a command-line tool that
one can use to quickly jumpstart a brand new Yii application. It is not mandatory to
use this tool, but it saves a lot of time and guarantees that the proper folder and file
structure is in place

To use this tool to create your first Yii application, open up a shell window,
and navigate to a place in your filesystem where you will want to create your
application's folder structure. For the purpose of this demo application, we will
assume the following:

.................................................................................................
•     YiiRoot is the folder where you have installed Yii
•     WebRoot is configured as the document root of your web server
•     From your command line, change to your WebRoot folder and execute
the following:
% cd WebRoot
% YiiRoot/framework/yiic webapp demo
Create a Web application under '/Webroot/demo'? [Yes|No]
Yes
   mkdir /WebRoot/demo
   mkdir /WebRoot/demo/assets
   mkdir /WebRoot/demo/css
   generate css/bg.gif
   generate css/form.css
   generate css/main.css

............................................................
Your application has been created successfully under /Webroot/demo. The webapp
command is used to create a brand new Yii web application. It takes just a single
argument to specify either the absolute or relative path to the folder in which the
application should be created. The result is the generation of all the needed folders
and files to provide a default Yii web application skeleton.
Now we can change into the newly created demo folder and look at what was created
for us:

.................................................................
% cd demo
% ls –p
assets/    images/    index.php  themes/
css/    index-test.php  protected/
A description of the high-level items that were automatically created is shown 
as follows:
demo/   
index.php    Web application entry script file   
index-test.php  entry script file for the functional tests   
assets/    containing published resource files 

css/      containing CSS files   
images/    containing image files   
themes/    containing application themes   
protected/    containing protected application files 

........................................................
With the execution of one simple command from the command line, we have created
all the folder structure and files needed to immediately take advantage of Yii's sensible
default configuration. All of these folders and the files, along with the subfolders
and files they contain, can look a little daunting at first glance. However, we can
ignore most of them as we are getting started. All these folders and files are actually
a working web application. The yiic command has populated the application with
enough code to establish a simple home page, a typical Contact Us page to provide
an example of a web form, and a login page with enough autogenerated code to
demonstrate basic authorization and authentication in Yii. If your web server supports
the GD2 graphics library extension, you will also see a CAPTCHA widget on the
Contact Us form, and the application will have the corresponding validation for this
form item.
As long as your web server is running, you should be able to open up your browser
and navigate to http://localhost/demo/index.php. Here you will be presented
with a My Web Application home page along with the friendly greeting Welcome
to My Web Application, followed by some helpful information on the steps to be
taken next. The next screenshot shows this example home page

No comments:

Post a Comment

Clicksor

Related Results

Related Posts Plugin for WordPress, Blogger...

Comment Here