• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

slimore: Slimore 是一个基于 Slim 框架的完全 (H)MVC 框架。

原作者: [db:作者] 来自: 网络 收藏 邀请

Slimore

The fully (H)MVC framework based on the Slim PHP Framwork v2.6.x .

Install

Require php >=5.4.0 .

composer.json :

{	"require" : {		"slimore/slimore" : "*"	}}

Install :

$ composer install

Directory structure

Single module :

/	app/		controllers/		models/		views/	configs/		routes.php		settigns.php	public/		.htaccess		index.php	vendor/		...	composer.json

Multi modules :

/	app/		frontend/			controllers/			models/			views/		backend/			controllers/			models/			views/		api/			controllers/			models/			views/		...	configs/		routes.php		settings.php	public/		.htaccess		index.php	vendor/		...	composer.json

Usige

.htaccess :

RewriteEngine OnRewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule ^ index.php [QSA,L]

index.php :

<?phpdefine('APP_PATH',  realpath(__DIR__ . '/../app') . DIRECTORY_SEPARATOR);define('BASE_URL',  str_replace('index.php', '', $_SERVER['PHP_SELF']));require __DIR__ . '/../vendor/autoload.php';$app = new \Slimore\Mvc\Application([    'debug'           => true,	'path'            => APP_PATH,	'baseURL'         => BASE_URL,	//'modules'       => ['home', 'admin', 'api'], // Multi-Modules	//'defaultModule' => 'home',    'autoloads'     => [        APP_PATH . 'path/xx/xx'    ]]);//$app->dbConnection(); // if using database$app->get("/", function() {    echo "Hello world!";});// Routes//$app->get('/news', 'NewsController:read');// or $app->get('/news', controller('index', 'read'));//$app->get('/news', 'Home\Controllers\NewsController:read');// or $app->get('/news', controller('news', 'read', 'Home\Controllers\\'));//$app->post('/news', 'Home\Controllers\NewsController:create');//$app->put('/news/:id', 'Home\Controllers\NewsController:update');//$app->delete('/news/:id', 'Home\Controllers\NewsController:delete');// or/*$app->moduleNamespace('Home\Controllers\\', function($namespace, $app) {    //echo $namespace;    $ctl = 'IndexController';    //$app->get('/', $namespace . $ctl . ':index');    //$app->get('/news/:id', $namespace . $ctl . ':index');    $app->controller('index', function($controller, $app, $namespace) {         //echo $controller . ', ' . $namespace;        //$app->get('/news/:id', $namespace . $controller . ':index');    }, $namespace);});*/// Auto routes => /:action, /:controller/:action, /:module/:controller/:action$app->autoRoute();$app->run();

Model :

<?phpclass Article extends \Slimore\Mvc\Model{	//protected  $table      = 'you_table_name';	//protected  $primaryKey = 'your_id';}

Using Eloquent ORM / Model : http://laravel.com/docs/5.0/eloquent

View :

<?php// using php statement?><title><?=$title?></title><?=$var?><?php if ($exp) : ?><?php else : ?><?php endif; ?>

Controller :

<?php// Multi-module//namesapce Frontend\Controllers;use \Slimore\Database\Manager as DB;class IndexController extends \Slimore\Mvc\Controller{    public function index()    {		// Using model, same Laravel		$article = Article::find(1);		// query builder        $news = $this->db->table('news')						 ->select(['nid', 'cid', 'title', 'content', 'add_time'])						 ->where(['cid' => 0])						 ->orderBy('nid', 'DESC')						 ->get();        //print_r($news);		// Basic database usage, same Laravel		$results = DB::select('select * from users where id = ?', [1]);		// Slim application methods		// request		$get = $this->request->get();		// response		//$this->response->headers->set('Content-Type', 'application/json');		// view		$this->view->setData(array(            'color' => 'red',            'size' => 'medium'        ));		 // render views/index.php		$this->render('index', [			'title'   => 'Hello world!' . $article->title,			'article' => $article		]);		// output json		/*$this->json([			'status' => 200,			'message' => 'xxxxxx',			'data' => $article		]);*/    }}

Using Slim : http://docs.slimframework.com/

Dependents

Components

  • Captcha
  • Debug\Simpler
  • Functions
  • FileCache
  • Http\Client
  • Image\Gd
  • Log\Writer
  • Pagination
  • Uploader
  • ...

Changes

Change logs

License

The MIT License.

Copyright (c) 2015 Pandao


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap