WordPressMVC

  1. Get Started
  2. Documentation
  3. Tutorials
  4. Blog
  1. Documentation
  2. Tutorials
v1.0.8 Login
  • Blog
  • Download
  • Get Started
  • The Basics
    • Ayuco
    • Main Class
    • Configuration
  • Hooks
    • Actions
    • Filters
    • Widgets
    • Shortcodes
  • MVC
    • Models
    • Post Models
    • Option Models
    • Term Models
    • User Models
    • Views
    • Controllers
  • Resources
    • Assets
    • Styles
    • Scripts
  • Advanced
    • Request
    • Response
    • Localization
    • Cache
    • Logger
    • Database
    • Testing
    • Deployment
    • Functions
    • Add-ons

Ayuco

Last updated: February 8, 2023

Ayuco is the command-line interpreter used in the framework to implement Scaffolding.

The framework comes with a set of Ayuco commands to create models, create controllers, create views, add hooks, register widgets, and register post types.

Usage

To use Ayuco, the developer must open the command-line interface of preference, every OS comes with at least one, and change directory to the project's folder path (see installation). Once in position, the command should be typed and executed as follows:

php ayuco {command}

Commands List

Setup Command

Calls to the setup wizard.

php ayuco setup {wizard}

{wizard}Description
WordPress MVC framework setup wizard.
testsUnit test (WordPress Test Suite and PHPUnit) setup wizard.

Add Command

Adds hooks, models, and assets.

php ayuco add {object}:{name} {params...}
{object}{name}{params}
actionWordpress action hook name.(1) View or controller handler.
filterWordpress filter hook name. (1) View or controller handler.
shortcodeShortcode ID (shortcode key).(1) View or controller handler.

Sample:

php ayuco add action:init ConfigController@init

The following are optional argument options you can use in the command:

--comment="..."Inserts a related comment in the Main Class and a controller handler.
--auditInserts a comment with the date in which Ayuco added the hook in the project.
--voidRemoves the `@return` comment tag in a controller handler.
--noprettyPrevents code from being prettified.

Sample:

php ayuco add action:init --comment="Initializes configuration settings." --void

Create Command

Creates models, views and controllers.

php ayuco create {object}:{name} {params...}
{object}{name}{params}
viewView key ID.
controllerController handler.
modelModel class name.
postmodelModel class name. Data storage: Posts.(1) Post type
optionmodelModel class name. Data storage: Options. (1) Model ID
usermodelModel class name. Data storage: Users.
termmodelModel class name. Data storage: Terms and Taxonomies.(1) Optional taxonomy name.
commentmodelModel class name.
jsJavaScript asset filename.(1) Optional script template.
cssCSS asset filename.
sassSASS asset filename (master or partial file).(1) Optional the name of the master file to import into.
scssSCSS asset filename (master or partial file). (1) Optional the name of the master file to import into.

Sample:

php ayuco create view:admin.metaboxes.custom

The following are optional argument options you can use in the command:

--comment="..."Inserts a related comment in a controller or a model.
--voidRemoves the `@return` comment tag from a controller method.
--noprettyPrevents code from being prettified.

Sample:

php ayuco create model:Book --comment="Business books model."

Register Command

Register assets, widgets and custom post types.

php ayuco register {object}:{name} {params...}
{object}{name}{params}
widgetWidget class name.
typeRegister a custom post type and automated post model.(1) Model class name.
(2) Controller class name.
modelModel class name.
assetAsset relative path (i.e. css/admin.css).

Sample:

php ayuco register widget:HelloWorldWidget

The following are optional argument options you can use in the command:

--comment="..."Inserts a related comment in a widget or a custom-type model.
--noprettyPrevents code from being prettified.

Set Command

Sets project version, text-domain (for localization), and other configurations.

php ayuco set {object}:{name} {params...}
{object}{name}{params}
versionProject version (i.e. 1.3.7).
domainText domain name, without spaces, symbols or caps.
author
namespaceName of the new namespace.
license

Sample:

php ayuco set version:2.0.5
php ayuco set domain:my-custom-plugin
php ayuco set namespace:NewNamespace

Generate Command

Generate POT, PO, and MO files. Generate translations.

php ayuco generate {object}:{name} {params...}
{object}{name}{params}
pot(1) Optional default language code (by default en).
poLocale to create (i.e. en_US).(1) Optional default language code to use for POT (by default en).
moLocale to create (i.e. en_US).
translationsLocale to create (i.e. en_US).

Sample:

php ayuco generate pot
php ayuco generate po:es_ES
php ayuco generate mo:es_ES
php ayuco generate translations:es_ES

The following are optional argument options you can use in the command:

--clearThis argument deletes the existing PO file and generates it from scratch, existing translated translations will be lost. If this argument is not used, and a PO file exists, new translations found in the code will be appended to the PO file.

Prettify Command

Prettifies the PHP code inside the /app folder.

php ayuco prettify

Help Command

Displays a list of available commands.

php ayuco help

Custom Commands

Developers can add custom commands to Ayuco. The command must be created using ayuco's guidelines (GitHub) and then should be registered inside the "ayuco" file located at the project's root folder, new commands should be set between "BEGIN - Custom commands" and "END - Custom commands" comments.

require_once __DIR__.'/vendor/autoload.php';

use MyNamespace\MyCustomCommand;

$ayuco = get_ayuco( __DIR__ );
// BEGIN - Custom commands

$ayuco->register(new MyCustomCommand);

// END - Custom commands
$ayuco->interpret();
© 2023 10 Quality Studio . All rights reserved.
Search in: