PHPackages                             asgard/behaviors - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. asgard/behaviors

ActiveAsgard-bundle[Utility &amp; Helpers](/categories/utility)

asgard/behaviors
================

v0.3.1(9y ago)04731MITPHPPHP &gt;=5.5.9

Since Sep 9Pushed 9y agoCompare

[ Source](https://github.com/asgardphp/behaviors)[ Packagist](https://packagist.org/packages/asgard/behaviors)[ RSS](/packages/asgard-behaviors/feed)WikiDiscussions master Synced today

READMEChangelog (6)Dependencies (5)Versions (7)Used By (1)

\#Behaviors

[![Build Status](https://camo.githubusercontent.com/386cc83274825ff466472a51fc9944b99c071ada3ab8b28594d581a4c2f99fc7/68747470733a2f2f7472617669732d63692e6f72672f6173676172647068702f6265686176696f72732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/asgardphp/behaviors)

The Behaviors package provides some behaviors ready to use out-of-the-box for your entities. This page defines what the usage, the properties, the hooks and the methods brought by the behavior.

- [Installation](#installation)
- [MetasBehavior](#metas)
- [PublishBehavior](#publish)
- [SlugifyBehavior](#slugify)
- [SortableBehavior](#sortable)
- [TimestampsBehavior](#timestamps)

\##Installation **If you are working on an Asgard project you don't need to install this library as it is already part of the standard libraries.**

```
composer require asgard/behaviors 0.*

```

\##MetasBehavior

\###Usage

In your entity definition:

```
$definition->behaviors = [
	new \Asgard\Behaviors\MetasBehavior
];

```

\###Properties

```
meta_title:
	type: text
	required: false
meta_description:
	type: text
	required: false
meta_keywords:
	type: text
	required: false

```

\###Methods

```
$entity->showMetas();

```

outputs the entity metas in the html

\##PublishBehavior

\###Usage

In your entity definition:

```
$definition->behaviors = [
	new \Asgard\Behaviors\PublishBehavior
];

```

\###Properties

```
published:
	type: boolean
	default: true

```

\###Methods

```
Entity::published();

```

returns an orm with a published entities scope.

```
Entity::loadPublished($id);

```

returns an entity from a given id only if the entity is published.

\##SlugifyBehavior

\###Usage

In your entity definition:

```
$definition->behaviors = [
	new \Asgard\Behaviors\SlugifyBehavior
];

```

This will use the first entity property as a slug.

To use a speficic property as slug:

```
$definition->behaviors = [
	new \Asgard\Behaviors\SlugifyBehavior('title')
];

```

\###Properties

```
slug:
	type: text
	required: false

```

\###Methods

```
$entity->slug();

```

returns the entity slug

\##SortableBehavior

\###Usage

In your entity definition:

```
$definition->behaviors = [
	new \Asgard\Behaviors\SortableBehavior
];

```

\###Properties

```
position:
	type: integer
	required: false
	default: 0
	editable: false

```

\###Hooks

If the position is not set, when saving the entity, the position will be incremented from the last entity.

\###Methods

```
$entity->moveAfter($anotherEntityId);

```

moves the entity after another entity with a given id

```
$entity->previous();

```

returns the entity before the current one.

```
$entity->next();

```

returns the entity after the current one.

\##TimestampsBehavior

\###Usage

In your entity definition:

```
$definition->behaviors = [
	new \Asgard\Behaviors\TimestampsBehavior
];

```

\###Properties

```
created_at:
	type: datetime
	required: false
	default: function() { return \Asgard\Common\Datetime::now(); }
	editable: false
updated_at:
	type: datetime
	required: false
	default: function() { return \Asgard\Common\Datetime::now(); }
	editable: false

```

\###Hooks

Upon saving an entity, the updated\_at property will be updated with the current date and time.

\###Contributing

Please submit all issues and pull requests to the [asgardphp/asgard](http://github.com/asgardphp/asgard) repository.

### License

[](#license)

The Asgard framework is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity52

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 ~122 days

Recently: every ~152 days

Total

6

Last Release

3649d ago

PHP version history (2 changes)v0.1.0PHP &gt;=5.4.0

v0.3.0PHP &gt;=5.5.9

### Community

Maintainers

![](https://www.gravatar.com/avatar/849017ae3ff0c90a272e935f9c1db9a64692db4a2a18a8d0e4bf9dbcd6f74e2c?d=identicon)[leyou](/maintainers/leyou)

---

Top Contributors

[![h0gar](https://avatars.githubusercontent.com/u/439138?v=4)](https://github.com/h0gar "h0gar (50 commits)")

### Embed Badge

![Health badge](/badges/asgard-behaviors/health.svg)

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

###  Alternatives

[intervention/zodiac

Zodiac Sign Calculator

58191.7k](/packages/intervention-zodiac)

PHPackages © 2026

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