假設您已經安裝了 yii 的應用環境
入口檔案 index.php
<?php
//開啟除錯模式
defined('yii_debug') or
define
('yii_debug', true); //線上環境設為false
defined('yii_env') or
define
('yii_env', 'dev'); //線上環境設為pro
//composer 載入
require(__dir__ .
'/../vendor/autoload.php');
//yii 核心框架檔案
require(__dir__ .
'/../vendor/yiisoft/yii2/yii.php');
//載入應用主體配置
$config
=require(__dir__ .
'/../config/web.php');
//建立應用主體 所有的應用從這裡開始
簡單示例 路徑 controllers\home\indexcontroller;
檔名 indexcontroller.php
<?php
namespace
useyii\web\controller;
class
indexcontroller
extends
controller
}//訪問 url : http://host/index.php?r=home/index/index
//請確保index.php 專案根目錄環境下面
?>
顯示檢視 路徑 controllers\home\customcontroller;
<?php
namespace
useyii;
useyii\web\controller;
class
customcontroller
extends
controller
public
function
actionindexview1
()
}?>
路徑 : views/home/custom/index.php
<?php var_dump($model); ?>
Yii學習筆記(入門)
use yii db activerecord class a extends activerecord hello,i am only page.1 初始化應用 訪問http localhost basic web index.php,進入yii的啟動頁面。如果提示你未安裝openssl的話,去你...
Yii入門教程之Yii安裝及hello world
注意版本,這裡是根據yii1來的,如果是yii2的話可能會不www.cppcns.com一樣。2,在自己的 www 目錄下建立乙個wen應用目錄,我這裡叫 fantacms 然後把剛剛 的yii安裝包解壓,然後把解壓檔案中的 framework 目錄剪下到 fantacms 目錄下 3,在命令列模式...
Yii學習筆記
1 執行環境檢測,yii提供了檢測工具 requirements index.php 2 使用yiic生成應用程式 下面的樹圖描述了我們這個應用的目錄結構。請檢視約定以獲取該結構的詳細解釋。testdrive index.php web 應用入口指令碼檔案 index test.php 功能測試使用...