shlinkio/shlink-installer

A PHP command line tool used to install shlink

v4.1.0 2020-02-15 19:13 UTC

This package is auto-updated.

Last update: 2020-02-15 19:14:18 UTC


README

A PHP command line tool used to install shlink.

Build Status Code Coverage Scrutinizer Code Quality Latest Stable Version License Paypal donate

Shlink installer

Installation

Install this tool using composer.

composer install shlinkio/shlink-installer

Usage

This is the command line tool used by shlink to guide you through the installation process.

The tool expects the active directory to be a valid shlink instance.

There are two main ways to run this tool:

  • Using the built-in CLI entry points.

    Run either vendor/bin/shlink-install or vendor/bin/shlink-update in order to install or update a shlink instance.

  • Using the bin/run.php helper script.

    This script returns two functions that can be used to either install or update a shlink instance.

    Just require it and invoke the appropriate function:

    <?php
    
    declare(strict_types=1);
    
    [$install, $update] = require 'vendor/shlinkio/shlink-installer/bin/run.php';
    $install(); // To install
    $update(); // To update

Customize options

Questions to ask the user

In order to retain backwards compatibility, it is possible to configure the installer to ask just a specific subset of questions.

Add a configuration file including a configuration like this:

<?php

declare(strict_types=1);

use Shlinkio\Shlink\Installer\Config\Option;

return [

    'installer' => [
        'enabled_options' => [
            Option\DatabaseDriverConfigOption::class,
            Option\DatabaseHostConfigOption::class,
            Option\BasePathConfigOption::class,
            Option\Regular404RedirectConfigOption::class,
            Option\ShortDomainHostConfigOption::class,
            Option\ShortDomainSchemaConfigOption::class,
        ],
    ],

];

If installer.enabled_options is not provided at all, all the config options will be asked.

Commands to run after installation

After the user has been asked for all the config, the installer will run a set of scripts which will create/update the database, download assets, etc.

It is possible to overwrite those commands via configuration too, using a syntax like this:

<?php

declare(strict_types=1);

return [

    'installer' => [
        'installation_commands' => [
            'db_create_schema' => [
                'command' => 'bin/shlink shlink:db:create',
            ],
            'db_migrate' => [
                'command' => 'bin/some-script some:command',
            ],
            'orm_proxies' => [
                'command' => '-v', // Just print PHP version
            ],
        ],
    ],

];

This example shows all the currently available commands. They are run in the order they have been set here.

Important: Take into consideration that all the commands must be PHP scripts, since the installer will prefix all of them with the php binary.