Showing posts with label php yii minimal site files. Show all posts
Showing posts with label php yii minimal site files. Show all posts

Friday, July 15, 2011

The minimum necessary site structure to run Yii, Part ii

In a previous post , I discussed how to make a minimal site with Yii. Well, here's an even smaller one, with only two files, maybe five lines of code, and no folders:

index.php:
<?
//load yii framework (you'll likely have to change the path):
require_once( dirname(__FILE__).'/../../yii/framework/yii.php' );
//create the app. note that it does not require a config file, you can just pass in an array:
$app = Yii::createWebApplication( array (
  'basePath' => dirname( __FILE__ ) , // if you don't want Protected folder
  'controllerPath' => '' // if you don't want Controllers folder
))->run();

?>
SiteController.php:
<?
class SiteController extends CController
{
  public function actionIndex()
  {
    echo 'hello world';
  }
}
?>
Now, this doesn't work with Gii or crazy things like assets, but that's probably the smallest Yii installation you can make