Download the PHP package mountain/laraslack without Composer

On this page you can find all versions of the php package mountain/laraslack. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laraslack

LaraSlack

Send alerts, notifications and Block Kit messages to Slack from Laravel, via incoming webhooks.

Requirements

Installation

The service provider is auto-discovered. Publish the config if you want to edit it in your application:

Then add your webhook URL to .env:

To create a webhook, go to https://api.slack.com/messaging/webhooks and create a Slack app with the Incoming Webhooks permission, or add an incoming webhook to an existing one.

Usage

send() returns true if Slack accepted the message, and false if it was skipped or rejected. It does not throw unless you ask it to.

Block Kit

Attachments

Posting to more than one channel

See "Identity and channels" below for why this matters.

Anything else

Anything the builder does not cover can be passed straight through as a raw Slack payload. This is also the reason the method is a single array rather than key/value pairs: a text value containing = would otherwise be misparsed as a form field.

Without the facade

Identity and channels

channel, username and icon are only honoured by legacy custom integration webhooks. Webhooks that belong to a Slack app ignore all three, because the app's own configuration wins:

You cannot override the default channel (chosen by the user who installed your app), username, or icon when you're using incoming webhooks to post messages. — Slack's documentation

So if SLACK_CHANNEL seems to be ignored, that is why. To post to a different channel, post to a different webhook, which is scoped to a channel at creation time. That is what webhook() is for.

If you need per-message identity as well, use the chat.postMessage Web API method with a bot token and the chat:write.customize scope instead. This package deliberately does not do that, to avoid pulling in token management.

Testing

With no SLACK_WEB_HOOK_URL configured, send() returns false and makes no request, so nothing is posted to Slack from your test suite.

To assert on what would have been sent, fake the HTTP client:

Remember that Slack answers with HTTP 200 and a body of ok on success, so fake that rather than a bare Http::response() if you want the transport to see a success.

Configuration

Key Env Default Notes
endpoint SLACK_WEB_HOOK_URL null Blank or missing disables sending entirely.
channel SLACK_CHANNEL null Legacy webhooks only.
username SLACK_USERNAME null Legacy webhooks only.
icon SLACK_ICON null An emoji shortcode, e.g. :rocket:. Legacy webhooks only.
enabled SLACK_ENABLED true Master switch.
throw_exceptions SLACK_THROW_EXCEPTIONS false Throw SlackRequestException instead of logging.
connect_timeout SLACK_CONNECT_TIMEOUT 3 Seconds to establish a connection.
timeout SLACK_TIMEOUT 5 Seconds for the whole request.
verify_tls SLACK_VERIFY_TLS true Leave this on.
proxy SLACK_PROXY null e.g. http://user:[email protected]:3128.

Error handling

By default a failed message is reported to your application logger and send() returns false. That includes connection failures, DNS errors and timeouts, so a Slack outage never breaks the request that triggered the alert.

Set SLACK_THROW_EXCEPTIONS=true to throw instead:

Note that Slack reports most webhook errors with an HTTP 200 and a plain text body such as invalid_payload or channel_not_found, so a 2xx status on its own does not mean the message arrived. This package checks both.

A message with no text, blocks or attachments throws EmptyMessageException before any request is made, rather than being posted as a blank message.

Contributing

Licence

MIT. See LICENSE.


All versions of laraslack with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-json Version *
guzzlehttp/guzzle Version ^7.5
illuminate/http Version ^10.0|^11.0|^12.0
illuminate/support Version ^10.0|^11.0|^12.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mountain/laraslack contains the following files

Loading the files please wait ...