PHPackages                             rtio/activitypub-core - 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. rtio/activitypub-core

ActiveLibrary

rtio/activitypub-core
=====================

This is a fork from https://github.com/landrok/activitypub.

0.1.0(3y ago)051MITPHPPHP ^7.2|^8.0

Since Nov 25Pushed 3y agoCompare

[ Source](https://github.com/rtio/activitypub-core)[ Packagist](https://packagist.org/packages/rtio/activitypub-core)[ Docs](https://github.com/rtio/activitypub-core)[ RSS](/packages/rtio-activitypub-core/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (1)

ActivityPhp
===========

[](#activityphp)

[![Build Status](https://camo.githubusercontent.com/50892e8f4474c4d2705526f2d94bd0e596b5b5f090a495df165bfee040b5dee7/68747470733a2f2f6170702e7472617669732d63692e636f6d2f7274696f2f61637469766974797075622d636f72652e7376673f6272616e63683d6d6173746572)](https://app.travis-ci.com/rtio/activitypub-core)[![Maintainability](https://camo.githubusercontent.com/b354771afd6c4fd811aacb59e3bf1aac63aca1a5e77265f90ce0f301d9d2bcc0/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f37323331376534663933623437373335393433322f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/rtio/activitypub-core/maintainability)[![Test Coverage](https://camo.githubusercontent.com/4b75abae930df51a09a62db2efd0fcce1f60bc901b052e9354770c86255c30b0/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f37323331376534663933623437373335393433322f746573745f636f766572616765)](https://codeclimate.com/github/rtio/activitypub-core/test_coverage)

This repository is a fork from .

ActivityPhp core is an implementation of the ActivityPub data layers in PHP.

It provides two layers:

- A **client to server protocol**, or "Social API" This protocol permits a client to act on behalf of a user.
- A [**server to server protocol**](#server), or "Federation Protocol" This protocol is used to distribute activities between actors on different servers, tying them into the same social graph.

As the two layers are implemented, it aims to be an ActivityPub conformant Federated Server

All normalized types are implemented too. If you need to create a new one, just extend existing types.

[See the full documentation](https://landrok.github.io/activitypub) or an overview below.

Table of contents
=================

[](#table-of-contents)

- [Install](#install)
- [Requirements](#requirements)
- [ActivityStreams Core Types](#activitystreams-core-types)
- [ActivityStreams Extended Types](#activitystreams-extended-types)
- [Types](#types)
    - [Type factory](#type-factory)
    - [Properties names](#properties-names)
    - [All properties and their values](#all-properties-and-their-values)
    - [Set several properties](#set-several-properties)
    - [Get a property](#get-a-property)
    - [Set a property](#set-a-property)
    - [Check if property exists](#check-if-property-exists)
    - [Create a copy](#create-a-copy)
    - [Use native types](#use-native-types)
    - [Use your own extended types](#use-your-own-extended-types)
    - [Create your own property validator](#create-your-own-property-validator)
    - [Dialects management](https://landrok.github.io/activitypub/activitypub-dialects-management.html)

---

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

[](#requirements)

- Supports PHP 7.2+ | 8.0

---

Install
-------

[](#install)

```
composer require landrok/activitypub
```

---

ActivityStreams Core Types
--------------------------

[](#activitystreams-core-types)

All core types are provided:

```
use ActivityPhp\Type\Core\Activity;
use ActivityPhp\Type\Core\Collection;
use ActivityPhp\Type\Core\CollectionPage;
use ActivityPhp\Type\Core\IntransitiveActivity;
use ActivityPhp\Type\Core\Link;
use ActivityPhp\Type\Core\ObjectType;
use ActivityPhp\Type\Core\OrderedCollection;
use ActivityPhp\Type\Core\OrderedCollectionPage;
```

---

ActivityStreams Extended Types
------------------------------

[](#activitystreams-extended-types)

All extended types are provided:

### Actor types

[](#actor-types)

```
use ActivityPhp\Type\Extended\Actor\Application;
use ActivityPhp\Type\Extended\Actor\Group;
use ActivityPhp\Type\Extended\Actor\Organization;
use ActivityPhp\Type\Extended\Actor\Person;
use ActivityPhp\Type\Extended\Actor\Service;
```

### Activity types

[](#activity-types)

```
use ActivityPhp\Type\Extended\Activity\Accept;
use ActivityPhp\Type\Extended\Activity\Add;
use ActivityPhp\Type\Extended\Activity\Announce;
use ActivityPhp\Type\Extended\Activity\Arrive;
use ActivityPhp\Type\Extended\Activity\Block;
use ActivityPhp\Type\Extended\Activity\Create;
use ActivityPhp\Type\Extended\Activity\Delete;
use ActivityPhp\Type\Extended\Activity\Dislike;
use ActivityPhp\Type\Extended\Activity\Flag;
use ActivityPhp\Type\Extended\Activity\Follow;
use ActivityPhp\Type\Extended\Activity\Ignore;
use ActivityPhp\Type\Extended\Activity\Invite;
use ActivityPhp\Type\Extended\Activity\Join;
use ActivityPhp\Type\Extended\Activity\Leave;
use ActivityPhp\Type\Extended\Activity\Like;
use ActivityPhp\Type\Extended\Activity\Listen;
use ActivityPhp\Type\Extended\Activity\Move;
use ActivityPhp\Type\Extended\Activity\Offer;
use ActivityPhp\Type\Extended\Activity\Question;
use ActivityPhp\Type\Extended\Activity\Read;
use ActivityPhp\Type\Extended\Activity\Reject;
use ActivityPhp\Type\Extended\Activity\Remove;
use ActivityPhp\Type\Extended\Activity\TentativeAccept;
use ActivityPhp\Type\Extended\Activity\TentativeReject;
use ActivityPhp\Type\Extended\Activity\Travel;
use ActivityPhp\Type\Extended\Activity\Undo;
use ActivityPhp\Type\Extended\Activity\Update;
use ActivityPhp\Type\Extended\Activity\View;
```

### Object types

[](#object-types)

```
use ActivityPhp\Type\Extended\Object\Article;
use ActivityPhp\Type\Extended\Object\Audio;
use ActivityPhp\Type\Extended\Object\Document;
use ActivityPhp\Type\Extended\Object\Event;
use ActivityPhp\Type\Extended\Object\Image;
use ActivityPhp\Type\Extended\Object\Mention;
use ActivityPhp\Type\Extended\Object\Note;
use ActivityPhp\Type\Extended\Object\Page;
use ActivityPhp\Type\Extended\Object\Place;
use ActivityPhp\Type\Extended\Object\Profile;
use ActivityPhp\Type\Extended\Object\Relationship;
use ActivityPhp\Type\Extended\Object\Tombstone;
use ActivityPhp\Type\Extended\Object\Video;
```

---

Types
-----

[](#types)

### Type factory

[](#type-factory)

You can instanciate ActivityStreams types using their short name.

```
use ActivityPhp\Type;

$link = Type::create('Link');
$note = Type::create('Note');
```

Instanciating a type and setting properties is possible with the second parameter.

```
use ActivityPhp\Type;

$note = Type::create('Note', [
    'content' => 'A content for my note'
]);
```

Starting from an array with a 'type' key, it's even possible to directly instanciate your type.

```
use ActivityPhp\Type;

$array = [
    'type'    => 'Note',
    'content' => 'A content for my note'
];

$note = Type::create($array);
```

---

### Properties names

[](#properties-names)

Whatever be your object or link, you can get all properties names with `getProperties()` method.

```
use ActivityPhp\Type;

$link = Type::create('Link');

print_r(
    $link->getProperties()
);
```

Would output something like:

```
Array
(
    [0] => type
    [1] => id
    [2] => name
    [3] => nameMap
    [4] => href
    [5] => hreflang
    [6] => mediaType
    [7] => rel
    [8] => height
    [9] => preview
    [10] => width
)

```

---

### All properties and their values

[](#all-properties-and-their-values)

In order to dump all properties and associated values, use `toArray()`method.

```
use ActivityPhp\Type;

$link = Type::create('Link');
$link->setName('An example');
$link->setHref('http://example.com');

print_r(
    $link->toArray()
);
```

Would output something like:

```
Array
(
    [type] => Link
    [name] => An example
    [href] => http://example.com
)

```

---

### Get a property

[](#get-a-property)

There are 3 equivalent ways to get a value.

```
use ActivityPhp\Type;

$note = Type::create('Note');

// Each method returns the same value
echo $note->id;
echo $note->get('id');
echo $note->getId();
```

---

### Set a property

[](#set-a-property)

There are 3 equivalent ways to set a value.

```
use ActivityPhp\Type;

$note = Type::create('Note');

$note->id = 'https://example.com/custom-notes/1';
$note->set('id', 'https://example.com/custom-notes/1');
$note->setId('https://example.com/custom-notes/1');
```

Whenever you assign a value, the format of this value is checked.

This action is made by a validator. If rules are not respected an Exception is thrown.

When a property does not exist, an Exception is thrown in strict mode. You can define 3 different behaviours:

- throw an exception (default=strict)
- ignore property (ignore)
- set property (include)

```
use ActivityPhp\Type;
use ActivityPhp\Type\TypeConfiguration;

$note = Type::create('Note');

// Ignore mode
TypeConfiguration::set('undefined_properties', 'ignore');
$note->undefinedProperty = 'https://example.com/custom-notes/1';
echo $note->undefinedProperty; // null

// Include mode
TypeConfiguration::set('undefined_properties', 'include');
$note->undefinedProperty = 'https://example.com/custom-notes/1';
echo $note->undefinedProperty; // https://example.com/custom-notes/1

// Strict mode
TypeConfiguration::set('undefined_properties', 'strict');
$note->undefinedProperty = 'https://example.com/custom-notes/1'; // Exception
```

---

### Set several properties

[](#set-several-properties)

With **Type factory**, you can instanciate a type and set several properties.

```
use ActivityPhp\Type;

$note = Type::create('Note', [
    'id'   => 'https://example.com/custom-notes/1',
    'name' => 'An important note',
]);
```

---

### Create a copy

[](#create-a-copy)

Sometimes you may use a copy in order not to affect values of the original type.

```
use ActivityPhp\Type;

$note = Type::create('Note', ['name' => 'Original name']);

$copy = $note->copy()->setName('Copy name');

echo $copy->name; // Copy name
echo $note->name; // Original name
```

You can copy and chain methods to affect only values of the copied type.

---

### Check if a property exists

[](#check-if-a-property-exists)

```
use ActivityPhp\Type;

$note = Type::create('Note');

echo $note->has('id'); // true
echo $note->has('anotherProperty'); // false
```

---

### Use native types

[](#use-native-types)

All core and extended types are used with a classic instanciation.

```
use ActivityPhp\Type\Extended\Object\Note;

$note = new Note();
```

Same way with Type factory:

```
use ActivityPhp\Type;

$note = Type::create('Note');
```

---

### Use your own extended types

[](#use-your-own-extended-types)

If you need some custom attributes, you can extend predefined types.

- Create your custom type:

```
use ActivityPhp\Type\Extended\Object\Note;

class MyNote extends Note
{
    // Override basic type
    protected $type = 'CustomNote';

    // Custom property
    protected $myProperty;
}
```

There are 2 ways to instanciate a type:

- A classic PHP call:

```
$note = new MyNote();
$note->id = 'https://example.com/custom-notes/1';
$note->myProperty = 'Custom Value';

echo $note->getMyProperty(); // Custom Value
```

- With the Type factory:

```
use ActivityPhp\Type;

$note = Type::create('MyNote', [
    'id' => 'https://example.com/custom-notes/1',
    'myProperty' => 'Custom Value'
]);
```

Extending types preserves benefits of getters, setters and their validators.

---

### Create your own property validator

[](#create-your-own-property-validator)

Use a custom property validator when you define custom attributes or when you want to override ActivityPub attribute default validation.

Regarding to previous example with a custom attribute `$myProperty`, if you try to set this property, it would be done without any check on values you're providing.

You can easily cope with that implementing a custom validator using `Validator`.

```
use ActivityPhp\Type\ValidatorInterface;
use ActivityPhp\Type\Validator;

// Create a custom validator that implements ValidatorInterface
class MyPropertyValidator implements ValidatorInterface
{
    // A public validate() method is mandatory
    public function validate($value, $container)
    {
        return true;
    }
}

// Attach this custom validator to a property
Validator::add('myProperty', MyPropertyValidator::class);

// Now all values are checked with the validate() method
// 'myProperty' is passed to the first argument
// $note is passed to the second one.

$note->myProperty = 'Custom Value';
```

An equivalent way is to use Type factory and `addValidator()` method:

```
use ActivityPhp\Type;

// Attach this custom validator to a property
Type::addValidator('myProperty', MyPropertyValidator::class);
```

---

More
----

[](#more)

- [See the full documentation](https://landrok.github.io/activitypub/)
- [ActivityPub](https://www.w3.org/TR/activitypub/)
- [ActivityStreams 2.0](https://www.w3.org/TR/activitystreams-core/)
- [JSON-LD](https://www.w3.org/TR/json-ld/)

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 96% 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

Unknown

Total

1

Last Release

1270d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/24c0683677b463dbf6095d5ceaa13a4e50a1213891d187930e8f3601253c4f2c?d=identicon)[rtio](/maintainers/rtio)

---

Top Contributors

[![landrok](https://avatars.githubusercontent.com/u/3310446?v=4)](https://github.com/landrok "landrok (312 commits)")[![rtio](https://avatars.githubusercontent.com/u/5431713?v=4)](https://github.com/rtio "rtio (6 commits)")[![swentel](https://avatars.githubusercontent.com/u/168466?v=4)](https://github.com/swentel "swentel (3 commits)")[![gudzpoz](https://avatars.githubusercontent.com/u/14026120?v=4)](https://github.com/gudzpoz "gudzpoz (1 commits)")[![jeremytubbs](https://avatars.githubusercontent.com/u/548888?v=4)](https://github.com/jeremytubbs "jeremytubbs (1 commits)")[![dpi](https://avatars.githubusercontent.com/u/21850?v=4)](https://github.com/dpi "dpi (1 commits)")[![snorpey](https://avatars.githubusercontent.com/u/166433?v=4)](https://github.com/snorpey "snorpey (1 commits)")

---

Tags

Federationactivitystreamsactivitypub

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rtio-activitypub-core/health.svg)

```
[![Health](https://phpackages.com/badges/rtio-activitypub-core/health.svg)](https://phpackages.com/packages/rtio-activitypub-core)
```

###  Alternatives

[onelogin/php-saml

PHP SAML Toolkit

1.3k44.0M107](/packages/onelogin-php-saml)[landrok/activitypub

A PHP implementation of ActivityPub protocol based upon the ActivityStreams 2.0 data format.

28874.5k3](/packages/landrok-activitypub)[surface/laravel-webfinger

A Laravel package to create an ActivityPub webfinger.

113.8k](/packages/surface-laravel-webfinger)

PHPackages © 2026

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