PHP code example of mazahaler / project-connection-checker
1. Go to this page and download the library: Download mazahaler/project-connection-checker library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mazahaler / project-connection-checker example snippets
use mazahaler\ProjectConnectionChecker\ProjectConnectionChecker;
/**
* Check secrets, db connections and mailing
* @param 1: Root path of the project
* @param 2: Path to secrets.json
* @param 3: \yii\swiftmailer\Mailer class
* @param 4: Array of db connections in format: ['Your connection title(used for error output)' => [Instance of \yii\db\Connection | \yii\mongodb\Connection]]
*/
ProjectConnectionChecker::checkAll(\Yii::getAlias('@app'), \Yii::getAlias('@app') . '/secrets/secrets.json', \Yii::$app->mailer, ['mysql' => [\Yii::$app->db], 'mongodb' => [\Yii::$app->mongodb]]);
// OR check it separately:
ProjectConnectionChecker::checkSecrets(\Yii::getAlias('@app'), \Yii::getAlias('@app') . '/secrets/secrets.json');
ProjectConnectionChecker::checkMailing(\Yii::$app->mailer);
ProjectConnectionChecker::checkConnections(['mysql' => [\Yii::$app->db], 'mongodb' => [\Yii::$app->mongodb]]);