Git Product home page Git Product logo

devtools's Introduction

Modules - Getting Started

Basically modules in HumHub are identical to Yii2 modules http://www.yiiframework.com/doc-2.0/guide-structure-modules.html.

You can use either the Yii's module base class [[yii\base\Module]] or the enhanced HumHub module base class [[humhub\components\Module]].

The enhanced HumHub module class provides additional features like:

  • Dynamic module management (enable / disable / install / uninstall) via administration interface
  • Usable as Space or User Profile module

Installation (for dummies)

cd /path/to/your/humhub/protected/humhub/modules
git clone https://github.com/humhub/humhub-modules-devtools.git devtools

On the web go to Administration->Modules and you will see the devtools module. Enable it :)

Quick start with HumHub Module Generator

You can use the HumHub module generator to quickly create a basic module for you to build on top of.

Enabling the Module Generator

The module generator extends Gii, a code generation tool for the Yii framework. As such, you must enable Gii and configure it to use HumHub's generators.

Web

Add the following to your web configuration (/protected/config/web.php) to enable the generator on the Gii web UI.

HumHub Only
return [
    'modules' => [
        'gii' => [
            'class' => 'humhub\modules\devtools\gii\Module',
            'allowedIPs' => ['127.0.0.1', '::1'],
        ],
    ]
];
Yii Compatibility

Info: In order to use Yii default generators alongside HumHub Generators, add the following configuration instead.

return [
    'modules' => [
        'gii' => [
            'class' => 'yii\gii\Module',
            'allowedIPs' => ['127.0.0.1', '::1'],
            'generators' => [
                'module' => [
                    'class' => 'humhub\modules\devtools\gii\generators\ModuleGenerator',
                ]
            ],
        ],
    ]
];

You can then access Gii through the following URL:

http://localhost/path/to/index.php?r=gii

Or if you have enabled pretty URLs, you may use the following URL:

http://localhost/path/to/index.php/gii

You can then click the "Start" button for the HumHub Module Generator.

Console

Add the following to your console configuration (/protected/config/console.php) to enable the generator in your console.

return [
    // ...
    'bootstrap' => ['gii'],
    'modules' => [
        'gii' => [
            'class' => 'yii\gii\Module',
            'allowedIPs' => ['127.0.0.1', '::1'],

            'generators' => [
                'module' => [
                    'class' => 'humhub\modules\devtools\Generator',
                    'templates' => [
                        'humhub' => '@app/modules/devtools/default',
                    ]
                ]
            ],
        ],
    ],
    // ...
];

You can run the HumHub Module Generator via the command line as follows:

cd protected
php yii gii/module --moduleClass="app\modules\example\Module" --moduleID=example --template="humhub"

Manual Module Creation

config.php

If the module is placed inside the /protected/modules folder, you can create a config.php in the module directory which provides automatic loading without manually modifing the application config.

The config.php should return an array including following fields:

Example of a config.php file:

<?php

use johndoe\example\Module;
use humhub\widgets\TopMenu;

return [
    'id' => 'example',
    'class' => 'johndoe\example\Module',
    'namespace' => 'johndoe\example',
    'events' => [
        array('class' => TopMenu::className(), 'event' => TopMenu::EVENT_INIT, 'callback' => array('johndoe\example\Module', 'onTopMenuInit')),
    ]
];
?>

Note: Do not execute any code in the config.php - the result will be cached!

module.json

This file holds basic information about the module like name, description or current version. Locate this file in the root directory of the module.

{
    "id": "example",
    "name": "My Example Module",
    "description": "My testing module.",
    "keywords": ["my", "cool", "module"],
    "version": "1.0",
    "humhub": {
    "minVersion": "0.20"
    }
}

PHPDA

"dot.exe" -T "svg" "C:\Users\buddha\AppData\Local\Temp\gra28D0.tmp" -o "C:\Users\buddha\AppData\Local\Temp\gra8A71.tmp.svg"
.\vendor\bin\phpda.bat analyze phpda.yml

devtools's People

Contributors

archblood avatar benmag avatar buddh4 avatar felli avatar hunwalk avatar kesselb avatar luke- avatar themroc avatar

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.