# Set of installation checks for AuthStack


## Installation

`composer require "authstack/installer: *"`

## Adding service providers

Open `config/app.php` and add the following to `providers` array:

```
'providers' => array(

    AuthStack\Installer\Provider\LicenseCheckerProvider::class,
    AuthStack\Installer\Provider\MySQLConnectionCheckerProvider::class,
);

```

## Checking the license 

```

use AuthStack\Installer\Facade\LicenseChecker;

$license = $request->input('license');
$domain = $request->server('HTTP_HOST');

/**
 * if successful, returns AuthStack\Installer\Model\License
 * on failure returns false
 */
$result = LicenseChecker::verify($license, $domain);

if(false === $result)
{
    return response()->json(['license' => LicenseChecker::getErrors()], 422);
}

return response()->json($result->toArray());


```

## Checking MySQL connectivity

```

use AuthStack\Installer\Facade\MySQLConnectionChecker;

$host = '127.0.0.1';
$dbname = 'test';
$username = 'username';
$password = 'password';
$port = 3306;

$result = MySQLConnectionChecker::verify($host, $dbname, $username, $password, $port);

if(false === $result)
{
    return response()->json(['mysql' => MySQLConnectionChecker::getErrors()], 422);
}

return response()->json($result->toArray()]);

```