Download the PHP package rtio/activitypub-core without Composer
On this page you can find all versions of the php package rtio/activitypub-core. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download rtio/activitypub-core
More information about rtio/activitypub-core
Files in rtio/activitypub-core
Package activitypub-core
Short Description This is a fork from https://github.com/landrok/activitypub.
License MIT
Homepage https://github.com/rtio/activitypub-core
Informations about the package activitypub-core
ActivityPhp
This repository is a fork from https://github.com/landrok/activitypub.
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, 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 or an overview below.
Table of contents
- Install
- Requirements
- ActivityStreams Core Types
- ActivityStreams Extended Types
- Types
- Type factory
- Properties names
- All properties and their values
- Set several properties
- Get a property
- Set a property
- Check if property exists
- Create a copy
- Use native types
- Use your own extended types
- Create your own property validator
- Dialects management
Requirements
- Supports PHP 7.2+ | 8.0
Install
ActivityStreams Core Types
All core types are provided:
ActivityStreams Extended Types
All extended types are provided:
Actor types
Activity types
Object types
Types
Type factory
You can instanciate ActivityStreams types using their short name.
Instanciating a type and setting properties is possible with the second parameter.
Starting from an array with a 'type' key, it's even possible to directly instanciate your type.
Properties names
Whatever be your object or link, you can get all properties names with
getProperties()
method.
Would output something like:
All properties and their values
In order to dump all properties and associated values, use toArray()
method.
Would output something like:
Get a property
There are 3 equivalent ways to get a value.
Set a property
There are 3 equivalent ways to set a value.
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)
Set several properties
With Type factory, you can instanciate a type and set several properties.
Create a copy
Sometimes you may use a copy in order not to affect values of the original type.
You can copy and chain methods to affect only values of the copied type.
Check if a property exists
Use native types
All core and extended types are used with a classic instanciation.
Same way with Type factory:
Use your own extended types
If you need some custom attributes, you can extend predefined types.
- Create your custom type:
There are 2 ways to instanciate a type:
-
A classic PHP call:
- With the Type factory:
Extending types preserves benefits of getters, setters and their validators.
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
.
An equivalent way is to use Type factory and addValidator()
method: