2017 © Pedro Peláez
 

library snowfire-app

image

snowfire/snowfire-app

  • Saturday, April 11, 2015
  • by emilsundberg
  • Repository
  • 6 Watchers
  • 0 Stars
  • 176 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Snowfire App

This packages makes it possible to connect your Laravel app to Snowfire., (*1)

Install the package

Add this to your composer.json, (*2)

"snowfire/snowfire-app": "dev-master"

Add this to your service providers in config/app.php, (*3)

'Snowfire\App\SnowfireServiceProvider'

Add this to your route middlewares in app/Http/Kernel.php, (*4)

'snowfire' => 'Snowfire\App\Middleware\SnowfireMiddleware',
'snowfireAdmin' => 'Snowfire\App\Middleware\SnowfireAdminMiddleware',

Publish the config file, (*5)

$ php artisan vendor:publish

Create the database table for snowfire installations, (*6)

$ php artisan migrate

Seed data

Add this to your DatabaseSeeder.php, (*7)

$this->call('\Snowfire\App\Storage\Seeder');

CSRF protection

If you have CSRF middleware activated in app/Http/Kernel.php open app/Http/Middleware/VerifyCsrfToken.php and add the following to the handle method:, (*8)

if ($request->header('User-Agent') == 'Snowfire')
{
    return $next($request);
}

Integration possibilities

There are two different ways to connect your app to Snowfire. As a link in the admin area and as a public action., (*9)

Example

Lets say you have a list of events. A public action will be something like http://your-app.com/events/all which will render an HTML <ul> list. Then you will have an admin link from Snowfire to http://your-app.com/admin which will let users add/edit/remove events., (*10)

Start by adding your actions to config/snowfire_app.php, (*11)

return [
    'id' => 'demo_app',
    'name' => 'Demo app',
    'tab' => 'admin',
    'actions' => [
        'events' => 'action.events.index',
        'event' => 'action.events.show',
    ]
];

This config adds the admin link as a named route called snowfire.tab and a route for all events. Both tab and actions are optional (but you need one of them, right?), (*12)

Your routes.php


// Admin routes Route::group(['prefix' => 'admin/{snowfireAppId}', 'before' => 'snowfireAppAuth', 'namespace' => 'Admin'], function() { Route::get('/', ['as' => 'admin.index', function($appId) { return 'Admin for appId: ' . $appId; }]); }); // Action routes Route::group(['namespace' => 'Action'], function() { Route::get('events', ['uses' => 'EventsController@index', 'as' => 'action.events.index']); Route::get('events/{id}', ['uses' => 'EventsController@event', 'as' => 'action.events.show']); });

This creates an admin route and the public action. The admin route is behind a snowfireAppAuth filter which makes sure the user is logged in and trusted., (*13)

Your Snowfire snippet to the public event list

Login to Snowfire and install the app (System -> Apps), (*14)

http://your-hosted-app.com/snowfire/install

Create a new snippet with this code:, (*15)

<?xml version="1.0" encoding="utf-8"?>
<snippet>
    <name>All events</name>
    <html><![CDATA[
        { com_application2 (
            id: '{{ component_id_0 }}',
            description: 'Demo App',
            app: 'demo_app',
            action: 'events',
            debug: 'true'
        ) }
    ]]></html>
</snippet>

Warning: Adding applications to the root / (i.e the home page) is currently not supported. Please create a sub page to add your app., (*16)

Now just add the snippet to a page and it will show you a list of events., (*17)

When you are working in an action that will be rendered within Snowfire, you need to use:, (*18)

<a href="{{ Snowfire::route('my.route') }}">A linked route</a>

This will make sure the links works from within Snowfire., (*19)

The Versions

11/04 2015

dev-master

9999999-dev

  Sources   Download

The Requires

 

by Emil Sundberg
by Markus Hedlund

21/02 2015

1.x-dev

1.9999999.9999999.9999999-dev

  Sources   Download

The Requires

 

by Emil Sundberg
by Markus Hedlund

10/02 2015

1.0

1.0.0.0

  Sources   Download

The Requires

 

by Emil Sundberg
by Markus Hedlund

10/02 2015

dev-laravel-4

dev-laravel-4

  Sources   Download

The Requires

 

by Emil Sundberg
by Markus Hedlund