Creating a Module
How it works
There is a distinction between primary
and secondary
modules.
You create a module by using emvicy
on CLI. The creation of the necessary environment config file (e.g. 'develop.php') during this module creation process depends on which MVC_ENV
is set in /.env
(see /1.x/configuration#Environment).
primary
module
You develop your application in a primary
module.
That primary
module is also stored by name in the globally available config $aConfig['MVC_MODULE_PRIMARY_NAME']
and is also available via Config::get_MVC_MODULE_PRIMARY_NAME()
.
The primary
module is the leading, tone-setting module.
You don't need to write secondary modules if you don't need one. Develop your application in a primary
module.
dotfile .primary
A primary module needs to have the dotfile .primary
in its root folder. There can only be one module having a .primary
dotfile at once.
If you add a module by following Creating a primary
Module, the .primary
dotfile will be automatically created.
If you want so make a secondary module as the primary one, just move the .primary
dotfile to the secondary module.
.primary
secondary
module
But sometimes there are parts of code you want to reuse in other software projects.
For such a case secondary
modules are suitable. Code written here should be reused in other Emvicy software projects if necessary.
Conclusion
- You need to install at least one Module as primary to be able to work.
- You can only have one primary module at a time.
- You can have unlimited secondary modules.
Creating a primary
Module
use one of the following commands to create a primary module
php emvicy c module:foo # creates primary module "Foo"; asks if modulename is correct
php emvicy c module:foo force:no # same
php emvicy c module:foo force:yes # no asking - instantly creating of primary module "Foo"
php emvicy c module:foo primary:yes # creates primary module "Foo"; asks if modulename is correct
php emvicy c module:foo primary:yes force:no # same
php emvicy c module:foo primary:yes force:yes # no asking - instantly creating of primary module "Foo"
After creating a primary module, you could start Emvicy's local development server to test the module frontend
php emvicy s
Call http://127.0.0.1:1969/ and you will see your created module frontend
Creating a secondary
Module
use one of the following commands to create a secondary module
php emvicy c module:bar primary:no # creates module "Bar" as a secondary module; asks if modulename is correct
php emvicy c module:bar primary:no force:yes # no asking - instantly creating of secondary module "Bar"