This website uses Cookies to provide you with the best possible service. Please see our Privacy Policy for more information. Click the check box below to accept cookies. Then confirm with a click on "Save".  
Status: 2023-11-19

Creating a Module


How it works

There is a distinction between primary and secondary modules.

You create a module by using emvicy.php 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 /3.4.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_CURRENT_NAME'] and is also available via Config::get_MVC_MODULE_CURRENT_NAME().

Only the configurations from this module are loaded automatically.

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.

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 myMVC software projects if necessary. For this version of myMVC there are already some secondary, public myMVC modules out there for reuse.

Public available modules:


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.php c module=foo;                       # creates primary module "Foo"; asks if modulename is correct
php emvicy.php c module=foo force=no;              # same
php emvicy.php c module=foo force=yes;             # no asking - instantly creating of primary module "Foo"
php emvicy.php c module=foo primary=yes;           # creates primary module "Foo"; asks if modulename is correct
php emvicy.php c module=foo primary=yes force=no;  # same
php emvicy.php c module=foo primary=yes force=yes; # no asking - instantly creating of primary module "Foo"

After creating a primary module, you could start myMVC's local development server to test the module frontend

php emvicy.php s

Call http://127.0.0.1:1969/ and you will see your created module frontend

myMVC Creating a Module


Creating a secondary Module

use one of the following commands to create a secondary module

php emvicy.php c module=bar primary=no             # creates module "Bar" as a secondary module; asks if modulename is correct
php emvicy.php c module=bar primary=no force=no;   # same
php emvicy.php c module=bar primary=no force=yes;  # no asking - instantly creating of secondary module "Baz"