1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-27 07:34:41 +01:00
MadelineProto/examples/database-config-examples/postgres.php

58 lines
1.1 KiB
PHP
Raw Normal View History

2022-12-30 21:54:44 +01:00
<?php
declare(strict_types=1);
use danog\MadelineProto\API;
2021-12-12 14:39:55 +01:00
use danog\MadelineProto\Settings;
2022-12-30 21:54:44 +01:00
use danog\MadelineProto\Settings\Database\Postgres;
2021-12-12 14:39:55 +01:00
/*
* load MadelineProto in Your Project
*/
2022-12-08 20:16:40 +01:00
if (file_exists('vendor/autoload.php')) {
include 'vendor/autoload.php';
} else {
2022-12-08 20:16:40 +01:00
if (!file_exists('madeline.php')) {
copy('https://phar.madelineproto.xyz/madeline.php', 'madeline.php');
}
include 'madeline.php';
}
2021-12-12 14:39:55 +01:00
/*
* create default Postgres object
*/
2022-12-30 21:54:44 +01:00
$database = new Postgres;
2021-12-12 14:39:55 +01:00
/*
config and set auth information
*/
$database->setUri('127.0.0.1:5432'); // postgres db default connection inforamtion
$database->setUsername('wsudo'); // postgres db username
$database->setPassword('12345678'); // postgres db password
$database->setDatabase('MyBotsData');// which database madeline proto will store datas in that
2021-12-12 14:39:55 +01:00
/*
create default settings object
*/
$settings = new Settings;
2021-12-12 14:39:55 +01:00
/*
set and merge database settings to main settings
*/
$settings->setDb($database);
2021-12-12 14:39:55 +01:00
/*
create madeline proto session
*/
2021-12-12 14:39:55 +01:00
$MadelineProto = new API('madeline.session', $settings);
2021-12-12 14:39:55 +01:00
/*
start madeline proto workers
*/
$MadelineProto->start();