ModStartCMS 基於 Laravel 模組化組織的後臺系統框架

ModStart開源發表於2021-09-22

簡介

ModStart 是一個基於 Laravel 模組化組織的後臺系統框架,很少的程式碼即可快速構建出一個功能完善的後臺系統。其中模組市場包含了豐富則模組,開箱即用,讓開發者能夠從冗長的程式碼中提效,對後端開發者非常友好。

技術棧

Laravel
LayUI
Vue
Element UI
jQuery

特性

簡潔優雅、靈活可擴充套件
後臺RBAC許可權管理
Ajax頁面無重新整理
元件按需載入靜態資源
內建豐富的表格常用功能
內建檔案上傳,無需繁瑣的開發
模組市場,只需在管理頁面點選滑鼠即可完成外掛的安裝、更新和解除安裝等操作
交流

加入我們

如果您對這個專案感興趣,非常歡迎加入專案開發團隊,參與這個專案的功能維護與開發。

歡迎任何形式的貢獻(包括但不限於以下):

貢獻程式碼
完善文件
撰寫教程
完善註釋

版本策略

ModStart 的版本發行將會參考主流 web 框架的發行策略,儘量降低版本升級帶來的影響,最大程度的考慮相容性問題,小版本的升級將盡量不改動任何功能介面;同時我們也將會提供更新日誌,詳細說明新版本的改動以及可能造成的影響。

對於小版本的發行,開發者可以放心的升級,基本不用擔心程式碼相容性問題。只有像從 v2.0.0 到 v3.0.0 這樣的大版本升級才可能會有相容性問題,小版本則基本是完全相容的(小版本升級也可能會有不相容的情況,但機率很小)。

安裝

環境要求
PHP >= 5.6
MySQL >= 5.0
PHP Extension:Fileinfo
Apache/Nginx
安裝步驟
配置 apache/nginx 伺服器,請將網站的根目錄配置到 <網站目錄>/public
訪問 www.xxx.com/install.php
使用安裝引導向導進行安裝

Nginx參考配置

server {
    listen       80;
    server_name  xx.com;x
    charset utf-8;
    index index.php index.html;
    root /var/www/html/xxx.com/public;
    autoindex off;
    location ^~ /.git {
        deny all;
    }
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }
    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  PHP_VALUE  "open_basedir=/var/www/html/xxx.com/:/tmp/:/var/tmp/";
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
    location ~ \.(gif|jpg|jpeg|png|bmp|ico|css|js)$ {
       expires max;
    }
    location ~* \.(eot|ttf|woff|woff2)$ {
        add_header Access-Control-Allow-Origin '*';
    }
}

Apache參考配置

<VirtualHost *:80>
      ServerName xxx.com
      DocumentRoot d:/wwwroot/xxx.com/public
</VirtualHost>

##整合環境
寶塔一鍵安裝教程:待完善
PHPStudy意見安裝教程:待完善
環境預檢
為方便系統環境快速配置,我們提供了伺服器端安裝環境預檢程式。使用方式如下:

通過連線下載檔案 modstart.com/env_check.zip ,解壓出 env_check.php 檔案。
將 env_check.php 檔案上傳到伺服器空間,配置通過訪問 www.xxx.com/env_check.php 來檢視安裝環境是否配置成功,如果環境預檢成功,可以看到如下提示。

##升級指南
在升級前,請備份好系統的原始碼、資料等資訊,按照如下步驟進行操作。

獲取最新的 ModStart 原始碼包
全量覆蓋所有的原始碼
使用命令列進入到系統的根路徑,執行 php artisan migrate,重新構建 public/asset 目錄和所有基礎服務程式碼;
使用命令列進入到系統的根路徑,執行 php artisan modstart:module-install-all,重新構建 public/vendor 目錄和所有擴充套件包程式碼。
快速開始
在日常開發中,最常見的即是增刪改查程式碼,使用ModStart開發此類功能,會變得非常簡單。

下面將會給大家介紹 ModStart 的使用方法,以及一個增刪改查頁面的基本構成。通過學習下面的內容將可以幫助大家快速理解這個系統的基本使用方法。

建立資料表
在Laravel的遷移目錄建立資料庫遷移檔案

class CreateNews extends Migration
{
    public function up()
    {
            Schema::create('news', function (Blueprint $table) {
                $table->increments('id');
                $table->timestamps();
                $table->string('title', 200)->nullable()->comment('');
                $table->string('cover', 200)->nullable()->comment('');
                $table->string('summary', 200)->nullable()->comment('');
                $table->text('content')->nullable()->comment('');
            });
        }
    }
    public function down()
    {
    }
}

建立控制器
增加路由控制器程式碼,同時按照

class NewsController extends Controller
{
    use HasAdminQuickCRUD;
    protected function crud(AdminCRUDBuilder $builder)
    {
        $builder
            ->init('news')
            ->field(function ($builder) {
                $builder->id('id','ID');
                $builder->text('title', '名稱');
                $builder->image('cover', '封面');
                $builder->textarea('summary', '摘要');
                $builder->richHtml('content', '內容');
                $builder->display('created_at', '建立時間');
                $builder->display('updated_at', '更新時間');
            })
            ->gridFilter(function (GridFilter $filter) {
                $filter->eq('id', 'ID');
                $filter->like('title', '標題');
            })
            ->title('新聞管理');
    }
}

增加路由和導航
在 routes.php 增加路由資訊

$router->match(['get', 'post'], 'news/news', 'NewsController@index');
$router->match(['get', 'post'], 'news/news/add', 'NewsController@add');
$router->match(['get', 'post'], 'news/news/edit', 'NewsController@edit');
$router->match(['get', 'post'], 'news/news/delete', 'NewsController@delete');
$router->match(['get', 'post'], 'news/news/show', 'NewsController@show');

在 ModuleServiceProvider.php 中註冊選單資訊

AdminMenu::register(function () {
  return [
    [
      'title' => '新聞管理',
      'icon' => 'list',
      'sort' => 150,
      'url' => '\App\Admin\Controller\NewsController@index',
    ]
  ];
});
``````php
AdminMenu::register(function () {
  return [
    [
      'title' => '新聞管理',
      'icon' => 'list',
      'sort' => 150,
      'url' => '\App\Admin\Controller\NewsController@index',
    ]
  ];
});
``````php
AdminMenu::register(function () {
  return [
    [
      'title' => '新聞管理',
      'icon' => 'list',
      'sort' => 150,
      'url' => '\App\Admin\Controller\NewsController@index',
    ]
  ];
});
``````php
AdminMenu::register(function () {
  return [
    [
      'title' => '新聞管理',
      'icon' => 'list',
      'sort' => 150,
      'url' => '\App\Admin\Controller\NewsController@index',
    ]
  ];
});

開發完成
這樣一個簡單的增刪改查頁面就開發完成了

開發前必讀
開發前的配置
開發環境請開啟 debug 模式(即在 .env 檔案中設定 APP_DEBUG=true )

公共樣式
ModStart 使用了一些基礎樣式對頁面進行佈局,既簡單又強大,開始開發前需要對此有所瞭解。

公共樣式對編寫頁面元件非常有幫助,能顯著提高開發效率,建議編寫元件前先查閱一遍文件。

LICENSE
Apache 2.0

本作品採用《CC 協議》,轉載必須註明作者和本文連結

相關文章