Creating a module in AvoRed is a nice way to extend the features of AvoRed E commerce.
- modules
- vendor-name (avored)
- module-name(helloworld)
- resources
- routes
- web.php
- src
- Module.php
- register.yaml
- Module.php
- module-name(helloworld)
- vendor-name (avored)
Register.yaml file the key to register most information about the modules. Things that needs to be careful here is your identifier neeeds to be unique.
identifier: avored-helloworld
description: AvoRed Hello World Module
namespace: Avored\Helloworld\
Module Source as it name suggest it contains all the .php
files of your modules. You must have an Provider.php
file and it should contain boot
and register
method where register method contains your module middleware or facade if you have any. boot
method register your view, routes, database migration and lang paths. Let say if you are creating an helloworld module then your provider.php
file should look like below.
<?php
namespace Avored\Helloworld;
use Illuminate\Support\ServiceProvider;
class Module extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
$this->registerResources();
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
}
/**
* Registering AvoRed Hello World Resource
* e.g. Route, View, Database & Translation Path
*
* @return void
*/
protected function registerResources()
{
$this->loadRoutesFrom(__DIR__ . '/../routes/web.php');
$this->loadTranslationsFrom(__DIR__ . '/../resources/lang', 'mage2-helloworld');
$this->loadViewsFrom(__DIR__ . '/../resources/views', 'mage2-helloworld');
}
}