Forward to Navigation

Yii Basic Steps

Posted by (Apr 6, 03:15 PM)

Tags: , , , , ,

This is just a reminder to myself about setting up a Yii install. There are much more detailed examples on the web.

Build database

Build a database (I use MySql with innodb engine). The innodb engine is important because it allows you to document foreign key associations

Copy yii to top level of webdirectory

If you haven’t already done so, get a copy of the latest version of yii, uncompress it, and install it in a webdirectory immediately below the web root.

In my case, I tend to put it under /var/www/ and call the directory yii.

Use yiic to build initial site

navigate to the root of your web directory. Assuming yii is an immediate child of this directory, use the following to build the initial site of your website, where $site is the directory name you want to use for your site and $path the full path to the current directory:

yii/framework/yiic webapp $site

The response should be: Your application has been created successfully under $path/$site

Prepare for building the scaffolding

change directory to $path/$site/protected/config/

edit main.php:

  1. remove the comments surrounding the section on the gii tool (you’ll want to put these back in production)
  2. make sure you put a password in
  3. (for MySql) remove the comments surrounding the MySql Stanza and modify/supply the required information (usernames, passwords, servers, etc.)
  4. fix the admin email.

Use gii to establish the basic scaffolding

  1. point your webbrowser at the site (e.g. http://localhost/$site/ or http://example.com/$site/)
  2. click on the “home” link in the menubar to get the top URL (it will be something like this: http://$domain/$site/index.php?r=site/index)
  3. in the location bar, replace site/index with gii
  4. enter the database root password

Develop models

Most if not all dbases will have a model in the system.

  1. Select “Model Generator”.
  2. enter * in the “Table name” field to generate models for all tables; otherwise type the table name in the box for a specific table.
  3. click on preview.
  4. if everything is good, click on generate (need to make sure permissions all generation).

Develop CRUD

  1. select “crud generator”
  2. enter Model names for the models for which you want to have specific forms and actions (not all tables will require this: some will be written automatically or through relations)
---

Posted: Friday April 6, 2012. 15:15.

Last modified: Wednesday May 23, 2012. 18:49.

----  

Comment [1]

  1. Ray Stoeckicht (Mon Apr 9, 2012 (11:38:18)) [PermLink]:

    Nice tutorial on Yii. It is great to see someone publishing quality content on the framework. We have been working on an open source CRM application that is written in PHP utilizing JQuery, Yii, and RedBeanPHP and relies heavily on test driven development. Zurmo might be one of the most sophisticated projects on Yii to date. Right now, we have 1000+ unit tests running across eight server configurations. We utilize selenium as well for a nice set of functional tests too. It would be incredibly helpful to get your technical feedback and recommendations so that we can improve the application. Take a look and let me know what you think: http://zurmo.org

Commenting is closed for this article.

Back to content

Search my site

Quick links for students

Tags

anglo-saxon studies, computers, digital humanities, digital pedagogy, editorial studies, english 2810, exercises, grammar, history, linguistics, medieval studies, moodle, morphology, old english, pedagogy, students, study tips, testing, tips, tutorials, universities, yii

See all...

Follow me on Twitter

Recent changes to this site

At the dpod blog