Download the PHP package dcodegroup/activity-log without Composer

On this page you can find all versions of the php package dcodegroup/activity-log. 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 activity-log

Laravel Activity Log

The dcodegroup/activity-log package provides a simple and unified approach to track and record activity / interactions against your Laravel models (and relations). Capture changes, updates, and user interactions to enhance transparency and auditing in your application in a centralised and consistent approach.

Latest Version on Packagist GitHub Code Style Action Status Total Downloads

Compatibility

Package version PHP Laravel
4.0.1+ / 4.x ^8.3 ^10.10, ^11, ^12, ^13
4.0.0 ^8.3 ^11, ^12, ^13
3.x ^8.3 ^11, ^12, ^13
2.x ^8.2 ^10.2, ^11, ^12 (later 2.x)
1.1.x ^8.2 / ^8.3 ^10, ^11
1.0.x ^8.0^8.2 ^7^10

Upgrading to 4.x? See UPGRADE.md for the step-by-step file changes.

Update note

Since version 1.1.1 we are no longer need to use observers to listen for changes from the model. bootActivityLoggable in ActivityLoggable trait solved that. Make sure to remove duplicate observers before updating

Installation

Installation (PHP package only)

This package is a PHP Laravel package and no longer ships Vue/JS/CSS. Frontend components live in a separate package (install with pnpm):

Install the backend via Composer:

Run the installer and migrations:

If you need the UI, install the Vue package and follow its README (or the 4.x upgrade guide if migrating from 3.x).

User Model

Add the following contract to the User model.

Service Provider

Add the following to the EventServiceProvider if you want to listen for mail events:

Configuration

Most of configuration has been set the fair defaults. However you can review the configuration file at config/activity-log.php and adjust as needed

Value Options Description
middleware Include a specification of what middleware this package should include.
layout_path The dot notation path to the resource/view that you would like to use for the Activity Log.
content_section The variable in the view that will contain the output of the Activtity Log.

Comment attachments

Set attachment_model to the attachment library's Eloquent model. attachment_url accepts either a base URL or a URL containing {attachment} (or {attachment_id}), for example /attachments/{attachment}.

Create comments with files by sending multipart/form-data. Add every file under the attachments[] field:

The target model must support the attachment package's addMedia method. Existing media can still be linked with attachment_id or attachment_ids[]. The activity resource returns the linked models in its attachments array and includes the resolved url for each attachment.

Usage

The package provides an endpoints which you can use. See the full list by running

They are

[example.com/activity-logs] Which is where you will form index. This is by default protected auth middleware but you can modify in the configuration. This is where you want to link to in your admin and possibly a new window

QueryBuilder Filters

Located in

Traits for activity log model

Located in

ActivityLoggable Trait

The ActivityLoggable trait provides functionality for logging activities and communication logs related to a model.

Methods

Example of define modelRelation via model using ActivityLoggable

when declared like this instead of activity log shows like this. account_id: 1 -> 20 The result will return like this: Account: Alison Cahill -> Annie Pollock.

Example of define activity log via model using ActivityLoggable

If you have a user case where you want the log messages to be logged against another model, Example. You have an Order model and you want the OrderItem models to be recorded against the Order. Then do as below.

with the OrderItem model add the method targetModel

Normally a model with have the field name title or label. This package can work this out in most cases. However if you have a none standard field used to name a model you can use the below method to customise the label for the model. If no label is found then a ModelLabelNotDefinedException exception will be thrown.

`

You can give any model a custom label by adding the following method to the model. If this is not set then Str::headline will be used on the model.

`

Automatically the package will try and find the key for the model. Typically, this will be a field named name, title or label. However this may not always be the case and the key may change depending on the the state of a model. Eg type Quote might be quote_number Order might use sales_order_number. If one of the defaults is not found then an ModelKeyNotDefinedException exception will be thrown.

This should only ever occur in your local environment. If this occurs then implement the follow method in your model.

By default this package will log all fields except for created_at, updated_at, deleted_at, password, and id. If you wish to exclude other fields on your model such as third party api tokens. Then implement the following method in your model.

Custom Formatters

You can use a custom formatter for fields in your model by using the activityLogFieldFormatters method.

example. Add the following to the model

price is the key for the field. Right hand side should be a closure than can then be used for format the value that will be present.

Entity name override

You can override the default name / label for an entity. Simply create a method named `` that returns a string. Below is the default.

Override relations entity name for another value like the name of the field

If you have a field such as Approved By. You may have a field in your database such as approved_by with a relationship name such as approvedBy that links to the User::class model. This would prefix the activity log message with User: for the field modified. This is not useful when you may have multiple relationships to users on the one model. You can customise the relationship name with this field, or multiple at once.

Communication Log

*createCommunicationLog(array $data, string $to, string $content, string $type = CommunicationLog::TYPE_EMAIL): CommunicationLog **: Create a new communication log.

Example of define Communication log via model using ActivityLoggable

Traits for activity log mailable to support tracking read email

Located in

Frontend components have been removed from this package. Use @dcodegroup-au/vue-activity-log (repo), call the package routes/controllers directly (php artisan route:list --name=activity-log), or build your own UI against those endpoints. See UPGRADE.md when moving from ≤ 3.x.

Events

The package provides the following events:

Usage

In order to log anything add the following trait to a model you want to log on.

In addition, we can add activity log wherever we want the model

Upgrade

Please see UPGRADE.md for upgrading to 4.x (including moving frontend assets to @dcodegroup-au/vue-activity-log via pnpm).

Changelog

Please see CHANGELOG for more information about recent changes.

Contributing

We believe in the power of collaboration! If you share our passion for pushing the boundaries of business software, feel free to contribute, report issues, or suggest improvements. Your insights make us better.

Development

This package is a backend-only Laravel package. For local PHP development and testing, use the included testbench setup and run PHPUnit:

Security

If you've found an issue related to this package that includes any security concerns; please email [email protected] to ensure that we can prioritise the concerns in a confidential manner.

Credits

This project is supported & funded by Dcode Group and the team - both past and present. Special mention to:

About Dcode Group

Dcode Group specializes in crafting tailored software solutions utilizing the Laravel framework. Our focus lies in developing business, financial, and process-driven systems designed to support unique business operations. Leveraging packages like this one, we streamline common features/functions across projects, ensuring swift integration of broad functionalities while enhancing overall code base maintenance and management. Find out more about

License


All versions of activity-log with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
coduo/php-to-string Version ^3.2
laravel/framework Version ^10.10|^11.0|^12.0|^13.0
nesbot/carbon Version ^2.72|^3.0
spatie/laravel-query-builder Version ^5.7|^6.0|^7.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 dcodegroup/activity-log contains the following files

Loading the files please wait ...