mercury/framework

带有文件管理后台界面的MVC框架

安装: 31

依赖者: 0

建议者: 0

安全: 0

星标: 2

关注者: 2

分支: 0

语言:JavaScript

1.0 2016-01-14 10:29 UTC

This package is not auto-updated.

Last update: 2024-09-14 18:52:55 UTC


README

这是一个另一个Micro MVC框架。它的独特之处在于配置通过Web界面完成并存储在数据库中。你所要做的就是编写对你应用有意义的代码。

安装

你可以下载文件并尝试,但祝你好运。我建议使用composer。在你的系统中安装composer,并在你的composer.json文件中复制粘贴以下内容:

{
    "minimum-stability": "dev",
    "require": {
        "mercury/framework": "dev-master"
    },
    "autoload": {
        "psr-4": {
            "Mercury\\App\\": "application"
        }
    },
    "extra": {
        "assets-dir" : "assets/vendors/"
    }
}

然后运行composer install -o

框架使用数据库进行操作,因此需要创建以下数据库:


DROP TABLE IF EXISTS `m_blueprint`;

CREATE TABLE `m_blueprint` (
  `blueprintid` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `type` varchar(10) DEFAULT NULL,
  `content` longtext,
  PRIMARY KEY (`blueprintid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO `m_blueprint` (`blueprintid`, `type`, `content`)
VALUES
  (1, 'CONTROLLER', '<?\nnamespace Mercury\\App\\{ModuleName}\\Controllers;\n\nuse Mercury\\Helper\\Controller;\n\nclass SampleController extends Controller {\n\n\n  public function initcontroller() {\n\n    /**\n    * Avoid defining a constructor use this method instead\n    */\n }\n\n public function indexAction() {\n\n   echo \"Sample file\";\n }\n\n}'),
  (2, 'VIEW', '<?php $this->layout($gs_template, $ga_templatedata) ?>'),
  (3, 'MODEL', '<?\nnamespace Mercury\\App\\{ModuleName}\\Models;\n\nuse Mercury\\Helper\\Model;\n\nclass SampleModel extends Model {\n\n\n protected function initmodel() {\n\n    // Set this because the table name is not in standard format\n    $this->settable(\'some_table\');\n\n  }\n\n}'),
  (4, 'HELPER', '<?\nnamespace Mercury\\App\\Helpers;\n\nuse Mercury\\Helper\\Core;\n\nclass [HelperName] extends Core {\n\n}');


DROP TABLE IF EXISTS `m_module`;

CREATE TABLE `m_module` (
  `moduleid` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(50) DEFAULT NULL,
  `core` tinyint(1) unsigned zerofill DEFAULT NULL,
  PRIMARY KEY (`moduleid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


DROP TABLE IF EXISTS `m_page`;

CREATE TABLE `m_page` (
  `pageid` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `label` varchar(100) DEFAULT NULL,
  `name` varchar(100) DEFAULT NULL,
  `content` longtext,
  `type` varchar(20) DEFAULT NULL,
  `moduleid` int(11) DEFAULT NULL,
  `controllerid` int(11) DEFAULT NULL,
  `templateid` int(11) DEFAULT NULL,
  `core` tinyint(1) unsigned zerofill DEFAULT NULL,
  `created` datetime DEFAULT NULL,
  `deleted` tinyint(1) unsigned zerofill DEFAULT NULL,
  PRIMARY KEY (`pageid`),
  KEY `type` (`type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


DROP TABLE IF EXISTS `m_route`;

CREATE TABLE `m_route` (
  `routeid` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `requesturi` varchar(100) DEFAULT NULL,
  `moduleid` int(11) DEFAULT NULL,
  `controllerid` int(11) DEFAULT NULL,
  `action` varchar(50) DEFAULT NULL,
  `method` varchar(50) DEFAULT NULL,
  `core` tinyint(1) DEFAULT NULL,
  `created` datetime DEFAULT NULL,
  PRIMARY KEY (`routeid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

NGINX配置

除了你的其他配置外,你还需要以下内容:

location / {
    try_files $uri $uri/ /index.php?$query_string;
}

location ~* (.+)\.(?:\d+)\.(js|css|png|jpg|jpeg|gif)$ {
   try_files $uri $1.$2;
}

就这样!你已经安装了一个很棒的框架 ;)

用法

目前没有太多文档,可能会在有时间时完成,但可以使用以下内容在你的index.php中开始使用:

<?
use Mercury\Helper\Application;
use Mercury\Helper\Profiler;

error_reporting(E_ALL);
ini_set('display_errors', 1);

// Autoload
require('vendor/autoload.php');

// Init the profiler
$go_profiler = new Profiler();

// Create the application
$go_app = new Application();

// Run the application
$go_app->runapp();

// Show the profiling result
$go_profiler->showresult();
?>