Install Amelia Booking plugin : error 500

Hi all,

as i ran into the same issue, i started to investigate further into this.
The issue is caused by using a non standard port for MySQL on LocalWP.

The Amelia Plugin API Calls try to connect to the the database using the standard port 3306.
Sadly, there is currently no easy way to set the port.

The classes (SLIM Framework) used by amelia does have a variable for the port, but it’s not read / taken into account during the initialisation process of connecting to the database.

This can be found in the script:
Infrastucture → ContainerConfig → container.php

Around these lines (73-89):

 if (!extension_loaded('pdo_mysql') || $mysqliEnabled) {
        return new \AmeliaBooking\Infrastructure\DB\MySQLi\Connection(
            $config('host'),
            $config('database'),
            $config('username'),
            $config('password'),
            $config('charset')
        );
    }

    return new \AmeliaBooking\Infrastructure\DB\PDO\Connection(
        $config('host'),
        $config('database'),
        $config('username'),
        $config('password'),
        $config('charset')
    );

Adding the Port you find in your localWP Database Config page, as last parameter, will solve this issue, as long as you don’t update the plugin.

 if (!extension_loaded('pdo_mysql') || $mysqliEnabled) {
        return new \AmeliaBooking\Infrastructure\DB\MySQLi\Connection(
            $config('host'),
            $config('database'),
            $config('username'),
            $config('password'),
            $config('charset'),
            10012 // Custom PORT 
        );
    }

    return new \AmeliaBooking\Infrastructure\DB\PDO\Connection(
        $config('host'),
        $config('database'),
        $config('username'),
        $config('password'),
        $config('charset'),
        10012 // Custom PORT 
    );

I would expect Amelia to fix this with a custom setting.

Regards
Frank