TGViewer
PWRTelegram API channel PWRTelegram API channel @pwrtelegram · 728 subscribers
Post #497 6.37K

Forwarded from MadelineProto | Official Channel (Daniil Gentili)

> What is AMPHP (https://amphp.org)?

Amp is a non-blocking concurrency framework for PHP providing primitives to manage concurrency such as an event loop, promises, and asynchronous iterators.

> OK, in simpler words?

AMPHP is a high-performance, parallelized PHP library that allows you to write extremely fast, efficient programs that work in parallel using green threads.

> * b r a i n m e l t *

Y E S

———

MadelineProto is not written in PHP: MadelineProto is written using AMPHP.
What this means is that when you using MadelineProto (and async is enabled), all incoming messages are handled in parallel, each in a separate thread, even on webhosts.

This allow your bots to always be responsive, even while executing complex tasks.

However, it is vital that you also use AMPHP (not PHP!) when writing your bot.
What this means is that the following PHP functions and extensions cannot be used in MadelineProto bots (otherwise, all the benefits of AMPHP would be nullified): instead, you must use the correct AMPHP library (automatically included in madeline.php).

❌ file_get_contents
✅ amphp/file for files, amphp/http-client and $MadelineProto->fileGetContents for URLs

❌ curl, guzzle
✅ amphp/http-client is async, much faster than other libraries, and also supports HTTP/2!

❌ mysqli, PDO, sqlite
✅ amphp/mysql supports both MySQL and SQLite backends, and is fully async!
❔You can also use amphp/postgres and amphp/redis for PostgreSQL and Redis!

❌ php-fpm
✅ amphp/http-server is a high-performance async HTTP/2 server, that can be interfaced with MadelineProto to create file download servers!

❌ include, require
❓ Don't use this function very often, and most importantly, don't use it inside of the event handler code.
❔ You should use it only once on bot startup, or else when reloading the bot (plugin source coming soon!)

———

In short, AMPHP is an awesome framework for using async PHP in 2020: you can join the official Telegram support group @amphpchat if you have any questions or suggestions on what else to add to AMPHP!
amphp.org Asynchronous Multitasking PHP Amp is a non-blocking concurrency library for PHP based on Revolt.
More from @pwrtelegram
  1. May 11, 2025And then, a long overdue post about my Autonomous System (AS198747), and an over more over…
  2. May 11, 2025The first series of posts I'll be adding here will be some technical deep dives into the p…
  3. May 11, 2025Happy to announce I've launched a blog, where I'll be posting news about all my different…
  4. Aug 25, 2024#FreeDurov.
  5. May 30, 2024MadelineProto was updated! MadelineProto 8.1.0 introduces an official Grafana dashboard fo…
  6. Apr 27, 2024MadelineProto was updated! 8.0.0 is the first stable release of MadelineProto v8! For the…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →