Link Search Menu Expand Document

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:

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);

Next section