Juno Release

Sep 27, 2017

Contents

1 Juno 1 1.1 Installing...... 1

2 Embedding 3 2.1 StackPHP...... 3 2.2 Within a Silex Application...... 4

3 Extending 5 3.1 Templates...... 5

i ii CHAPTER 1

Juno

Juno is a small web application build in Silex and AngularJS. It provides a nice interface for introspection and moni- toring of Bernard. It can be run as a single application or it can be embedded Silex through a Service Provider. Also i can be wrapped with StackPHP and be pseudu embedded. You can read more about StackPHP here.

Installing

As all other appliations in the PHP world Juno is installed through . Composer will handle autoloading and package dependency resolvement.

composer require bernard/juno:~1.0

To run Juno on its own just install it with Composer and create a front controller. Juno provides a function that bootstraps the application. As the function returns the instance it is possible to do any configuration at this point.

$app= Juno\create_application($debug= true);

Now copy the frontend resources in to a folder that lets /juno/app.js be found. Assuming we use web as the document root this will look like this. Also you can do a symlink.

$ cp -R vendor/bernard/juno/src/Resources/public web/juno

1 Juno, Release

2 Chapter 1. Juno CHAPTER 2

Embedding

Just as you can run Juno on its own, it is also possible to embed it into you application or run it side by side using StackPHP.

StackPHP

To run within StackPHP you need its url-map package. Now push Juno on to your map. Using StackPHP enables you to embed it into any application that is build on HttpKernelInterface. Thee applications includes , , Silex, Flint, and a bunch or others.

$juno= Juno\create_application($debug= true); // Configure $juno here.

$map= new Stack\UrlMap($myApp, array( '/_juno' => $juno, ));

// Assuming $app contains your normal HttpKernel application. $map->handle();

Instead of doing the handle() call explicitly it is encouraged to use Stack\run which handles calling the right events etc.

use Stack\UrlMap;

$map= new UrlMap($myApp, array( '/_juno', Juno\create_application($debug= true), ));

3 Juno, Release

Stack\run($map);

Within a Silex Application

Juno is written as ServiceProviderInterface and ControllerProviderInterface implementations. This lets you embed it directly by using the service providers. The service provider uses the boot method to mount the controller provider.

$app= new Silex\Applcation(array('debug' => true)); $app->register(new BernardServiceProvider); $app->register(new JunoServiceProvider, array( 'juno.mount_prefix' => '/_juno', )); $app->run();

4 Chapter 2. Embedding CHAPTER 3

Extending

As each Bernard installiation can use custom middleware that could collect statistics and so on. It is important that theese can be shown in Juno.

Templates

Juno uses for templating this makes it easy to override. All templates used by Juno are under the Juno names- pace. This means accessing a template would be @Juno/queue.html.twig. src/Resources/views/base.html.twig contains the layout with its blocks used by Juno. This includes the layout and different blocks. To override using this create a new layout.html.twig file and extend @Juno/ base.html.twig.

{% extends '@Juno/base.html.twig' %}

{% block stylesheets %} {% endblock %}

Remember to prepend you new path to twigs file loader so it will be checked before the standard templates. This is done by extending the service.

$app['twig.loader.filesystem']= $app->share($app->extend('twig.loader.filesystem',

˓→function ($loader){ $loader->prependPath('/my/override/dir', 'Juno');

return $loader; }));

For a list of templates look in src/Resources/views where the also the templates used for can be found.

5 Juno, Release

Blocks

Everything in the layout is defined as blocks to make it easy to override. Also it is possible to turn specific stuff off such as the “Fork me on GitHub!” ribbon. Here is a layout.html.twig template which overrides all the blocks

{% extends '@Juno/base.html.twig' %}

{% block ribbon'' %}

{% block title 'Not Juno' %}

{% block stylesheets %} {{ parent() }}

{# additional style includes #} {% endblock %}

{% block %} {{ parent() }}

{# additional script includes #} {% endblock %}

6 Chapter 3. Extending