Settings
MadelineProto has lots of settings that can be used to modify the behaviour of the library.
These settings are controlled by the following classes in the \danog\MadelineProto\Settings
namespace:
- AppInfo: App information.
- Auth: Cryptography settings.
- Connection: Connection settings.
- Files: File management settings.
- Logger: Logger settings.
- Peer: Peer database settings.
- Pwr: PWRTelegram settings.
- RPC: RPC settings.
- SecretChats: Secret chat settings.
- Serialization: Serialization settings.
- TLSchema: TL schema settings.
- Templates: Web and CLI template settings for login.
- VoIP: VoIP settings.
- Database\Memory: Memory backend settings.
- Database\Mysql: MySQL backend settings.
- Database\Postgres: Postgres backend settings.
- Database\Redis: Redis backend settings.
These classes can be instantiated and passed individually to MadelineProto:
$settings = (new \danog\MadelineProto\Settings\AppInfo)
->setApiId(124)
->setApiHash('xx');
$API = new \danog\MadelineProto\API('session.madeline', $settings);
It’s heavily recommended to remove (or pass null) the second $settings
parameter passed to the constructor once the instance is logged in, to avoid the performance overhead of needlessly updating settings every time API is instantiated:
To modify the settings of an already created instance, updateSettings
should be used, instead:
$settings = (new \danog\MadelineProto\Settings\AppInfo)
->setApiId(124)
->setApiHash('xx');
$MadelineProto->updateSettings($settings);
It’s recommended you create a separate file that accesses the session just to modify the settings, as it’s a very rare operation.
You can also group settings in a single \danog\MadelineProto\Settings object, to quickly modify multiple settings:
See here » for more info on how to get and modify the instances of each subsetting class mentioned at the beginning of this page.
$settings = new \danog\MadelineProto\Settings;
$settings->setDb((new \danog\MadelineProto\Settings\Database\Mysql)
->setUri('tcp://localhost')
->setPassword('pass')
);
$settings->setAppInfo((new \danog\MadelineProto\Settings\AppInfo)
->setApiId(124)
->setApiHash('xx')
);
$settings->getFiles()->setUploadParallelChunks(100);
$MadelineProto->updateSettings($settings);