Download the PHP package mgrechanik/yii2-universal-module-sceleton without Composer

On this page you can find all versions of the php package mgrechanik/yii2-universal-module-sceleton. 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-universal-module-sceleton

Yii2 universal module sceleton

Русская версия

Table of contents


Goal

This extension gives the structure of the module which:

  1. will be self-sufficient and portable because it holds all his functionality in one place
  2. logically divided at backend and frontend parts
  3. easily connects both to Advanced and Basic application templates
  4. with Basic application template:

    • connects to module section only one time
    • there is functionality of protection to all backend controllers (for admin part of your web site)
  5. it is easy to inherit such modules from one another to override functionality without controllers duplication

Installing

The preferred way to install this extension is through composer.:

Either run

or add

to the require section of your composer.json


What it is about


Using

1) Generate, or create manually, your module class

2) Inherit your module class from universal module class

3) Now create (or generate) frontend controller

, where match .
When the name and class of controller do not match use next definition form: .

Always when you create new controller do not forget to define it in appropriate controller map of your module.

You are not required to inherit your controller classes from any parent type.

4) Now create (or generate) backend controller

5) Done, your module is ready, you can connect it to application:

config/main.php:

, do not forget to define - mode

It is comfortable to connect all such modules at first level of application modules, without nested modules but like a simple list of modules we used to see at admin pages of popular CMSs, which also gives short urls.


Module inheritance

When you inherit your module class from existing one without overriding and the next happens: 1) These two properties will be taken from parent naturally 2) But the basic controller namespace will be set to your module namespace. You do not have such controllers and you do not want to create their copies 3) There are next opportunities how to make your module to use controllers from any of his ancestors:


Module settings

Connecting module to application we can use next it's properties:

- mode in which this module works

You are required to set up it. Details

- layout for backend controllers

Sets up to module when backend controller is requested.
It is useful for Basic application template.

- frontend controller map

Details

- backend controller map

Details

- callback for final adjustment of controller map

After module's controller map is generated you can adjust it with this function which signature is:

- backend controllers settings

When module creates backend controller it could set up controller with these properties.

It is handy, for example, to restrict access to such controllers using yii filters connected like behaviors.

Example of using.

- frontend controllers settings

It is the same like

- the basic namespace for the controllers the module uses

By default it is not used and controllers will be searched relevant to your current module namespace.
But with this property you can tell to take controllers from any other module

- whether to take controllers from parent

It is by default, meaning no taking.
But with this property you can tell to take controllers from immediate parent of current module

- basic path where to find module's

By default it is not used.
It is automatically set up whether to current module directory or relevant to the two properties above when they are set.
But with this property you can finally say where to search for . Example of value:


Example of module's set up with Basic application template

Lets suppose that we have two modules we are talking about - and .
Here is working configs to set up these modules:

config/params.php:

At this config we gave permission to "admin pages" only to one user , with additional check for .

config/web.php:


How-to

Make all admin urls start with

Lets see Basic application template with two "our" modules connected to it:

If we followed advice above about naming of backend controllers all of them have names like .
So urls to them will be and .
And we want all our admin urls to start with .

It is easily achived with the next two for your :

Generating backend functionality with Gii CRUD generator

You can easily generate CRUD functionality considering that:

How to connect the module to console application?

If our module has console commands who reside for example here:

, then in the console application config this module is connected like:

Where to put all other module's functionality?

This module regulates only directory structure described above where only from controllers and views their concrete positions are expected.
When writing the rest of functionality you may follow the next advices:

For example for models:


All versions of yii2-universal-module-sceleton with dependencies

PHP Build Version
Package Version
Requires yiisoft/yii2 Version ~2.0
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 mgrechanik/yii2-universal-module-sceleton contains the following files

Loading the files please wait ....