Installation and Setup | laravel-activitylog | Spatie

 SPATIE

  Laravel Activity Log
=======================

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Laravel-activitylog](https://spatie.be/docs/laravel-activitylog/v1)  Installation and Setup

 Version   v5   v4   v3   v2   v1

 Other versions for crawler [v5](https://spatie.be/docs/laravel-activitylog/v5) [v4](https://spatie.be/docs/laravel-activitylog/v4) [v3](https://spatie.be/docs/laravel-activitylog/v3) [v2](https://spatie.be/docs/laravel-activitylog/v2) [v1](https://spatie.be/docs/laravel-activitylog/v1)

  Installation and Setup
- [ Introduction ](https://spatie.be/docs/laravel-activitylog/v1/introduction)
- [ Postcardware ](https://spatie.be/docs/laravel-activitylog/v1/postcardware)
- [ Requirements ](https://spatie.be/docs/laravel-activitylog/v1/requirements)
- [ Installation and Setup ](https://spatie.be/docs/laravel-activitylog/v1/installation-and-setup)
- [ Questions and issues ](https://spatie.be/docs/laravel-activitylog/v1/questions-and-issues)
- [ Changelog ](https://spatie.be/docs/laravel-activitylog/v1/changelog)
- [ About us ](https://spatie.be/docs/laravel-activitylog/v1/about-us)

Basic usage
-----------

- [ Logging activity ](https://spatie.be/docs/laravel-activitylog/v1/basic-usage/logging-activity)
- [ Cleaning up the log ](https://spatie.be/docs/laravel-activitylog/v1/basic-usage/cleaning-up-the-log)

Advanced usage
--------------

- [ Logging model events ](https://spatie.be/docs/laravel-activitylog/v1/advanced-usage/logging-model-events)
- [ Using placeholders ](https://spatie.be/docs/laravel-activitylog/v1/advanced-usage/using-placeholders)
- [ Using multiple logs ](https://spatie.be/docs/laravel-activitylog/v1/advanced-usage/using-multiple-logs)

      You are viewing the documentation for **an older version** of this package. You can check the version you are using with the following command:

 `                                    composer show spatie/laravel-activitylog                                                                                                                                                                                                                                    `

Installation and Setup
======================

The package can be installed via composer:

```
composer require spatie/laravel-activitylog
```

Next, you must install the service provider:

```
// config/app.php
'providers' => [
    ...
    Spatie\Activitylog\ActivitylogServiceProvider::class,
];
```

You can publish the migration with:

```
php artisan vendor:publish --provider="Spatie\Activitylog\ActivitylogServiceProvider" --tag="migrations"
```

After the migration has been published you can create the `activity_log` table by running the migrations:

```
php artisan migrate
```

You can optionally publish the config file with:

```
php artisan vendor:publish --provider="Spatie\Activitylog\ActivitylogServiceProvider" --tag="config"
```

This is the contents of the published config file:

```
return [

    /*
     * When set to false, no activities will be saved to database.
     */
    'enabled' => env('ACTIVITY_LOGGER_ENABLED', true),

    /**
     * When running the clean-command all recording activities older than
     * the number of days specified here will be deleted.
     */
    'delete_records_older_than_days' => 365,

    /**
     * When not specifying a log name when logging activity
     * we'll using this log name.
     */
    'default_log_name' => 'default',

    /**
     * You can specify an auth driver here that gets user models.
     * When this is null we'll use the default Laravel auth driver.
     */
    'default_auth_driver' => null,

    /**
     * When set to true, the subject returns soft deleted models.
     */
     'subject_returns_soft_deleted_models' => false,

    /**
     * This model will be used to log activity. The only requirement is that
     * it should be or extend the Spatie\Activitylog\Models\Activity model.
     */
    'activity_model' => \Spatie\Activitylog\Models\Activity::class,
];
```

 A good
match?
-------------

### What we do best

- All things Laravel
- Custom frontend components
- Building APIs
- AI-powered features
- Simplifying things
- Clean solutions
- Integrating services

### Not our cup of tea

- WordPress themes
- Cutting corners
- Free mockups to win a job
- "Just execute the briefing"

 In short: we'd like to be a **substantial part** of your project.

 [ Get in touch via email ](mailto:info@spatie.be?subject=A%20good%20match%21&body=Tell%20us%20as%20much%20as%20you%20can%20about%0A-%20your%20online%20project%0A-%20your%20planning%0A-%20your%20budget%0A-%20%E2%80%A6%0A%0AAnything%20that%20helps%20us%20to%20start%20straightforward%21)
