- What is escarter/activity-log used for in a Laravel application?
- It is a lightweight Laravel package for recording user activities and model events so you can build audit trails and track changes across your application. It focuses on simple integration and customizable logging rather than a large feature surface. Developers typically use it when they want a clean way to monitor actions taken by users or changes made to Eloquent models.
- How do I install escarter/activity-log with Composer?
- Require the package through Composer using the escarter/activity-log name, then follow the setup steps documented in the repository README. As with most Laravel packages, installation may also involve publishing configuration or migration assets and, on older Laravel versions without package discovery, registering a service provider. Always check the README for the exact commands for your Laravel version.
- Which Laravel versions does escarter/activity-log support?
- The supported range is defined by the package's composer.json constraints rather than by its one-line description. Check the require section on Packagist or GitHub and confirm it matches the Laravel and PHP versions your project runs. If you are on an older release or the newest major version, verify compatibility before adding it to a production app.
- How does it log model events like created, updated, and deleted?
- The package records model events, which is what lets you capture creates, updates, and deletes as part of an audit trail. Instead of writing logging calls by hand in every controller, you let the package observe Eloquent activity and store the resulting entries. See the README for the exact trait or model configuration needed to opt a model into logging.
- Can I customize what escarter/activity-log records?
- Customizable logging is one of the stated goals of the package, so you can shape what gets recorded instead of accepting a fixed format. Typical adjustments involve choosing which models or events are captured and how each entry is described. The README is the authoritative source for the available configuration options and defaults.
- Can I record activities manually, without relying on model events?
- The package is described as recording both user activities and model events, which suggests you can log actions that are not tied to an Eloquent lifecycle event. This is useful for things like logins, exports, or failed attempts that a model observer would never see. Check the README for the exact helper, facade call, or service you should use.
- Does it track which authenticated user performed an action?
- Because the package targets user activity and audit trails, entries are typically associated with the authenticated user responsible for the action. In a standard Laravel app that means the record resolves the currently logged-in user through the framework's auth guard. Confirm in the README whether the user relationship and resolver are configurable for multi-guard or API-only setups.
- Is escarter/activity-log suitable for production audit trails?
- It can be, provided you plan for volume, since activity tables grow quickly in busy applications and you should index the columns you filter on and consider pruning or archiving old entries. Decide whether writes should occur inside the same transaction as the change being logged, because that affects consistency and failure behavior. Review the package's migration and configuration before relying on it for compliance-grade auditing.
- How do I test that activity logging works in my Laravel test suite?
- Assert against the activity records your application creates using normal Laravel testing tools, such as database assertions against the package's table. If the package exposes a model or dispatches events, you can also use Laravel's event fakes alongside database assertions in feature tests. Wrap the tests in RefreshDatabase so the activity table is migrated cleanly on every run.
- How does escarter/activity-log compare to spatie/laravel-activitylog?
- spatie/laravel-activitylog is the most widely adopted package in this space, with a broader feature set and a much larger community. escarter/activity-log positions itself as a lightweight alternative emphasizing simple integration and customizable logging, which can suit smaller projects that do not want heavier dependencies. Compare maintenance activity, Laravel version support, and schema flexibility of both before committing.