Download the PHP package dmytrof/push-notification-bundle without Composer

On this page you can find all versions of the php package dmytrof/push-notification-bundle. 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 push-notification-bundle

PushNotificationBundle

Symfony2 bundle for sending push notifications with OneSignal

Installation

Step 1: Composer require

$ php composer.phar require "norkunas/onesignal-php-api":"1.0.x-dev" "dmytrof/push-notification-bundle"

Step2: Enable the bundle in the kernel

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Dmytrof\PushNotificationBundle\DmytrofPushNotificationBundle(),
        // ...
    );
}

Configuration

Enable the bundle in your config.yml:

# app/config/config.yml
dmytrof_push_notification:
    provider: one_signal
    one_signal:                                                 # See: https://documentation.onesignal.com/docs/web-push-sdk-setup-http
        app_id: "%one_signal.app_id%"
        app_auth_key: "%one_signal.auth_key%"
        safari_web_id: "%one_signal.safari_web_id%"     # Safari Support (Optional). See: https://documentation.onesignal.com/docs/web-push-sdk-setup-http#section-3-safari-support-optional-
        subdomain: "%one_signal.subdomain%"             # HTTP Setup ONLY. See https://documentation.onesignal.com/docs/web-push-sdk-setup-http#section-1-4-choose-subdomain

Usage

Web Push SDK Setup

{# layout.html.twig #}
<head>
{# ... #}

{{ dmytrof_push_notification_web_sdk() }}
</head>

Tag your users

<?php
// SomeController

public function addTagAction()
{
    // ...

    $this->get('dmytrof_push_notification.provider')->addTag('tagName', 'tagValue');

    // ...
}

public function addTagsAction()
{
    // ...

    $this->get('dmytrof_push_notification.provider')->addTags([
        'tagName1' => 'value1',
        'tagName2' => 'value2'
    ]);

    // ...
}

Users will be tagged after rendering of layout with Web Push SDK

Remove tags

<?php
// SomeController

public function removeTagsAction()
{
    // ...

    $this->get('dmytrof_push_notification.provider')->removeTags([
        'tagName1',
        'tagName2'
    ]);

    // ...
}

Tags will be removed after rendering of layout with Web Push SDK

Send Push Notification

<?php
// SomeController

public function sendNotificationAction()
{
    // Send to all

    $provider = $this->get('dmytrof_push_notification.provider');
    $notification = $provider->createNotification()
                                ->setSubject('Notification Subject')
                                ->setMessage('Test notification for all')
                                ->includeSegments(['All']);

    $provider->sendNotification($notification);

    // Filter by tags

    $notification = $provider->createNotification()
                                ->setSubject('Notification Subject')
                                ->setMessage('Filtered by tags')
                                ->filterByTag('tagName1', '=', 'value1')
                                ->filterByTag('tagName2', '=', 'value2', true);
    $provider->sendNotification($notification);

    // Send templated message to user

    $notification = $provider->createNotification()
                                ->setTemplate('AppBundle:PushNotification:test_notification.html.twig', [
                                    'user' => $user
                                ])
                                ->filterByTag('userId', '=', $user->getId());
    $provider->sendNotification($notification);
}

Configure message template:

{# 'AppBundle:PushNotification:test_notification.html.twig' #}
{% extends 'DmytrofPushNotificationBundle:PushNotification:layout.html.twig' %}

{% block Subject %}
    Test templated subject
{% endblock %}

{% block Message %}
    Your user ID: {{ user.id }}
{% endblock %}

{% block Url %}
    {{ absolute_url(path('YOUR_ROUTE')) }}
{% endblock %}

All versions of push-notification-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6
twig/twig Version 1.*
symfony/framework-bundle Version ^2.8
php-http/guzzle6-adapter Version ^1.1
norkunas/onesignal-php-api Version 1.0.x-dev
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 dmytrof/push-notification-bundle contains the following files

Loading the files please wait ....