Model
Quick start
creates Model Bar
in the given module Foo
php emvicy module:createModel Bar Foo
- If module
Foo
does not exist, it will be created as a primary if possible, otherwise as a secondary one.
Find out more about Models, for example on wikipedia, "Model–view–controller#Model", 2023-12-28
Class
There are no specific restrictions regarding a model class. For example, methods can have any visibility, the class can also follow the singleton pattern, etc.
writing the Model class
- Place the Model Class inside your module's Model folder (see /modules/{moduleName}/Model/
- Use a Pascal Case Name (see wiki.c2.com/?PascalCase) for the Class file
Illustration: Module Foo
, Model Bar
with static method doSomething
<?php
namespace Foo\Model;
class Bar
{
/**
* @param int $iValue
* @return void
*/
public static function doSomething(int $iValue)
{
// your code …
}
}