3

I was just curious if Yii is supposed to be compiled into PHP or not. Is it possible to use Yii just by copying the Framework to a folder on the server and then including something (something as in one of the yii files- I am not sure how it works) in the scripts I wish to use the framework for?

(Noob when it comes to frameworks and usage)

Thanks, Josh

3 Answers 3

5

I'll go with the line

Is it possible to use Yii just by copying the Framework to a folder on the server and then including something

and answer yes :p Though, you should just follow webapp creation through yiic webapp like so:

  1. Download the yii (yii-someversion.tar.gz or what have you) distribution,
  2. extract it somewhere (e.g. /opt/yii in *nix or C:/web/yii in windows.)
  3. Now put that directory in your path ($PATH in *nix, or %PATH% in windows),
  4. go to a shell / command prompt, change the directory to your webserver's document root and do a yiic webapp <app folder name>

After answering a couple config question, you should have an look at the index.php created there, you should have something like:

<?php

// change the following paths if necessary
$yii=dirname(__FILE__).'/../yii/framework/yii.php';
$config=dirname(__FILE__).'/protected/config/main.php';

// remove the following lines when in production mode
defined('YII_DEBUG') or define('YII_DEBUG',true);
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);

require_once($yii);
Yii::createWebApplication($config)->run();

and that's about it :p

Sign up to request clarification or add additional context in comments.

2 Comments

ZaQ, what about dependencies? Specifically the PDO_DAO package, which won't be supported by my budget host server. If I develop on LAMP and upload all the files to that server, will it work from there?
cmiiw, yii needs the pdo extensions for it's DAO layer (at least I think the CActiveRecord class uses it) if you don't have PDO you still can use yii but not the dao (specifically the active records and its subclass etc) part
2

Yii is a PHP framework and not an extension. You can just copy-paste it somewhere. Be sure to put the destination folder into your include path.

Comments

0

you just need to do it once to get an instance, and then you can copy this instance as much as you want, provided that the path of yii.php file in the index.php file is right, for me I usually copy the framework folder from the yii folder, paste it inside the instance in the folder "protected" and then change the path in index.php to "/protected/framework/yii.php"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.