PHP code example of musonza / laravel-activity-streams

1. Go to this page and download the library: Download musonza/laravel-activity-streams library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

musonza / laravel-activity-streams example snippets


    'ActivityStreams' => Musonza\ActivityStreams\ActivityStreamsFacade::class,
    

use ActivityStreams;



use Illuminate\Database\Eloquent\Model;
use Musonza\ActivityStreams\Traits\HasFeed;

class User extends Model
{
    use HasFeed;
}

$feed = $user->createFeed();



namespace App;

class Trending
{
    // Optional implementation
}


php artisan streams:make:feed 'App\Trending' 'some-unique-id'

use ActivityStreams;
use Musonza\ActivityStreams\ValueObjects\Verbs;

$activity = ActivityStreams::setActor($actor)
    ->setVerb(Verbs::VERB_LIKE)
    ->setObject($object)
    ->setTarget($target)
    ->createActivity();

$verbs = ActivityStreams::verbs();

ActivityStreams::addActivityToFeed($feed, $activity);

ActivityStreams::addActivityToFeed($feed, $activities);

ActivityStreams::addActivityToMultipleFeeds($feeds, $activity);

    php artisan vendor:publish --tag="activity.streams.config"
    

    php artisan vendor:publish --tag="activity.streams.migrations"
    

    php artisan migrate