Download the PHP package rouxtaccess/laravel-cloudwatch without Composer

On this page you can find all versions of the php package rouxtaccess/laravel-cloudwatch. 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 laravel-cloudwatch

Laravel CloudWatch

Latest Version on Packagist GitHub Tests Action Status Total Downloads

Ship Laravel logs to AWS CloudWatch Logs without blocking your application.

For years, CloudWatch logging from PHP has meant choosing between two kinds of pain. The existing log handlers are synchronous, calling the AWS API from inside your PHP process, where a slow or unavailable CloudWatch endpoint can slow down or outright break your requests. The alternative is a CloudWatch agent living on every server, with file watchers, per-host configuration, and one more piece of infrastructure for Ops to install, monitor, and keep patched. This package exists to remove both. Logging never touches AWS inside your request path, and there is nothing to run beyond a normal Laravel install, using the scheduler and a cache store you already have.

The log channel writes each record to a fast local buffer (any Laravel cache store), and a scheduled command ships the buffer to CloudWatch in batches, outside of any request or job.

Highlights:

Installation

Install via composer:

Optionally publish the config file:

Usage

Add a cloudwatch channel to config/logging.php:

Then enable shipping in your .env:

That is everything. The package schedules cloudwatch:ship every minute (with overlap protection) as long as your scheduler is running. On the first shipment it creates the log group with the configured retention.

Logging works like any other channel:

Records are stored as JSON lines, which makes them directly queryable with CloudWatch Logs Insights:

Configuration

Choosing the buffer store

By default the buffer uses your application's default cache store. Point it at any store from config/cache.php with:

Stores with atomic increments (Redis, Memcached, database, DynamoDB) are safe under concurrent writes. Avoid the file store outside local development, since its counters are not atomic across processes.

Log group, stream and retention

If your IAM policy is locked down and the group is provisioned externally (Terraform, CloudFormation), disable group management:

With group management enabled, the IAM user or role needs:

With CLOUDWATCH_CREATE_LOG_GROUP=false only logs:PutLogEvents is required.

Buffer safety valves

The buffer is capped so an extended outage cannot grow your cache store unbounded. Once the cap is reached new records are dropped until the shipper catches up. Buffered records also carry a TTL as a second safety net.

Shipping frequency

By default the ship command runs every minute. Projects that do not log much can ship less often. A plain number means "every N minutes", or provide a full five-part cron expression:

An idle run is nearly free either way. When the buffer is empty the command exits after two cache reads, without contacting AWS. When shipping less frequently, make sure CLOUDWATCH_BUFFER_CAP comfortably holds the records your app produces between runs.

Scheduling yourself

Set CLOUDWATCH_AUTO_SCHEDULE=false and schedule the command however you prefer:

Custom formatter

The channel accepts a formatter option, any Monolog formatter class resolved through the container:

The default is a JsonFormatter, which is the most useful format for Logs Insights queries.

Custom buffer backend

The buffer is bound through the Rouxtaccess\CloudWatch\Buffer\Buffer contract. To store records somewhere else entirely, implement the contract (four methods: push, peek, acknowledge, pendingCount) and point the config at your class:

Delivery semantics

Delivery is at least once. The shipper only acknowledges (removes) records after CloudWatch accepts them, so a failure keeps everything buffered for the next run. A crash between a successful PutLogEvents call and the acknowledgement can duplicate a batch, and a hard crash of the cache store can lose records that have not shipped yet. If CloudWatch rejects individual events (for example events older than 14 days), the rejection info is logged as a warning.

Testing

The test suite runs on the array cache store, so it needs no external services.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-cloudwatch with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
aws/aws-sdk-php Version ^3.300
illuminate/contracts Version ^12.0||^13.0
monolog/monolog Version ^3.0
spatie/laravel-package-tools Version ^1.16
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 rouxtaccess/laravel-cloudwatch contains the following files

Loading the files please wait ...