Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Doctrine Behaviors Laravel Package

eightmarq/doctrine-behaviors

View on GitHub
Deep Wiki
Context7

Blameable

Blameable is able to track entity creators and updaters.

Entity

<?php

declare(strict_types=1);

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use Knp\DoctrineBehaviors\Contract\Entity\BlameableInterface;
use Knp\DoctrineBehaviors\Model\Blameable\BlameableTrait;

/**
 * [@ORM](https://github.com/ORM)\Entity
 */
class Category implements BlameableInterface
{
    use BlameableTrait;
}

How it Works

By default, the current user from Symfony\Security is used. If you want to change it, just implement Knp\DoctrineBehaviors\Contract\Provider\UserProviderInterface yourself and override native service.

Usage

Then, you can use it like that:

<?php

/** [@var](https://github.com/var) Knp\DoctrineBehaviors\Contract\Entity\BlameableInterface $category */
$category = new Category();
$entityManager->persist($category);

$createdBy = $category->getCreatedBy();
var_dump($createdBy); 
// "App\Entity\User" object

$updatedBy = $category->getUpdatedBy();
var_dump($updatedBy);
// "App\Entity\User" object

Configuration

By default, no user entity is provided. You need to specify the User class with a new parameter in your config:

# services.yaml
parameters:
    doctrine_behaviors_blameable_user_entity: App\Entity\User
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
calmfox/watch-sylius
damienfern/grpc-symfony-bundle
atoolo/index-bundle
atoolo/genai-bundle
coprotoai/laravel-ticket
davidjln/llm-carbon-bundle
cryonighter/valid-request-bundle
coolms/taxonomy-bundle
coolms/field-bundle
articulate-orm/symfony
aaix/laravel-tall-architect
ephoto/akeneo-connector
emmanuelballery/eb-plantumlbundle
emielburgman/symfony-visitor-beacon
emielburgman/symfony-visit-storage
emielburgman/symfony-security-headers
emielburgman/symfony-log-viewer
emarref/xdebug-bundle
emarref/pubnub-bundle
elriseio/finance-money-bundle