-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
150 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# 给我家狗狗的视频直播 | ||
—— 基于 Laruence 的 Yaf Framework(powered by C) | ||
—— Powered by Laruence's Yaf Framework |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
/** | ||
* @name Bootstrap | ||
* @author young-pc\young | ||
* @desc 所有在Bootstrap类中, 以_init开头的方法, 都会被Yaf调用, | ||
* @see http://www.php.net/manual/en/class.yaf-bootstrap-abstract.php | ||
* 这些方法, 都接受一个参数:Yaf_Dispatcher $dispatcher | ||
* 调用的次序, 和申明的次序相同 | ||
*/ | ||
class Bootstrap extends Yaf_Bootstrap_Abstract{ | ||
|
||
public function _initConfig() { | ||
//把配置保存起来 | ||
$arrConfig = Yaf_Application::app()->getConfig(); | ||
Yaf_Registry::set('config', $arrConfig); | ||
} | ||
|
||
public function _initPlugin(Yaf_Dispatcher $dispatcher) { | ||
//注册一个插件 | ||
$objSamplePlugin = new SamplePlugin(); | ||
$dispatcher->registerPlugin($objSamplePlugin); | ||
} | ||
|
||
public function _initRoute(Yaf_Dispatcher $dispatcher) { | ||
//在这里注册自己的路由协议,默认使用简单路由 | ||
} | ||
|
||
public function _initView(Yaf_Dispatcher $dispatcher){ | ||
//在这里注册自己的view控制器,例如smarty,firekylin | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
/** | ||
* @name ErrorController | ||
* @desc 错误控制器, 在发生未捕获的异常时刻被调用 | ||
* @see http://www.php.net/manual/en/yaf-dispatcher.catchexception.php | ||
* @author young-pc\young | ||
*/ | ||
class ErrorController extends Yaf_Controller_Abstract { | ||
|
||
//从2.1开始, errorAction支持直接通过参数获取异常 | ||
public function errorAction($exception) { | ||
//1. assign to view engine | ||
$this->getView()->assign("exception", $exception); | ||
//5. render by Yaf | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
/** | ||
* @name IndexController | ||
* @author young-pc\young | ||
* @desc 默认控制器 | ||
* @see http://www.php.net/manual/en/class.yaf-controller-abstract.php | ||
*/ | ||
class IndexController extends Yaf_Controller_Abstract { | ||
|
||
/** | ||
* 默认动作 | ||
* Yaf支持直接把Yaf_Request_Abstract::getParam()得到的同名参数作为Action的形参 | ||
* 对于如下的例子, 当访问http://yourhost/Sample/index/index/index/name/young-pc\young 的时候, 你就会发现不同 | ||
*/ | ||
public function indexAction($name = "Stranger") { | ||
//1. fetch query | ||
$get = $this->getRequest()->getQuery("get", "default value"); | ||
|
||
//2. fetch model | ||
$model = new SampleModel(); | ||
|
||
//3. assign | ||
$this->getView()->assign("content", $model->selectSample()); | ||
$this->getView()->assign("name", $name); | ||
|
||
//4. render by Yaf, 如果这里返回FALSE, Yaf将不会调用自动视图引擎Render模板 | ||
return TRUE; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
项目库文件放在这里 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
/** | ||
* @name SampleModel | ||
* @desc sample数据获取类, 可以访问数据库,文件,其它系统等 | ||
* @author young-pc\young | ||
*/ | ||
class SampleModel { | ||
public function __construct() { | ||
} | ||
|
||
public function selectSample() { | ||
return 'Hello World!'; | ||
} | ||
|
||
public function insertSample($arrInfo) { | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
/** | ||
* @name SamplePlugin | ||
* @desc Yaf定义了如下的6个Hook,插件之间的执行顺序是先进先Call | ||
* @see http://www.php.net/manual/en/class.yaf-plugin-abstract.php | ||
* @author young-pc\young | ||
*/ | ||
class SamplePlugin extends Yaf_Plugin_Abstract { | ||
|
||
public function routerStartup(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response) { | ||
} | ||
|
||
public function routerShutdown(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response) { | ||
} | ||
|
||
public function dispatchLoopStartup(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response) { | ||
} | ||
|
||
public function preDispatch(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response) { | ||
} | ||
|
||
public function postDispatch(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response) { | ||
} | ||
|
||
public function dispatchLoopShutdown(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response) { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?php | ||
echo "Error Msg:" . $exception->getMessage(); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?php | ||
echo $content, " I am ", $name; | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[common] | ||
application.directory = APP_PATH "/application" | ||
application.dispatcher.catchException = TRUE | ||
|
||
[product : common] | ||
|
||
|
||
[product] | ||
; 支持直接使用PHP中已定义常量 | ||
application.directory = APP_PATH "/application" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,8 @@ | ||
<?php | ||
echo 'index.php'; | ||
/** APP 根目录 指向public上一级 */ | ||
define('APP_PATH', __DIR__); | ||
$app = new Yaf_Application(APP_PATH . '/conf/application.ini'); | ||
|
||
$app->run(); | ||
echo "\n"; | ||
echo __DIR__; |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
需要在php.ini里面启用如下配置,生产的代码才能正确运行: | ||
yaf.environ="product" | ||
|
||
错误日志在php错误日志; |