1 Star 0 Fork 7

yongze.chen / SinglePHP

forked from leo108 / SinglePHP 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

SinglePHP

简介

SinglePHP是一个单文件PHP框架,适用于简单系统的快速开发,提供了简单的路由方式,抛弃了坑爹的PHP模板,采用原生PHP语法来渲染页面,同时提供了widget功能,简单且实用。

目前SinglePHP由leo108开发维护,如果你希望参与到此项目中来,可以到Github上Fork项目并提交Pull Request。

文档

中文: http://leo108.github.io/SinglePHP/

English: http://leo108.github.io/SinglePHP/en/ (Not Finished Yet)

Demo

在线演示:demo

目录结构

├── App                                 #业务代码文件夹,可在配置中指定路径
│   ├── Controller                      #控制器文件夹
│   │   └── IndexController.class.php
│   ├── Lib                             #外部库
│   ├── Log                             #日志文件夹,需要写权限
│   ├── View                            #模板文件夹
│   │   ├── Index                       #对应Index控制器
│   │   │   └── Index.php
│   │   └── Public
│   │       ├── footer.php
│   │       └── header.php
│   ├── Widget                          #widget文件夹
│   │   ├── MenuWidget.class.php
│   │   └── Tpl                         #widget模板文件夹
│   │       └── MenuWidget.php
│   └── common.php                      #一些共用函数
├── SinglePHP.class.php                 #SinglePHP核心文件
└── index.php                           #入口文件

Hello World

只需增加3个文件,即可输出hello world。

入口文件:index.php

<?php
include './SinglePHP.class.php';         //包含核心文件
$config = array('APP_PATH' => './App/'); //指定业务目录为App
SinglePHP::getInstance($config)->run();  //撒丫子跑起来啦

默认控制器:App/Controller/IndexController.class.php

<?php
class IndexController extends Controller {       //控制器必须继承Controller类或其子类
    public function IndexAction(){               //默认Action
        $this->assign('content', 'Hello World'); //给模板变量赋值
        $this->display();                        //渲染吧骚年
    }
}

模板文件:App/View/Index/Index.php

<?php echo $content;

在浏览器访问index.php,应该会输出

Hello World
The MIT License (MIT) Copyright (c) 2013 leo108 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

暂无描述 展开 收起
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/chenyongze/SinglePHP.git
git@gitee.com:chenyongze/SinglePHP.git
chenyongze
SinglePHP
SinglePHP
master

搜索帮助