PHPackages                             rmed19/simple-behaviors-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. rmed19/simple-behaviors-bundle

ActiveSymfony-bundle[Database &amp; ORM](/categories/database)

rmed19/simple-behaviors-bundle
==============================

A Symfony bundle providing simple behaviors such as sluggable and timestampable entities.

v1.1.0(1y ago)080MITPHPPHP &gt;=8.0

Since Aug 11Pushed 1y ago1 watchersCompare

[ Source](https://github.com/rmed19/simple-behaviors-bundle)[ Packagist](https://packagist.org/packages/rmed19/simple-behaviors-bundle)[ RSS](/packages/rmed19-simple-behaviors-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (7)Versions (3)Used By (0)

MrSimpleBehaviorsBundle
=======================

[](#mrsimplebehaviorsbundle)

MrSimpleBehaviorsBundle is a Symfony bundle that provides simple, reusable behaviors for Doctrine entities, such as Sluggable and Timestampable functionalities.

Features
--------

[](#features)

- **Sluggable**: Automatically generates a URL-friendly slug for your entities based on a specified field.
- **Timestampable**: Automatically manages `createdAt` and `updatedAt` fields for your entities.

Requirements
------------

[](#requirements)

- PHP 8.0 or higher
- Symfony 6.0 or higher
- Doctrine ORM
- Symfony String Component
- Symfony Serializer Component

Installation
------------

[](#installation)

Install the bundle via Composer:

```
composer require rmed19/simple-behaviors-bundle
```

If you're not using Symfony Flex, you'll need to manually enable the bundle in your `config/bundles.php`:

```
return [
    // Other bundles...
    Mr\SimpleBehaviorsBundle\MrSimpleBehaviorsBundle::class => ['all' => true],
];
```

Usage
-----

[](#usage)

### Sluggable Entity

[](#sluggable-entity)

To use the Sluggable functionality in your entity, simply include the `SluggableEntity` trait and implement the `SluggableInterface`:

```
use Doctrine\ORM\Mapping as ORM;
use Mr\SimpleBehaviorsBundle\Model\SluggableInterface;
use Mr\SimpleBehaviorsBundle\Traits\SluggableEntity;

#[ORM\Entity]
class Article implements SluggableInterface
{
    use SluggableEntity;

    #[ORM\Column(type: 'string', length: 255)]
    private string $title;

    public function getTitle(): string
    {
        return $this->title;
    }

    public function setTitle(string $title): self
    {
        $this->title = $title;

        return $this;
    }

    public function __toString(): string
    {
        return $this->title;
    }
}
```

### Timestampable Entity

[](#timestampable-entity)

To use the Timestampable functionality in your entity, include the `TimestampableEntity` trait and implement the `TimestampableInterface`:

```
use Doctrine\ORM\Mapping as ORM;
use Mr\SimpleBehaviorsBundle\Model\TimestampableInterface;
use Mr\SimpleBehaviorsBundle\Traits\TimestampableEntity;

#[ORM\Entity]
class Post implements TimestampableInterface
{
    use TimestampableEntity;

    #[ORM\Column(type: 'string', length: 255)]
    private string $content;

    public function getContent(): string
    {
        return $this->content;
    }

    public function setContent(string $content): self
    {
        $this->content = $content;

        return $this;
    }
}
```

### Serialization Groups

[](#serialization-groups)

The `MrSimpleBehaviorsBundle` provides serialization groups directly within the traits for controlling how slugs and timestamps are serialized.

- **For Slugs**: The `SluggableEntity` trait includes the group `mr_simple_behaviors:slug:read`.
- **For Timestamps**: The `TimestampableEntity` trait includes the group `mr_simple_behaviors:timestamp:read`.

These groups allow you to manage the serialization of these fields effectively in different contexts.

#### Example:

[](#example)

In your entity, the `SluggableEntity` trait automatically applies the `mr_simple_behaviors:slug:read` group to the `slug` field, and the `TimestampableEntity` trait applies the `mr_simple_behaviors:timestamp:read` group to the `createdAt` and `updateAt` fields.

Example usage with Symfony's Serializer component:

```
use Symfony\Component\Serializer\SerializerInterface;

$serializedData = $serializer->serialize($article, 'json', ['groups' => ['mr_simple_behaviors:slug:read']]);
```

In the example above, only the fields associated with the `mr_simple_behaviors:slug:read` group, including the slug, will be serialized.

### Configuration

[](#configuration)

The bundle uses Doctrine event listeners to automatically handle Sluggable and Timestampable behaviors. No additional configuration is required out of the box.

However, if you need to customize the behavior, you can override the default services by modifying the `services.xml` file located in your project:

```

```

### Testing

[](#testing)

To run the test suite, use PHPUnit:

```
vendor/bin/phpunit
```

Make sure you have PHPUnit installed and configured.

### Contributing

[](#contributing)

Contributions are welcome! Please submit a pull request or open an issue to discuss your ideas.

### License

[](#license)

This bundle is licensed under the MIT license. See the [LICENSE](LICENSE) file for more details.

### Credits

[](#credits)

MrSimpleBehaviorsBundle is developed and maintained by Mohamed RHAMNIA. Special thanks to the Symfony and Doctrine communities for their amazing tools and documentation.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

637d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/82ef8c61ceb6f536c21a602a02c86f9e1e8a6eeb98affc4bc2010a06309794ac?d=identicon)[rmed19](/maintainers/rmed19)

---

Top Contributors

[![rmed19](https://avatars.githubusercontent.com/u/511446?v=4)](https://github.com/rmed19 "rmed19 (3 commits)")

---

Tags

phpsymfonybundledoctrinesluggabletimestampableBehaviorentity listener

### Embed Badge

![Health badge](/badges/rmed19-simple-behaviors-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/rmed19-simple-behaviors-bundle/health.svg)](https://phpackages.com/packages/rmed19-simple-behaviors-bundle)
```

###  Alternatives

[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[fresh/doctrine-enum-bundle

Provides support of ENUM type for Doctrine2 in Symfony applications.

4636.8M12](/packages/fresh-doctrine-enum-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
