2017-25 © Pedro Peláez
 

library loader

Modulatr

image

modulatr/loader

Modulatr

  • Wednesday, April 18, 2018
  • by willishq
  • Repository
  • 0 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Modulatr Loader

Software License Build Status Coverage Status Quality Score, (*1)

Package for creating and loading modules in PHP projects., (*2)

Installation via Composer

composer require modulatr/loader, (*3)

Usage

Modulatr is framework agnostic, although there are plans for implementing service providers for popular frameworks as and when requested., (*4)

To start with, create a new Module., (*5)

<?php

namespace App\Modules;

use Modulatr\Loader\Module;

class Example extends Module
{
    public function getId(): string
    {
        return 'example';
    }

    public function getServiceProviders(): array 
    {
        return [];
    }
}

Next, load the module into the ModuleLoader class, with the URI parts as the first parameter and a config array as the second:, (*6)

<?php

use Modulatr\Loader\ModuleLoader;
use App\Modules\Example;

$loader = new ModuleLoader(['example', 'index'], [
    'modules' => [
        Example::class,    
    ],
]);

In the above example, the URI passed to the module would be /example/index, (*7)

If you are using a framework such as Laravel, you might want to create the array from the route name (which may be example.index) in order to not tie your modules to the URI directly., (*8)

Now, if you call getCurrentModule() on the loader, you will be returned your module class, as it's ID is example and the URI array contains the string example., (*9)

The Versions

18/04 2018

dev-develop

dev-develop

Modulatr

  Sources   Download

The Requires

  • php ^7.2

 

The Development Requires