Download the PHP package zacksleo/yii2-plugin without Composer

On this page you can find all versions of the php package zacksleo/yii2-plugin. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package yii2-plugin

Plugin Module

Latest Stable Version Total Downloads License

Languages: 中文


cp

FEATURES

Module Usage

Install

Add these array in the project config (if you have more than one entries,add these in both of them)

'components' =>[
    'plugin' => [
        'class' => 'zacksleo\yii2\plugin\components\HookRender'
    ],
],

'modules' => [

    'plugin' => [
        'class' => 'zacksleo\yii2\plugin\Module',
        'layout' => 'layout',
        'layoutPath' => '@vendor/zacksleo/yii2-backend/src/views/layouts', #布局
        'pluginRoot' => '@vendor/moguyun-plugins/', ##放置插件的namespace目录
        'pluginNamespace' => '@moguyun/plugins',  ##放置插件的namespace
    ],  
]

Create table

Link to plugin control panel

The CP url is :

$this->createUrl(['/plugin/plugin-manage/index']);

Add hooks in the views

#just add this to the position you want to be hooked
Yii::$app->plugin->render('Hook_Name');   # Name the Hook Position and told it to your plugin developers. 

Plugin Develop

Create A Plugin

For Create a plugin, you need to inherit the class Plugin.

And the class name and class file name should end with the word Plugin. For expamle, file ExamplePlugin.php:

class ExamplePlugin extends Plugin {
    //codes here
}

The word Example (without word Plugin) is the plugin's identify (case sensitive).

Implement The Plugin

To implement the plugin and makes it work, you should inherit these method and initialize some properties.

class ExamplePlugin extends Plugin {

    public function init() {                    #initialize,config plugin's info, required
        // set plugin's info
        $this->identify = 'Example';            #required, the Unique id for this plugin.
        $this->name = 'Example Plugin';         #required, plugin's name for display.
        $this->version = '1.0';
        $this->description = 'description here';
        $this->copyright = '© Robin <[email protected]>';
        $this->website = 'http://example.com';   
        $this->icon = 'icon.png'; #max to 72*72, if not set a default icon will display in the admin cp;
    }

    // return hooks array which this plugin want to hook, the value is the method's name
    // for the hook.
    public function hooks(){
        return array(
            //'Hook Position Name' => 'hook method';
            'Hook_Index_Header' => 'header',
        );
    }

    // method for hook
    public function header(){
        // some codes here
        echo 'This will echo a sting at position Hook_Index_Header';
    }

    // If you want to display a page with an url instead of render as a widget,
    // you need to write a method begin with the word "action", the word after 
    // "action" is the action's name.
    // e.g.:
    public function actionPage() {
        echo "This action have a url like this (with url rewrite):";
        # domain/plugin<Module>/plugin<controller name>/index<router action name>
        # ?id=xx<plugin identify>&action=xxx<action name>
        echo "You_Domain.com/plugin/plugin/index?id=example&action=page";

        #You can create this url by call method 'createUrl'
        echo $this->createUrl('page',array('param'=>'test'));
    }

    public function actionExample(){
        # this action is named with plugin's identify,
        # param $action could be empty or false value
        echo $this->createUrl();
    }      

    // If your plugin allow to set configs at the admin control panel
    // You need to inherit this:

    public function admincp() {
        // You can put codes here.
        // Like some inputs
        $this->setSetting('key','value');   # write setting
        echo $this->getSetting('key');      # read setting
    }

    // Here you can put some code at the Installation and Uninstallation
    public function install() {
        //codes here
        $sql = "create `tbl_xxxxxx` .....";     # write sql with a table prefix 
        $this->query($sql,'tbl_');              # and pass it at method query
                                                # as default, it is 'tbl_'
        return true; #This method need to return true, or the installation will fail.
    }

    public function uninstall() {
        // just like the method install.
        return true; #This method need to return true, or the uninstallation will fail.
    }

    // Then, you created a simple plugin
    // For advanced usage, see demos
}

All versions of yii2-plugin with dependencies

PHP Build Version
Package Version
Requires yiisoft/yii2 Version *
yiisoft/yii2-bootstrap Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package zacksleo/yii2-plugin contains the following files

Loading the files please wait ....