Download the PHP package get-stream/stream-laravel without Composer

On this page you can find all versions of the php package get-stream/stream-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package stream-laravel

Stream Laravel

Build Status PHP version

stream-laravel is a Laravel client for Stream. You can use this in any Laravel application, or in any application that uses Eloquent ORM (illuminate/database) as a standalone ORM.

You can sign up for a Stream account at https://getstream.io/get_started.

Note there is also a lower level PHP - Stream integration library which is suitable for all PHP applications.

Build Activity Streams, News Feeds, and More

You can build:

Demos

https://github.com/GetStream/Stream-Laravel-Example

https://github.com/GetStream/Stream-Example-PHP

Installation

Composer

Begin by installing this package through Composer. Edit your project's file to require :

Next, update Composer:

Laravel

Laravel prior to 5.5 (no longer supported)

Add 'GetStream\StreamLaravel\StreamLaravelServiceProvider' to your list of providers in config/app.php:

And add the FeedManager facade 'GetStream\StreamLaravel\Facades\FeedManager' to your list of aliases in config/app.php:

Publish the configuration file:

This will create . We will set our credentials after they are created in the Stream Dashboard.

GetStream.io Dashboard

Now, login to GetStream.io and create an application in the dashboard.

Retrieve the API key, API secret, and API app id, which are shown in your dashboard.

Create feeds in your new application. By default, you should create the following:

Stream-Laravel Config File

Set your key, secret, and app id in file as their are shown in your dashboard. Also set the location for good measure. For example:

You can also set the name of your feeds here:

And that should get you off and running with Stream-Laravel. Have lots of fun!

Lumen Installation

Begin by installing this package through Composer.

Add 'GetStream\StreamLaravel\StreamLumenServiceProvider' to the list of providers in bootstrap/app.php

Manually create a config file in ./config/stream-laravel.php...

and tell Lumen to configure it, in bootstrap.

Features of Stream-Laravel

Eloquent Integration

Stream-Laravel provides instant integration with Eloquent models - extending the class will give you automatic tracking of your models to user feeds.

For example:

Everytime a Pin is created it will be stored in the feed of the user that created it, and when a Pin instance is deleted than it will get removed as well.

Automatically!

Activity Fields

Models are stored in feeds as activities. An activity is composed of at least the following data fields: actor, verb, object, time. You can also add more custom data if needed.

object is a reference to the model instance itself actor is a reference to the user attribute of the instance verb is a string representation of the class name

In order to work out-of-the-box the Activity class makes few assumptions:

  1. the Model class belongs to a user
  2. the model table has timestamp columns (created_at is required)

You can change how a model instance is stored as activity by implementing specific methods as explained later.

Below shows an example how to change your class if the model belongs to an author instead of to a user.

Activity Extra Data

Often, you'll want to store more data than just the basic fields. You achieve this by implementing the method in the model.

NOTE: you should only return data that can be serialized by PHP's json_encode function

Customize Activity Verb

By default, the verb field is the class name of the activity, you can change that implementing the activityVerb method.

Feed Manager

Stream Laravel comes with a FeedManager class that helps with all common feed operations. You can get an instance of the manager with if you defined the facade alias (see above in the install), or with if you did not.

Pre-Bundled Feeds

To get you started the manager has feeds pre configured. You can add more feeds if your application needs it. The three feeds are divided in three categories.

User Feed:

The user feed stores all activities for a user. Think of it as your personal Facebook page. You can easily get this feed from the manager.

News Feed:

The news feeds store the activities from the people you follow. There is both a timeline (similar to twitter) and an aggregated timeline (like facebook).

Notification Feed:

The notification feed can be used to build notification functionality.

Notification feed

Below we show an example of how you can read the notification feed.

By default the notification feed will be empty. You can specify which users to notify when your model gets created. In the case of a retweet you probably want to notify the user of the parent tweet.

Another example would be following a user. You would commonly want to notify the user which is being followed.

Follow Feed

To create the newsfeeds you need to notify the system about follow relationships. The manager comes with APIs to let a user's news feeds follow another user's feed. This code lets the current user's timeline and timeline_aggregated feeds follow the target_user's personal feed.

Displaying the Newsfeed

Activity Enrichment

When you read data from feeds, a like activity will look like this:

This is far from ready for usage in your template. We call the process of loading the references from the database enrichment. An example is shown below:

The enrich method returns an array of objects of type which you can also parse yourself. For example, in an API where you are using you could use a loop like the following in your Controller to return json to your api.

On your model:

In your controller:

Templating

Now that you've enriched the activities you can render them in a view. For convenience we includes a basic view:

The view tag will render the view activity.$activity["verb"] view with the activity as context.

For example activity/tweet.blade.php will be used to render an normal activity with verb tweet and aggregated_activity/like.blade.php for an aggregated activity with verb like

If you need to support different kind of templates for the same activity, you can send a third parameter to change the view selection.

The example below will use the view activity/homepage_like.html

Customizing Enrichment

Sometimes you'll want to customize how enrichment works. The documentation will show you several common options.

Enrich Extra Fields

If you store references to model instances in the activity extra_data you can use the Enrich class to take care of it for you:

Preload Related Data

You will commonly access related objects such as activity['object']->user. To prevent your newsfeed to run N queries you can instruct the manager to load related objects. The manager will use Eloquent's functionality.

Full documentation and Low level APIs access

When needed you can also use the low level PHP API directly. Documentation is available at the Stream website.

Contributing

We welcome code changes that improve this library or fix a problem, please make sure to follow all best practices and add tests if applicable before submitting a Pull Request on Github. We are very happy to merge your code in the official repository. Make sure to sign our Contributor License Agreement (CLA) first. See our license file for more details.

Getting started:

Copyright and License Information

Copyright (c) 2014-2022 Stream.io Inc, and individual contributors. All rights reserved.

See the file "LICENSE" for information on the history of this software, terms & conditions for usage, and a DISCLAIMER OF ALL WARRANTIES.


All versions of stream-laravel with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
illuminate/support Version >=9.0
illuminate/database Version >=9.0
get-stream/stream Version ^7.0.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package get-stream/stream-laravel contains the following files

Loading the files please wait ....