Creating a Module


Introduction

Developing modules in Pyro is quite easy. By using a couple Artisan commands Pyro will do most of the work for you!

To get started run the make:addon command:

php artisan make:addon my_project.module.library

The above command will create a new addon in the /addons/{reference}. From here you can continue building up your module.

Module Class

The make:addon command will create an empty module class that looks like this:

<?php namespace MyProject\LibraryModule;

use Anomaly\Streams\Platform\Addon\Module\Module;

class LibraryModule extends Module
{

    /**
     * The navigation display flag.
     *
     * @var bool
     */            
    protected $navigation = true;

    /**
     * The addon icon.
     *
     * @var string
     */
    protected $icon = 'fa fa-puzzle-piece';

    /**
     * The module sections.
     *
     * @var array
     */
    protected $sections = [
        'example'
    ];
}

We will get into sections in more detail later but feel free to modify your module's icon with one found at Font-Awesome or Glyphicons.

Title and Name

You can edit the module's title (short), name (full), and description in the /resources/lang/{locale}/addon.php file.

Fields Migration

A migration for creating fields within your module's namespace (it's slug by default) will be generated in your addon's /migrations directory:

/migrations/2017_03_01_063944_my_project.module.library__create_library_fields.php

You can edit this migration to configure fields that will be created within the module's namespace when it's ran.

Service Provider

You will also notice that a service provider is created as well. You can read more about using service providers in the service providers section.