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
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:validatechecks your config file for common mistakes, for example missing meta tags or language settings which don't match your pages.config:convertconverts the config file into another format. You can pass one of the valuesyaml,php-methodorphp-flatas argument.url:defineis an interactive command to define the URL structure, including the settings forwwwand SSL. Afterwards it offers to create the.htaccessfile directly.language:defineis an interactive command for the language handling, asking whether visitors may switch between language versions and which the default language is.basic:metatagsis 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-missingscans yourphtmlfiles for texts printed with theTextclass and compares them with the existing language files. Found texts can be added directly, and with thestichoza/google-translate-phplibrary installed, they can be translated automatically.translation:unused:removesearches for texts which are stored in the language files but can't be found in your code and removes them.translation:sortsorts all translations alphabetically, case-insensitive.translation:clearremoves 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:installinstalls the asset files coming from Node. It detects Yarn first and falls back to NPM.asset:attribute-cache:createtakes all asset files of a given folder and creates cache files with their attributes (for examplewidthandheight). These cache files are then used by the Source Collection extension automatically.
Creating static files
htaccess:createcreates a.htaccessfile depending on your config (useSSL,useWWW). If the config contains values for a basic authentication, it will also create the.htpasswdfile. Read more about the settings under the section The configuration.robotstxt:createcreates arobots.txtfile from your config. If asitemap.xmlis found, aSitemap:line will be added, too. Read more under the section Robots.txt and Sitemap.xml.files:updateupdates all static files likebin/consoleorpublic/index.phpto the current version.cache:cleardeletes all files inside the cache folder, including all cached HTML pages and the compiled route cache.composer:json:updateadds the Kiwa-related scripts to yourcomposer.json.
Running the website
server:startstarts a local PHP server. It takes an optional address (default127.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.