Butterfly
  • Butterfly
  • Introduction
  • Changelog
  • Admin Panel
  • Audit Logs
  • Cloud
  • Commands
  • Data Manager
  • Data Types
  • Database
  • Designs
  • Introduction
  • Features
  • File Storage
  • Frontend
  • Generators
  • Helpers
  • Installation
  • Items
  • Migrations
  • Modules
  • Notification
  • Performance
  • Queue
  • Security
  • Settings
  • Smarty Helpers
  • Streams
  • Testing
  • Tutorials
  • Upgrade
  • Usage of Validator
  • Webservice
  • Swagger API Documentation Generator
  • CLI Commands
Powered by GitBook
On this page
  • Introduction
  • Modules of Butterfly
  • Butterfly\Core
  • Butterfly\Framework
  • Butterfly\Library
  • Module Structure
  • Enabling Modules

Modules

Introduction

Butterfly is extensible. You can extend system by using Modules.

[!DANGER] Purpose of Modules is make reusable code. Which means that, if your code is project specific, you can just keep it in project repository within app directory. If you are developing a new feature that can be used in other projects, than you can develop it as a Module.

Modules of Butterfly

Butterfly has 3 Modules out of box:

Butterfly\Core

Butterfly Core module handles admin panel operations. It has API access for all operations.

Butterfly\Framework

Butterfly Framework module has Base Classes for integrations like Database, Cache, Search etc.

Butterfly\Library

Butterfly Framework module has utility classes and functions like StringHelper, Utils. This is a legacy which will merge into Butterfly\Framework Module.

Module Structure

Every module has the following pieces:

  • module.yaml

Example yaml file content as follows:

name: 'Butterfly Framework Module'
namespace: 'Butterfly\Framework'
version: '1.0.0'
  • VendorName\ModuleName\Module class: This is an empty class extended from Butterfly\Framework\Module\Base

Example file:

<?php


namespace Butterfly\Framework;

use Butterfly\Framework\Module\Base;

class Module extends Base
{

}

Enabling Modules

In order to enable modules, first, you need to require the composer package from composer.

composer require vendorname\packagename;

In order to enable the Module, you need to add Module class reference to modules.php.

You can enable different modules in different domains. For example: You can enable your development module only in development domain. Please check config section for more details.

Example modules config file:

return [
    \Butterfly\Core\Module::class,
    \Butterfly\Framework\Module::class,
    \Butterfly\Library\Module::class
];

Note: Modules are initiated in the order of config array. You can change order in the array to manage dependencies.

PreviousMigrationsNextNotification

Last updated 3 years ago