Download the PHP package williamson/laragram without Composer
On this page you can find all versions of the php package williamson/laragram. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download williamson/laragram
More information about williamson/laragram
Files in williamson/laragram
Package laragram
Short Description A Laravel Wrapper for telegram-cli
License MPL-2.0
Informations about the package laragram
Laravel Wrapper for telegram-cli
This project was originally forked from: php-telegram-cli-client and credit to zyberspace for the start I needed to get this project working.
What is new in 1.0?
- To make the laravel service provider "deferred" (performance enhancing feature), you must now manually register the
TG
alias in theconfig/app.php
alias section.
What is it?
This project allows you to use the lovely Laravel syntax you are familar with to quickly and easily send messages / images / documents / audio files / location via Telegram Messenger with the aid of telegram-cli running on your server.
It allows you do things like:
or
or
Of course if you don't like using Facades you can always revert to
Requirements
- A running telegram-cli listening on a unix-socket (
-S
) or a port (-P
). Needs to be configured already (phone-number, etc.). - php >= 5.4.0
- curl installed
- json flag added to the telegram daemon startup command
Installing Telegram-cli
Setup telegram-cli
Telegram-cli needs to run on a unix-socket (-S
) or a port (-P
), so laragram can connect to it. Please read the instructions at telegram-cli on how to configure
and then make
If your build was successful you can continue!
First time running telegram-cli
If you never started telegram-cli before, you need to start it first in normal mode, so you can type in your telegram-phone-number and register it.
Assuming you installed telegram in ~/telegram
your command should look like this:
~/telegram/bin/telegram-cli
.
Once registered, you can exit telegram-cli (safe_quit
) and launch it as a daemon.
Running telegram-cli as a daemon
To run telegram-cli as a daemon you need to use the -d
flag and set a unix socket -S
.
Or instead you may use a TCP port
The -W
switch means the contact-list gets loaded on startup - this allows you to send messages straight away. The &
at the ends means that the command will load in the background allowing you to continue with the script.
To stop the daemon use killall telegram-cli
or kill -TERM [telegram-pid]
.
You now have Telegram-cli working and waiting to be told what to send!
To ensure your daemon does not exit unexpectantly, you can use something like supervisor to make sure the process always is running. See notes at the end of how this can be set up.
Installing Laragram
Install Laragram with composer
In your laravel project-root:
Service Providers and Facades
Open config/app.php
file, find the providers array and add to the bottom
If you're running Laravel 5.1 or greater you can use this syntax instead in the config/app.php
file:
Note the lack of single quotes for the laravel 5 version.
Now you add the following line to the Alias array in config/app.php
to register the shorthand TG
facade
Open config/services.php
file, add the following array to specify what type of socket you would like to connect to the
telegram daemon.
Other values include unix sockets. ie 'socket' => 'unix:///tmp/tg.sck'
You're done!
Using Laragram
Now anywhere in your app you can send a telegram message quickly and easily like follows:
Remember that the name should have underscores instead of spaces eg firstname_lastname
, OR you can use user#
and then the persons telegram ID directly. This method is far more reliable. eg user#123456789
In addition to sendMessage, the following commands are available to you:
License
This software is licensed under the Mozilla Public License v. 2.0. For more information, read the file LICENSE
.
Using Supervisor
Assuming that you have
- supervisord installed on your system (if not supervisord install ) and
- telegram has been installed in
/home/username/telegram
Then create a new file /etc/supervisor/conf.d/telegram.conf
and copy the following into it, adding/replacing any log files you wish to create
Save the file and restart supervisor (make sure that telegram-cli is NOT running before you do this, supervisor will now take care of insuring that the process always runs even if it crashes).
You can view how the process is doing by using the monitoring program
All versions of laragram with dependencies
ext-curl Version *