infifly / tt
My first Simple Php Framework
Requires
- php: >=5.4.0
- ezyang/htmlpurifier: 4.6.*
- joshcam/mysqli-database-class: v2.*
- maximebf/debugbar: *
This package is not auto-updated.
Last update: 2025-04-02 05:47:17 UTC
README
简单php框架
简单,0学习成本.
composer.json 如下
{
"name": "test",
"minimum-stability": "stable",
"require": {
"php": ">=5.4.0",
"infifly/tt":"*"
},
"autoload": {
"psr-4": {"app\\":"tt"}
},
"config": {
"secure-http": false
},
"repositories": [
{"type": "composer", "url": "http://packagist.phpcomposer.com"},
{"packagist": false}
]
}
目录结构
/configs/
/runtime/
/tt/
|---controllers
|-- LayoutController.php
/views/
|--layout
|--index.php
/models/
/web/
|--assets
|--images
|--css
.htaccess
index.php
/vendor/
composer.json
配置文件
/configs/pub.php
<?php
return [
"appname"=>"tt",
"env"=>"test" //prod, test,
];
?>
/configs/web.php
<?php
$cfg=include("pub.php");
$cfg['defaultlayout']="app\controllers\Layout.index";
$cfg['404page']="app\controllers\Layout.show404";
return $cfg;
?>
输出调试信息到页面 : \TT::setDebugMessage("xxxxx");
代码示例:
控制器:
<?php
namespace app\controllers;
use TT\core\Controller;
class TestController extends Controller{
public function __construct()
{
parent::__construct();
}
public function indexAction(){
\TT::setDebugMessage("test");
return $this->render("index",['name'=>'infi']);
}
}
?>
模板:
1:/views/layout/index.php:
<head>
<body>
<?=$this->getContent()?>
</body>
</html>
2:/views/test/index.php
<?=$name?>