Ayuco
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. | |
tests | Unit test (WordPress Test Suite and PHPUnit) setup wizard. |
Add Command
Adds hooks, models, and assets.
php ayuco add {object}:{name} {params...}
{object} | {name} | {params} |
action | Wordpress action hook name. | (1) View or controller handler. |
filter | Wordpress filter hook name. | (1) View or controller handler. |
shortcode | Shortcode 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. |
--audit | Inserts a comment with the date in which Ayuco added the hook in the project. |
--void | Removes the `@return` comment tag in a controller handler. |
--nopretty | Prevents 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} |
view | View key ID. | |
controller | Controller handler. | |
model | Model class name. | |
postmodel | Model class name. Data storage: Posts. | (1) Post type |
optionmodel | Model class name. Data storage: Options. | (1) Model ID |
usermodel | Model class name. Data storage: Users. | |
termmodel | Model class name. Data storage: Terms and Taxonomies. | (1) Optional taxonomy name. |
commentmodel | Model class name. | |
js | JavaScript asset filename. | (1) Optional script template. |
css | CSS asset filename. | |
sass | SASS asset filename (master or partial file). | (1) Optional the name of the master file to import into. |
scss | SCSS 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. |
--void | Removes the `@return` comment tag from a controller method. |
--nopretty | Prevents 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} |
widget | Widget class name. | |
type | Register a custom post type and automated post model. | (1) Model class name. (2) Controller class name. |
model | Model class name. | |
asset | Asset 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. |
--nopretty | Prevents 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} |
version | Project version (i.e. 1.3.7 ). | |
domain | Text domain name, without spaces, symbols or caps. | |
author | ||
namespace | Name 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 ). | |
po | Locale to create (i.e. en_US ). | (1) Optional default language code to use for POT (by default en ). |
mo | Locale to create (i.e. en_US ). | |
translations | Locale 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:
--clear | This 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();