MyBB Community Forums

Full Version: CLI tools for MyBB (WIP - FEEDBACK WANTED)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Currently I am working on 2 set of CLI tools for MyBB, first one is a MyBB Installer, that easily allows downloading and extract the latest version of MyBB into a decided directory, second one is a CLI for your MyBB application, that will manage that specific application.

MyBB Installer
The MyBB Installer will become available for download using Composer:
composer global require ulties/mybb-installer (coming soon, will post here when its released)

After the installation, you can easily setup a new MyBB project using the cli tool:
mybb new forum
Which will download the latest version of MyBB and extract its files to a new folder called "forum".

Besides that the installer will by default add some recommended plugins and themes to the new MyBB application.
So far only the MyBB CLI plugin is added, but I would love to get recommendations for other plugins or themes to add by default.
Of cause this can be disabled with some command line flags.

MyBB CLI
The MyBB CLI will be a plugin for MyBB that empowers the MyBB application with command line tools to easier manage the application.

In the first version of the CLI, it will support running the MyBB installation script directly from the terminal instead of having to go over the installation manually.

This can be done like this:
cli install --db-engine=mysqli --db-host=mysql-host.my-site.com:1234 --db-user=mark --db-pass=secret --db-name=mybb --db-encoding=utf8 --db-prefix=mybb_ --forum-name="My Forum" --forum-url=http://mybbresources.com --website-name="My Site" --website-url="http://mybbresources.com" --cookie-domain=".mybbresources.com" --cookie-path="/" --contact-email="[email protected]" --admin-pin=1234 --admin-user=mark --admin-pass=secret [email protected]
The default values for the options are listed below:
--db-engine: mysqli
--db-host: localhost
--db-user: root
--db-pass: (EMPTY)
--db-name: mybb
--db-encoding: utf8
--db-prefix: mybb_
--forum-name: Forums
--forum-url: (NOT DECIDED YET - IF ANY)
--website-name: Your Website
--website-url: (NOT DECIDED YET - IF ANY)
--cookie-domain: (NOT DECIDED YET - IF ANY)
--cookie-path: /
--contact-email: (NOT DECIDED YET - IF ANY)
--admin-pin: (EMPTY)
--admin-user: admin
--admin-pass: secret
--admin-email: (NOT DECIDED YET - IF ANY)

Please share your ideas, thoughts and feedback for this.
+1, interesting!
Sounds interesting. Some of your ideas are what we have planned for the core so it may be worthwhile us working on it together. I believe Euan is going to stop by later and share some of his thoughts further.
There has been some changes to the default values of the CLI install command.

The default for the "--forum-url", "--website-url" and "--cookie-domain" options, will be "http://localhost" for urls and ".localhost" for cookie domain.
The default for the "--contact-email" option are taken from the variable "$_SERVER['SERVER_ADMIN']".

Besides that a new "--domain" option has been added, example "cli install --domain=foo.com" is a shortcode for this:
cli install --forum-url=http://foo.com --website-url=http://foo.com/ --cookie-domain=.foo.com [email protected]


Also the "--admin-email" will by default be the same as the "--contact-email".

Feedback is still welcome since I am still not finished with this plugin.

(2020-01-05, 04:30 PM)Ben Wrote: [ -> ]Sounds interesting. Some of your ideas are what we have planned for the core so it may be worthwhile us working on it together. I believe Euan is going to stop by later and share some of his thoughts further.

Sounds good. I will await Euan. However I am almost done with this, I will soon share the WIP version, for feedback and for the possiblility to merge some of this into core.

News on the CLI plugin, it will allow anyone to setup their own commands for the CLI tool.

Example of how commands can be loaded into the CLI tool.

function load_custom_cli_command($cli) {
    $cli->addCommand('install', new MyCommand());
}
$plugins->add_hook('cli_load_commands', 'load_custom_cli_command');
Hi Mark, how is the project going? It is interesting.
Hi, your project looks promising, keep it up.