1 Star 0 Fork 3

albert / TinyMvc

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

PHP Tiny MVC Framework

  • 基于composer简约的高性能php mvc框架,包含:路由,ORM,session,view,cache等等。
  • 支持Mysql && sqlite

截图

image image

目录结构

TinyMvc/

├── config                              
│   └── main.php    //配置文件
├── demo                               
│   └── users.sql   //demo 数据库
├── public                              
│   ├── index.php   //app 入口
│   └── static      //静态资源
├── runtime
│   ├── cache       //文件缓存
│   └── logs        //日志

├── src  //源文件
│   ├── app
│   │   ├── Application.php   
│   │   └── ApplicationHelper.php
│   ├── base
│   │   ├── AppException.php
│   │   ├── Config.php
│   │   ├── Decorators.php
│   │   └── TinyMvc.php
│   ├── controllers             //controller 目录
│   │   ├── BaseController.php
│   │   ├── Home.php
│   │   └── Users.php
│   ├── models                  //models 目录
│   │   └── User.php
│   ├── routers                 //路由目录
│   │   ├── default.php
│   │   └── users.php
│   └── utils
│       └── Utils.php
└── views                       //views目录
    ├── error
    │   └── error.php
    ├── home
    │   └── index.php
    ├── layouts
    │   └── main.php
    └── users

install

git clone https://git.oschina.net/man0sions/TinyMvc.git
cd TinyMvc
composer update

系统环境

  • Composer
  • PHP 5.6+
  • PDO extension

配置文件

参照 : config/main.php

路由配置

src/routers 详细路由配置请查看 http://git.oschina.net/man0sions/Router

$router->get("/","Home@index");

$router->get("/users","Users@index");


$router->get("/users/id/:id","Users@view");

controller

src/controllers 详细controller用法查看 http://git.oschina.net/man0sions/Controller

class Users extends BaseController
{
    private $page_size = 10;

   
    public function index()
    {
        $users = User::model()->limit($start, $this->page_size)->findAll();
        return $this->render(['users' => $users]);
    }
    
}

view

views

默认情况下 controller
Home@index
对应 views
home/index.php

model

src/models 详细用法查看 http://git.oschina.net/man0sions/Orm

use LuciferP\Orm\base\Model;

class User extends Model
{
    protected $table="users";
}

run

cd public && php -S 127.0.0.1:3000

Visit http://127.0.0.1:3000/

demo

demo 数据库在 demo/users.sql

展示了 user curd的实现细节,包括:
路由配置 src/routers/users.php
controller  src/controllers/Users.php
view views/users

The MIT License (MIT) Copyright (c) 2016 man0sions 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.

简介

简约的高性能php mvc框架 展开 收起
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

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

搜索帮助