The Kiwa Console

This page is about the Kiwa Console, a CLI tool which helps to handle a website made with Kiwa.

Table of contents

Installation

The console is a separate package made for the use with Composer. Add it to your project by running

$ composer require kiwa/console

The console is now available under bin/console. Run it without any arguments to get a list of all commands:

$ php bin/console

Each command has its own help text which you can display with the --help option, for example:

$ php bin/console page:create --help
The easiest way to create a website with Kiwa is using the Website Skeleton, which loads the `kiwa/core` along with the `kiwa/console` as dependencies.

Available commands

Command Description
page:create Creates a new page.
config:validate Validates the config file.
config:convert Converts the config file into another format.
url:define Defines the URL structure.
language:define Defines the language handling.
basic:metatags Defines basic meta tags.
translation:find-missing Finds missing translations.
translation:unused:remove Removes unused translations.
translation:sort Sorts all translations.
translation:clear Clears all translation files.
assets:install Installs all asset files.
asset:attribute-cache:create Creates an asset attribute cache.
htaccess:create Creates a .htaccess file.
robotstxt:create Creates a robots.txt file.
files:update Updates all static files.
server:start Starts a local PHP server.
cache:clear Deletes all cache files.
introduction Shows the introduction.
composer:json:update Updates the composer.json file.

Creating pages

The page:create command creates a new page. The command asks for the page name, the phtml file, the page type and the title and description. Read the full example in Getting started.

Handling the configuration

  • config:validate checks your config file for common mistakes, for example missing meta tags or language settings which don't match your pages.
  • config:convert converts the config file into another format. You can pass one of the values yaml, php-method or php-flat as argument.
  • url:define is an interactive command to define the URL structure, including the settings for www and SSL. Afterwards it offers to create the .htaccess file directly.
  • language:define is an interactive command for the language handling, asking whether visitors may switch between language versions and which the default language is.
  • basic:metatags is an interactive command to define the basic meta tags of your website.

Handling translations

The translation commands work on the files inside the language folder:

  • translation:find-missing scans your phtml files for texts printed with the Text class and compares them with the existing language files. Found texts can be added directly, and with the stichoza/google-translate-php library installed, they can be translated automatically.
  • translation:unused:remove searches for texts which are stored in the language files but can't be found in your code and removes them.
  • translation:sort sorts all translations alphabetically, case-insensitive.
  • translation:clear removes all translations where the source text equals the translation, for example when a text has not been translated yet.

Read more about translations under the section Languages and Translations.

Handling assets

  • assets:install installs the asset files coming from Node. It detects Yarn first and falls back to NPM.
  • asset:attribute-cache:create takes all asset files of a given folder and creates cache files with their attributes (for example width and height). These cache files are then used by the Source Collection extension automatically.

Creating static files

  • htaccess:create creates a .htaccess file depending on your config (useSSL, useWWW). If the config contains values for a basic authentication, it will also create the .htpasswd file. Read more about the settings under the section The configuration.
  • robotstxt:create creates a robots.txt file from your config. If a sitemap.xml is found, a Sitemap: line will be added, too. Read more under the section Robots.txt and Sitemap.xml.
  • files:update updates all static files like bin/console or public/index.php to the current version.
  • cache:clear deletes all files inside the cache folder, including all cached HTML pages and the compiled route cache.
  • composer:json:update adds the Kiwa-related scripts to your composer.json.

Running the website

  • server:start starts a local PHP server. It takes an optional address (default 127.0.0.1:8000) and the router script. If the given port is busy, the console looks for the nearest free port. Read more under the section Getting started.

Help

You can find the source of the Kiwa Console under bitbucket.org/wirbelwild/kiwa-console.

If you have any questions, feel free to contact us under hello@bitandblack.com.