GithubHelp home page GithubHelp logo

singlephp's Introduction

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

singlephp's People

Contributors

leo108 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

singlephp's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.