1. Home
  2. Docs
  3. Application Framework
  4. CLI Reference
  5. add-class


$ wp mwp add-class <slug> <classname>

This command adds a correctly namespaced class to your plugin in the /classes directory.


<slug> (required) The slug (directory) of the plugin to add to
<classname> (required) The name of the new class (namespaced relative to the plugin)
--type=<type> (optional) The type of class to scaffold. (‘generic’, ‘model’, ‘singleton’, ‘controller’)

When specifying a class using the --type parameter, the following values are allowed:

  • generic: Generate a bare bones class. This is the default if no type is specified.
  • model: Generate a class which extends the ActiveRecord class to be used for a model.
  • singleton: Generate a class which extends the Singleton class to be used for a singleton.
  • controller: Generate a generic controller class which extends the MWP\Framework\Pattern\Controller class.
  • model_controller: Generate a controller that can be used for CRUD management of ActiveRecord models.


$ wp mwp add-class acmecompany-gizmo Utility\Helper --type=singleton
Creating new plugin class file...
Class added successfully.

Was this article helpful to you? Yes No

How can we help?