SlideShare ist ein Scribd-Unternehmen logo
1 von 60
Downloaden Sie, um offline zu lesen
Terrific Composer
Makes your life easier…
Agenda

Concept

Terrific Composer
   ‣ Installation
   ‣ Twig
   ‣ Pages
   ‣ Modules & Skins
   ‣ Layout
   ‣ Dev -> Prod




Remo Brunschwiler   10. July 2012   #   3
Github
Take it. Make it better. Together.
Repositories

TerrificJS
   ‣ https://github.com/brunschgi/terrificjs

Terrific Composer (Symfony2 Edition)
   ‣ https://github.com/brunschgi/terrific-composer

Terrific Symfony2 Bundles
   ‣ https://github.com/brunschgi/TerrificCoreBundle
   ‣ https://github.com/brunschgi/TerrificComposerBundle




Remo Brunschwiler   10. July 2012                          #   5
Showcases
See Terrific in action
Remo Brunschwiler   14. August 2012   #   7
Concept
It’s really easy…
Hold on a minute!

Before we dive deeper into the Terrific Composer…




Remo Brunschwiler                                   #   9
Hold on a minute!

Before we dive deeper into the Terrific Composer…



Lets refresh our Terrific
knowledge!
http://www.slideshare.net/brunschgi/terrific-frontends




Remo Brunschwiler                                        #   9
Terrific Composer
Makes your life easier…
Terrific Composer

Frontend Development Framework
   ‣ Designed for building frontends / applications based on the
     Terrific concept
   ‣ Integrates TerrificJS
   ‣ Based on Symfony
   ‣ … still very young




Remo Brunschwiler   10. July 2012                                  #   11
Terrific Composer

Frontend Development Framework
   ‣ Designed for building frontends / applications based on the
     Terrific concept
   ‣ Integrates TerrificJS
   ‣ Based on Symfony
   ‣ … still very young



… melts dozens of best practices!




Remo Brunschwiler   10. July 2012                                  #   11
Documentation

Terrific Composer
   ‣ Unfortunately, a specific documentation does not exist yet
   ‣ Any help is gladly appreciated!!

Symfony Documentation
   ‣ http://symfony.com/doc/current/quick_tour/the_big_picture.html
     – quick tour
   ‣ http://symfony.com/doc/current/book/ – really great in-depth
     documentation!
   ‣ http://symfony.com/doc/current/cookbook/ – solutions and
     tutorials for common tasks
   ‣ http://symfony.com/doc/current/components/index.html –
     symfony components documentation



Remo Brunschwiler   10. July 2012                                   #   12
Installation
Very fast setup for your project!
Download it from: http://terrifically.org/composer/


 Installation




Remo Brunschwiler   10. July 2012                     # 14
Explore
… the sidebar and their possibilities
Create


                                    Add new Modules & Skins to your project.
                                    The Skeleton is generated for you so that
                                    you can start right away.




Remo Brunschwiler   10. July 2012                                        #   16
Open


                                    The Open dialog provides you fast access to
                                    all of your Modules and Pages.




Remo Brunschwiler   10. July 2012                                       #   17
Inspect


                                    The inspect mode shows you which modules
                                    are in use on the current page.




Remo Brunschwiler   10. July 2012                                    #   18
Twig
The flexible, fast, and secure template engine for PHP
Twig

Symfony comes with a powerful templating language called Twig
   ‣ http://symfony.com/doc/current/book/templating.html
   ‣ http://twig.sensiolabs.org/documentation



…I couldn’t have explained it better, so have a look at the links
above :-)




Remo Brunschwiler   10. July 2012                                   # 20
IDE Integration

Twig is a quite young project, but there is already support for
several IDEs:
   ‣ PhpStorm (native as of 2.1) – recommended!!
   ‣ Textmate via the Twig bundle
   ‣ Vim via the Jinja syntax plugin
   ‣ Netbeans via the Twig syntax plugin
   ‣ Eclipse via the Twig plugin
   ‣ Sublime Text via the Twig bundle
   ‣ Coda 2 via the other Twig syntax mode




Remo Brunschwiler   10. July 2012                                 #   21
Hands on!
Terrific Composer – Step by Step
Step by Step

Common Tasks
   ‣ Create a new page
   ‣ Create a new Module / Skin
   ‣ Create a new layout
   ‣ Development -> Productive




Remo Brunschwiler   10. July 2012   # 23
Pages
Play Lego!
… Let’s see it in action




Remo Brunschwiler   10. July 2012   # 25
Create a new page

Things to do
   1. Create a new or extend an existing controller
   2. Create an action in the controller
   3. Set annotations (@Template, @Route, @Composer)
   4. Create a view (twig file) in /Resources/views/




Remo Brunschwiler   10. July 2012                      # 26
1. Create / Extend Controller

<?php
namespace TerrificCompositionController;

use   SymfonyBundleFrameworkBundleControllerController;
use   TerrificComposerBundleAnnotationComposer;
use   SensioBundleFrameworkExtraBundleConfigurationRoute;
use   SensioBundleFrameworkExtraBundleConfigurationTemplate;

class DefaultController extends Controller
{
}

Things to consider
   ‣ PHP 5.3 namespace describes where the class is located
   ‣ Filename = ClassName, eg. DefaultController.php
     -> needed for classloading
   ‣ PHP 5.3 use statements for base controller and annotations


Remo Brunschwiler   10. July 2012                                  # 27
2. Create Action

class DefaultController extends Controller
{
    /**
      * @Composer("Welcome")
      * @Route("/", name="home")
      * @Template()
      */
    public function indexAction()
    {
         return array();
    }
}

Things to consider
   ‣ action name must end in Action
   ‣ return statement of an action is a Response object
     -> in our case it is and array: because of @Template()



Remo Brunschwiler   10. July 2012                             # 28
3. Set Annotations
/**
  * @Composer("Welcome")
  * @Route("/", name="home")
  * @Template()
  */
public function indexAction()
{
     return array();
}

@Composer(<name>)
   ‣ The given name will appear in the open dialog

@Route(“<path>”, name=”<name”)
   ‣ Describes the path under which the page is available
   ‣ For more options have a look at @Route

@Template()
   ‣ Specifies which template should be rendered (@Template documentation)



Remo Brunschwiler   10. July 2012                                      # 29
4. Create Twig View

/Resources/views/<ControllerName>/<actionName>.html.twig

   {% extends 'TerrificComposition::base.html.twig' %}

   {% block title %}Terrific Composer - Welcome{% endblock %}

   {% block body %}
   <div class="page">
     … here comes your stuff …
   </div>
   {% endblock %}



Things to consider
‣ Extend the layout of your choice
‣ Override / Extend the twig blocks you need


Remo Brunschwiler   10. July 2012                               # 30
Twig Blocks

Provided from TerrificCoreBundle::base.html.twig
   ‣ title – content of the <title> element
   ‣ meta – for meta tags (<meta charset="UTF-8"/> is always set)
   ‣ styles – the place for your stylesheets
   ‣ body_class – allows you to give your body a class
   ‣ composition – your content goes here
   ‣ jquery – jquery script element
   ‣ terrificjs – terrificjs script element
   ‣ scripts – the place for your javascripts
   ‣ bootstrap – the default terrificjs bootstrap



Remo Brunschwiler   10. July 2012                                   #   31
Hands on!

Create a new page that…
   ‣ is available under /workshop
   ‣ appears in the open dialog as “Workshop”
   ‣ has the same content as the homepage




Remo Brunschwiler   10. July 2012               # 32
Hands on!

Create a new page that…
   ‣ is available under /workshop
   ‣ appears in the open dialog as “Workshop”
   ‣ has the same content as the homepage

Enhance the page, so that…
   ‣ you can type an URL like /workshop/{title}
   ‣ the {title} is displayed as heading before the Intro module
   ‣ and if no title is given, “Terrific Composer” should be displayed
     instead




Remo Brunschwiler   10. July 2012                                    # 32
Twig Module Macro
{#
      Renders terrific modules.

      @param   name {String} name of the module
      @param   view {String} name of the view to render (without html.twig suffix) [optional]
      @param   skins {Array} contains the skins to apply [optional]
      @param   connectors {Array} contains the channel ids to connect to [optional]
      @param   attrs {Object} contains the additional html attributes for the module [optional]
      @param   data {Object} contains the data to pass to embedded controllers [optional]
#}
{% macro module(name, view, skins, connectors, attrs, data) %}



To consider
     ‣ Twig 1.x does not support things like:
      {{ tc.module('Intro', attrs={'data-name' : 'einstein'}) }}
      -> this is going to change with Twig 2.0



Remo Brunschwiler    10. July 2012                                                   # 33
Render Modules #1

Simple views without logic

{# this render the template with the same name (intro.html.twig) #}
{{ tc.module('Intro') }}

{# this renders the mrterrific template from the Hero Module #}
{{ tc.module('Hero', 'mrterrific')}}

{# the 3rd param is the Skins array, ie. Mr. Terrific is getting decorated
with the Stealth Skin #}
{{ tc.module('Hero', 'mrterrific', [ 'Stealth' ])}}

{# the 4th param is an array with communication channel ids, ie. all
modules with the same id can talk with each other #}
{{ tc.module('Hero', 'mrterrific', ['Stealth'], ['talk'])}}

{# the 5th param is the attrs object #}
{{ tc.module('Hero', 'mrterrific', null, null, { ‘data-name’ :
‘Mr. Terrific‘})}}


Remo Brunschwiler   10. July 2012                                       # 34
Render Modules #2

Complex views
‣ the concept is – thanks to TWIG – very simple
  http://symfony.com/doc/current/book/
  templating.html#embedding-controllers
‣ have their own controllers, actions & templates
‣ gives you Multi-MVC out-of-the-box
‣ are used rarely in plain “templating” projects


{{ tc.module('Filter','Filter:overspeed', null, null, null, {'segment':'washing'})}}

                embeds the view of the FilterController/   the data passed to the
                 overspeedAction in the Filter module         overspeedAction




Remo Brunschwiler   10. July 2012                                                   # 35
Hands on!

Enhance your workshop page, so that…
   ‣ only two of the heroes can talk with each other
   ‣ the {title} is rendered inside the speech bubble of Einstein




Remo Brunschwiler   10. July 2012                                   # 36
Modules & Skins
Get more flexibility…
What we want to achieve

Create a new «Victim» module, that…
   ‣ consists of a normal image (drowning man) & a background
     image (bubble)
   ‣ uses less for better code
   ‣ is able to call our heroes for help




Remo Brunschwiler   10. July 2012                               # 38
Markup

<div class="bubble">
    <span class="message">help!</span>
</div>
<img src="
  {{ asset("bundles/terrificmodulevictim/img/drowning-victim.png") }}
"/>
<a class="base" href="#help">Call for help!</a>


                                            links to image asset in /web/bundles/…


But how is the drowning-victim.png got there?
   ‣ The composer copies all module images on the fly to
     /web/bundles/<bundle>/img/ (configurable in config_dev.yml)

How did you come up with that path?
   ‣ Symfony standard: app/console assets:install


Remo Brunschwiler   10. July 2012                                           # 39
Import directive (mixins, variables etc.)
/* import.less */
@import "colors.less";
@import "mixins.less";

/* colors.less */
@text: #74AE00;               variable

/* mixins.less*/
.scale(@ratio) {             mixin function
  -webkit-transform:        scale(@ratio);
     -moz-transform:        scale(@ratio);
      -ms-transform:        scale(@ratio);
       -o-transform:        scale(@ratio);
          transform:        scale(@ratio);
}




Remo Brunschwiler   10. July 2012             # 40
/* @group Module: victim */
@import "../../../../../Composition/Resources/public/css/import.less";

@media screen {
                                           cascaded import – import.less has other imports
    .mod-victim {
        position: relative;

           .bubble {   nested rules -> .mod-victim .bubble { … }
               background: transparent url('../bubble.png') no-repeat 0 0;
               ...
           }
                   access variable             relative to less file
           .message {
               color: @text;
               font-size: 36 / 16em;
               ...
           }                 calculation
           ...
      }
}




Remo Brunschwiler   10. July 2012                                                 #   41
There is even more to less! Have a look at the documentation
   ‣ http://lesscss.org




Remo Brunschwiler   10. July 2012                              # 42
TerrificJS

on:function (callback) {
    var self = this,
        $ctx = this.$ctx;

      $('a', $ctx).on('click', function() {
          var message = $('.message', $ctx).text();

            self.fire('message', { name: 'drowner', message: message });

            return false;
      });

      callback();
}



Nothing special here, but mention the new naming of the hooks in
TerrificJS v2.0



Remo Brunschwiler   10. July 2012                                          # 43
Hands on!

Create a skin for your Victim that lets him drown when there is no
help from one of the heroes
   ‣ Create skin “Drown” for your Victim
   ‣ Write a simple drown functionality (eg. fadeOut)
   ‣ Trigger this functionality automatically after ~5 seconds
   ‣ Do not let your Victim drown when he calls for help within the
     given time frame




Remo Brunschwiler   10. July 2012                                     # 44
Layouts
Let’s say thanks to TWIG & Assetic
Layouts

A layouts job is to do stuff that is common to several pages
   ‣ javascripts
   ‣ styles
   ‣ meta tags
   ‣ header, footer, sidebar etc.

Thanks to TWIG & Assetic, layouts are no longer a big & inflexible
thing…




Remo Brunschwiler   10. July 2012                                    # 46
Twig Layout Approach

In Twig a layout is nothing more than an inherited template
   ‣ http://symfony.com/doc/current/book/templating.html#template-
     inheritance-and-layouts

In your page:                       this is your layout


   {% extends 'TerrificComposition::base.html.twig' %}

   {% block title %}Terrific Composer - Welcome{% endblock %}

   {% block body %}
   <div class="page">
     … here comes your stuff …
   </div>
   {% endblock %}




Remo Brunschwiler   10. July 2012                               # 47
Twig Layout Approach

In TerrificComposition::base.html.twig

{% extends 'TerrificCoreBundle::base.html.twig' %}          Terrific Core Layout

{% block title %}Terrific Composer{% endblock %}
…
{# content that is the same on every page goes into composition #}
{% block composition %}

{# your page content goes into body #}
{% block body %}    this block is overridden in your page
{% endblock %}

{% endblock %}
…




Remo Brunschwiler   10. July 2012                                                  # 48
Including JavaScripts

Symfony comes bundled with a very nice Assetic integration

Including JavaScripts has never been easier
                                     concatenates – and minifies in production
{% block scripts %}                       mode – all files in this directory
    {# here comes your scripts #}
    {% javascripts
    '@TerrificComposition/Resources/public/js/*.*'
    output='js/compiled/statics.js'      the name of the compiled file
    %}
        <script src="{{ asset_url }}" type="text/javascript"></script>
    {% endjavascripts %}

    {# scripts from parent (terrific core) layout #}
    {{ parent() }}      includes the content of the parent block
{% endblock %}




Remo Brunschwiler   10. July 2012                                                # 49
Including Stylesheets

… and the same for stylesheets
                                       concatenates – and minifies in production
                                             mode – all of the given files
{% block styles %}
    {% stylesheets
        '@TerrificComposition/Resources/public/css/reset.less'
        '@TerrificComposition/Resources/public/css/grid.less'
        '@TerrificComposition/Resources/public/css/elements.less'
        output="css/compiled/project.css"     the name of the compiled file
    %}
        <link rel="stylesheet" href="{{ asset_url }}" />
    {% endstylesheets %}

    {# styles from parent (terrific core) layout #}
    {{ parent() }}      includes the content of the parent block
{% endblock %}




Remo Brunschwiler   10. July 2012                                                  # 50
Dev -> Prod
Prepare your assets for the real world
Productive

The productive version is…
   ‣ available under / (instead of /app_dev.php)

Dumping assets
   ‣ php app/console assets:install web

Compile CSS / JS
   ‣ php app/console assetic:dump --env=prod




Remo Brunschwiler   10. July 2012                  # 52
Questions?
More…
More…

Lets keep talking
   ‣ http://terrifically.org
   ‣ remo@terrifically.org
   ‣ https://github.com/brunschgi
   ‣ http://twitter.com/#!/brunschgi




Remo Brunschwiler   10. July 2012      # 55
Remo Brunschwiler   10. July 2012   # 56
Thank you!

Weitere ähnliche Inhalte

Was ist angesagt?

Behavior & Specification Driven Development in PHP - #OpenWest
Behavior & Specification Driven Development in PHP - #OpenWestBehavior & Specification Driven Development in PHP - #OpenWest
Behavior & Specification Driven Development in PHP - #OpenWestJoshua Warren
 
Flutter movie apps tutor
Flutter movie apps tutorFlutter movie apps tutor
Flutter movie apps tutorHerry Prasetyo
 
Dockercon - Building a Chef cookbook testing pipeline with Drone.IO and Docker
Dockercon - Building a Chef cookbook testing pipeline with Drone.IO and DockerDockercon - Building a Chef cookbook testing pipeline with Drone.IO and Docker
Dockercon - Building a Chef cookbook testing pipeline with Drone.IO and Dockerpczarkowski
 
Creating Openbravo Workspace Widgets
Creating Openbravo Workspace WidgetsCreating Openbravo Workspace Widgets
Creating Openbravo Workspace WidgetsRob Goris
 
Introduction to Continous Integration with WordPress
Introduction to Continous Integration with WordPressIntroduction to Continous Integration with WordPress
Introduction to Continous Integration with WordPressSeagyn Davis
 
Asynchronous Programming at Netflix
Asynchronous Programming at NetflixAsynchronous Programming at Netflix
Asynchronous Programming at NetflixC4Media
 

Was ist angesagt? (7)

Behavior & Specification Driven Development in PHP - #OpenWest
Behavior & Specification Driven Development in PHP - #OpenWestBehavior & Specification Driven Development in PHP - #OpenWest
Behavior & Specification Driven Development in PHP - #OpenWest
 
Flutter movie apps tutor
Flutter movie apps tutorFlutter movie apps tutor
Flutter movie apps tutor
 
Dockercon - Building a Chef cookbook testing pipeline with Drone.IO and Docker
Dockercon - Building a Chef cookbook testing pipeline with Drone.IO and DockerDockercon - Building a Chef cookbook testing pipeline with Drone.IO and Docker
Dockercon - Building a Chef cookbook testing pipeline with Drone.IO and Docker
 
Creating Openbravo Workspace Widgets
Creating Openbravo Workspace WidgetsCreating Openbravo Workspace Widgets
Creating Openbravo Workspace Widgets
 
Introduction to Continous Integration with WordPress
Introduction to Continous Integration with WordPressIntroduction to Continous Integration with WordPress
Introduction to Continous Integration with WordPress
 
Asynchronous Programming at Netflix
Asynchronous Programming at NetflixAsynchronous Programming at Netflix
Asynchronous Programming at Netflix
 
Maven 3.0 at Øredev
Maven 3.0 at ØredevMaven 3.0 at Øredev
Maven 3.0 at Øredev
 

Andere mochten auch

德國氣球節
德國氣球節德國氣球節
德國氣球節mapart
 
這些年.這些事
這些年.這些事這些年.這些事
這些年.這些事mapart
 
WL4 Firewall
WL4 FirewallWL4 Firewall
WL4 Firewallcormacmcd
 
Developer sales staff amas power point presentation
Developer sales staff amas power point presentationDeveloper sales staff amas power point presentation
Developer sales staff amas power point presentationLARRY FOSTER
 
Check mate infidelity test press release
Check mate infidelity test press releaseCheck mate infidelity test press release
Check mate infidelity test press releaseCheck Mate Test, LLC
 
VSTS in a nutshell for project lifecycle management
VSTS in a nutshell  for project lifecycle managementVSTS in a nutshell  for project lifecycle management
VSTS in a nutshell for project lifecycle managementPhanindra Kishore
 

Andere mochten auch (6)

德國氣球節
德國氣球節德國氣球節
德國氣球節
 
這些年.這些事
這些年.這些事這些年.這些事
這些年.這些事
 
WL4 Firewall
WL4 FirewallWL4 Firewall
WL4 Firewall
 
Developer sales staff amas power point presentation
Developer sales staff amas power point presentationDeveloper sales staff amas power point presentation
Developer sales staff amas power point presentation
 
Check mate infidelity test press release
Check mate infidelity test press releaseCheck mate infidelity test press release
Check mate infidelity test press release
 
VSTS in a nutshell for project lifecycle management
VSTS in a nutshell  for project lifecycle managementVSTS in a nutshell  for project lifecycle management
VSTS in a nutshell for project lifecycle management
 

Ähnlich wie Terrific Composer Workshop

Tips and Tricks for Using Visual Studio.Net Effectively
Tips and Tricks for Using Visual Studio.Net EffectivelyTips and Tricks for Using Visual Studio.Net Effectively
Tips and Tricks for Using Visual Studio.Net Effectivelyweili_at_slideshare
 
Chrome & Webkit overview
Chrome & Webkit overviewChrome & Webkit overview
Chrome & Webkit overviewBin Chen
 
Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]GDSC UofT Mississauga
 
Guide: How to Build OpenCV 3.0.0
Guide: How to Build OpenCV 3.0.0Guide: How to Build OpenCV 3.0.0
Guide: How to Build OpenCV 3.0.0André Moreira
 
Fast Paced Drupal 8: Accelerating Development with Composer, Drupal Console a...
Fast Paced Drupal 8: Accelerating Development with Composer, Drupal Console a...Fast Paced Drupal 8: Accelerating Development with Composer, Drupal Console a...
Fast Paced Drupal 8: Accelerating Development with Composer, Drupal Console a...Acquia
 
JavaScript guide 2020 Learn JavaScript
JavaScript guide 2020 Learn JavaScriptJavaScript guide 2020 Learn JavaScript
JavaScript guide 2020 Learn JavaScriptLaurence Svekis ✔
 
Makefile
MakefileMakefile
MakefileIonela
 
Desktop apps with node webkit
Desktop apps with node webkitDesktop apps with node webkit
Desktop apps with node webkitPaul Jensen
 
His162013 140529214456-phpapp01
His162013 140529214456-phpapp01His162013 140529214456-phpapp01
His162013 140529214456-phpapp01Getachew Ganfur
 
Docker Introduction.pdf
Docker Introduction.pdfDocker Introduction.pdf
Docker Introduction.pdfOKLABS
 
JavaScript Presentation Frameworks and Libraries
JavaScript Presentation Frameworks and LibrariesJavaScript Presentation Frameworks and Libraries
JavaScript Presentation Frameworks and LibrariesOleksii Prohonnyi
 
Hacking the Kinect with GAFFTA Day 1
Hacking the Kinect with GAFFTA Day 1Hacking the Kinect with GAFFTA Day 1
Hacking the Kinect with GAFFTA Day 1benDesigning
 
Web components Introduction
Web components IntroductionWeb components Introduction
Web components IntroductionEugenio Romano
 

Ähnlich wie Terrific Composer Workshop (20)

Tips and Tricks for Using Visual Studio.Net Effectively
Tips and Tricks for Using Visual Studio.Net EffectivelyTips and Tricks for Using Visual Studio.Net Effectively
Tips and Tricks for Using Visual Studio.Net Effectively
 
Chrome & Webkit overview
Chrome & Webkit overviewChrome & Webkit overview
Chrome & Webkit overview
 
Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]
 
Terrific Frontends
Terrific FrontendsTerrific Frontends
Terrific Frontends
 
Guide: How to Build OpenCV 3.0.0
Guide: How to Build OpenCV 3.0.0Guide: How to Build OpenCV 3.0.0
Guide: How to Build OpenCV 3.0.0
 
web application.pptx
web application.pptxweb application.pptx
web application.pptx
 
Fewd week1 slides
Fewd week1 slidesFewd week1 slides
Fewd week1 slides
 
CEF.net
CEF.netCEF.net
CEF.net
 
Fast Paced Drupal 8: Accelerating Development with Composer, Drupal Console a...
Fast Paced Drupal 8: Accelerating Development with Composer, Drupal Console a...Fast Paced Drupal 8: Accelerating Development with Composer, Drupal Console a...
Fast Paced Drupal 8: Accelerating Development with Composer, Drupal Console a...
 
Untangling4
Untangling4Untangling4
Untangling4
 
JavaScript guide 2020 Learn JavaScript
JavaScript guide 2020 Learn JavaScriptJavaScript guide 2020 Learn JavaScript
JavaScript guide 2020 Learn JavaScript
 
Makefile
MakefileMakefile
Makefile
 
Desktop apps with node webkit
Desktop apps with node webkitDesktop apps with node webkit
Desktop apps with node webkit
 
C++ for hackers
C++ for hackersC++ for hackers
C++ for hackers
 
His162013 140529214456-phpapp01
His162013 140529214456-phpapp01His162013 140529214456-phpapp01
His162013 140529214456-phpapp01
 
Fewd week4 slides
Fewd week4 slidesFewd week4 slides
Fewd week4 slides
 
Docker Introduction.pdf
Docker Introduction.pdfDocker Introduction.pdf
Docker Introduction.pdf
 
JavaScript Presentation Frameworks and Libraries
JavaScript Presentation Frameworks and LibrariesJavaScript Presentation Frameworks and Libraries
JavaScript Presentation Frameworks and Libraries
 
Hacking the Kinect with GAFFTA Day 1
Hacking the Kinect with GAFFTA Day 1Hacking the Kinect with GAFFTA Day 1
Hacking the Kinect with GAFFTA Day 1
 
Web components Introduction
Web components IntroductionWeb components Introduction
Web components Introduction
 

Kürzlich hochgeladen

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 

Kürzlich hochgeladen (20)

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 

Terrific Composer Workshop

  • 1.
  • 3. Agenda Concept Terrific Composer ‣ Installation ‣ Twig ‣ Pages ‣ Modules & Skins ‣ Layout ‣ Dev -> Prod Remo Brunschwiler 10. July 2012 # 3
  • 4. Github Take it. Make it better. Together.
  • 5. Repositories TerrificJS ‣ https://github.com/brunschgi/terrificjs Terrific Composer (Symfony2 Edition) ‣ https://github.com/brunschgi/terrific-composer Terrific Symfony2 Bundles ‣ https://github.com/brunschgi/TerrificCoreBundle ‣ https://github.com/brunschgi/TerrificComposerBundle Remo Brunschwiler 10. July 2012 # 5
  • 7. Remo Brunschwiler 14. August 2012 # 7
  • 9. Hold on a minute! Before we dive deeper into the Terrific Composer… Remo Brunschwiler # 9
  • 10. Hold on a minute! Before we dive deeper into the Terrific Composer… Lets refresh our Terrific knowledge! http://www.slideshare.net/brunschgi/terrific-frontends Remo Brunschwiler # 9
  • 12. Terrific Composer Frontend Development Framework ‣ Designed for building frontends / applications based on the Terrific concept ‣ Integrates TerrificJS ‣ Based on Symfony ‣ … still very young Remo Brunschwiler 10. July 2012 # 11
  • 13. Terrific Composer Frontend Development Framework ‣ Designed for building frontends / applications based on the Terrific concept ‣ Integrates TerrificJS ‣ Based on Symfony ‣ … still very young … melts dozens of best practices! Remo Brunschwiler 10. July 2012 # 11
  • 14. Documentation Terrific Composer ‣ Unfortunately, a specific documentation does not exist yet ‣ Any help is gladly appreciated!! Symfony Documentation ‣ http://symfony.com/doc/current/quick_tour/the_big_picture.html – quick tour ‣ http://symfony.com/doc/current/book/ – really great in-depth documentation! ‣ http://symfony.com/doc/current/cookbook/ – solutions and tutorials for common tasks ‣ http://symfony.com/doc/current/components/index.html – symfony components documentation Remo Brunschwiler 10. July 2012 # 12
  • 15. Installation Very fast setup for your project!
  • 16. Download it from: http://terrifically.org/composer/ Installation Remo Brunschwiler 10. July 2012 # 14
  • 17. Explore … the sidebar and their possibilities
  • 18. Create Add new Modules & Skins to your project. The Skeleton is generated for you so that you can start right away. Remo Brunschwiler 10. July 2012 # 16
  • 19. Open The Open dialog provides you fast access to all of your Modules and Pages. Remo Brunschwiler 10. July 2012 # 17
  • 20. Inspect The inspect mode shows you which modules are in use on the current page. Remo Brunschwiler 10. July 2012 # 18
  • 21. Twig The flexible, fast, and secure template engine for PHP
  • 22. Twig Symfony comes with a powerful templating language called Twig ‣ http://symfony.com/doc/current/book/templating.html ‣ http://twig.sensiolabs.org/documentation …I couldn’t have explained it better, so have a look at the links above :-) Remo Brunschwiler 10. July 2012 # 20
  • 23. IDE Integration Twig is a quite young project, but there is already support for several IDEs: ‣ PhpStorm (native as of 2.1) – recommended!! ‣ Textmate via the Twig bundle ‣ Vim via the Jinja syntax plugin ‣ Netbeans via the Twig syntax plugin ‣ Eclipse via the Twig plugin ‣ Sublime Text via the Twig bundle ‣ Coda 2 via the other Twig syntax mode Remo Brunschwiler 10. July 2012 # 21
  • 24. Hands on! Terrific Composer – Step by Step
  • 25. Step by Step Common Tasks ‣ Create a new page ‣ Create a new Module / Skin ‣ Create a new layout ‣ Development -> Productive Remo Brunschwiler 10. July 2012 # 23
  • 27. … Let’s see it in action Remo Brunschwiler 10. July 2012 # 25
  • 28. Create a new page Things to do 1. Create a new or extend an existing controller 2. Create an action in the controller 3. Set annotations (@Template, @Route, @Composer) 4. Create a view (twig file) in /Resources/views/ Remo Brunschwiler 10. July 2012 # 26
  • 29. 1. Create / Extend Controller <?php namespace TerrificCompositionController; use SymfonyBundleFrameworkBundleControllerController; use TerrificComposerBundleAnnotationComposer; use SensioBundleFrameworkExtraBundleConfigurationRoute; use SensioBundleFrameworkExtraBundleConfigurationTemplate; class DefaultController extends Controller { } Things to consider ‣ PHP 5.3 namespace describes where the class is located ‣ Filename = ClassName, eg. DefaultController.php -> needed for classloading ‣ PHP 5.3 use statements for base controller and annotations Remo Brunschwiler 10. July 2012 # 27
  • 30. 2. Create Action class DefaultController extends Controller { /** * @Composer("Welcome") * @Route("/", name="home") * @Template() */ public function indexAction() { return array(); } } Things to consider ‣ action name must end in Action ‣ return statement of an action is a Response object -> in our case it is and array: because of @Template() Remo Brunschwiler 10. July 2012 # 28
  • 31. 3. Set Annotations /** * @Composer("Welcome") * @Route("/", name="home") * @Template() */ public function indexAction() { return array(); } @Composer(<name>) ‣ The given name will appear in the open dialog @Route(“<path>”, name=”<name”) ‣ Describes the path under which the page is available ‣ For more options have a look at @Route @Template() ‣ Specifies which template should be rendered (@Template documentation) Remo Brunschwiler 10. July 2012 # 29
  • 32. 4. Create Twig View /Resources/views/<ControllerName>/<actionName>.html.twig {% extends 'TerrificComposition::base.html.twig' %} {% block title %}Terrific Composer - Welcome{% endblock %} {% block body %} <div class="page"> … here comes your stuff … </div> {% endblock %} Things to consider ‣ Extend the layout of your choice ‣ Override / Extend the twig blocks you need Remo Brunschwiler 10. July 2012 # 30
  • 33. Twig Blocks Provided from TerrificCoreBundle::base.html.twig ‣ title – content of the <title> element ‣ meta – for meta tags (<meta charset="UTF-8"/> is always set) ‣ styles – the place for your stylesheets ‣ body_class – allows you to give your body a class ‣ composition – your content goes here ‣ jquery – jquery script element ‣ terrificjs – terrificjs script element ‣ scripts – the place for your javascripts ‣ bootstrap – the default terrificjs bootstrap Remo Brunschwiler 10. July 2012 # 31
  • 34. Hands on! Create a new page that… ‣ is available under /workshop ‣ appears in the open dialog as “Workshop” ‣ has the same content as the homepage Remo Brunschwiler 10. July 2012 # 32
  • 35. Hands on! Create a new page that… ‣ is available under /workshop ‣ appears in the open dialog as “Workshop” ‣ has the same content as the homepage Enhance the page, so that… ‣ you can type an URL like /workshop/{title} ‣ the {title} is displayed as heading before the Intro module ‣ and if no title is given, “Terrific Composer” should be displayed instead Remo Brunschwiler 10. July 2012 # 32
  • 36. Twig Module Macro {# Renders terrific modules. @param name {String} name of the module @param view {String} name of the view to render (without html.twig suffix) [optional] @param skins {Array} contains the skins to apply [optional] @param connectors {Array} contains the channel ids to connect to [optional] @param attrs {Object} contains the additional html attributes for the module [optional] @param data {Object} contains the data to pass to embedded controllers [optional] #} {% macro module(name, view, skins, connectors, attrs, data) %} To consider ‣ Twig 1.x does not support things like: {{ tc.module('Intro', attrs={'data-name' : 'einstein'}) }} -> this is going to change with Twig 2.0 Remo Brunschwiler 10. July 2012 # 33
  • 37. Render Modules #1 Simple views without logic {# this render the template with the same name (intro.html.twig) #} {{ tc.module('Intro') }} {# this renders the mrterrific template from the Hero Module #} {{ tc.module('Hero', 'mrterrific')}} {# the 3rd param is the Skins array, ie. Mr. Terrific is getting decorated with the Stealth Skin #} {{ tc.module('Hero', 'mrterrific', [ 'Stealth' ])}} {# the 4th param is an array with communication channel ids, ie. all modules with the same id can talk with each other #} {{ tc.module('Hero', 'mrterrific', ['Stealth'], ['talk'])}} {# the 5th param is the attrs object #} {{ tc.module('Hero', 'mrterrific', null, null, { ‘data-name’ : ‘Mr. Terrific‘})}} Remo Brunschwiler 10. July 2012 # 34
  • 38. Render Modules #2 Complex views ‣ the concept is – thanks to TWIG – very simple http://symfony.com/doc/current/book/ templating.html#embedding-controllers ‣ have their own controllers, actions & templates ‣ gives you Multi-MVC out-of-the-box ‣ are used rarely in plain “templating” projects {{ tc.module('Filter','Filter:overspeed', null, null, null, {'segment':'washing'})}} embeds the view of the FilterController/ the data passed to the overspeedAction in the Filter module overspeedAction Remo Brunschwiler 10. July 2012 # 35
  • 39. Hands on! Enhance your workshop page, so that… ‣ only two of the heroes can talk with each other ‣ the {title} is rendered inside the speech bubble of Einstein Remo Brunschwiler 10. July 2012 # 36
  • 40. Modules & Skins Get more flexibility…
  • 41. What we want to achieve Create a new «Victim» module, that… ‣ consists of a normal image (drowning man) & a background image (bubble) ‣ uses less for better code ‣ is able to call our heroes for help Remo Brunschwiler 10. July 2012 # 38
  • 42. Markup <div class="bubble"> <span class="message">help!</span> </div> <img src=" {{ asset("bundles/terrificmodulevictim/img/drowning-victim.png") }} "/> <a class="base" href="#help">Call for help!</a> links to image asset in /web/bundles/… But how is the drowning-victim.png got there? ‣ The composer copies all module images on the fly to /web/bundles/<bundle>/img/ (configurable in config_dev.yml) How did you come up with that path? ‣ Symfony standard: app/console assets:install Remo Brunschwiler 10. July 2012 # 39
  • 43. Import directive (mixins, variables etc.) /* import.less */ @import "colors.less"; @import "mixins.less"; /* colors.less */ @text: #74AE00; variable /* mixins.less*/ .scale(@ratio) { mixin function -webkit-transform: scale(@ratio); -moz-transform: scale(@ratio); -ms-transform: scale(@ratio); -o-transform: scale(@ratio); transform: scale(@ratio); } Remo Brunschwiler 10. July 2012 # 40
  • 44. /* @group Module: victim */ @import "../../../../../Composition/Resources/public/css/import.less"; @media screen { cascaded import – import.less has other imports .mod-victim { position: relative; .bubble { nested rules -> .mod-victim .bubble { … } background: transparent url('../bubble.png') no-repeat 0 0; ... } access variable relative to less file .message { color: @text; font-size: 36 / 16em; ... } calculation ... } } Remo Brunschwiler 10. July 2012 # 41
  • 45. There is even more to less! Have a look at the documentation ‣ http://lesscss.org Remo Brunschwiler 10. July 2012 # 42
  • 46. TerrificJS on:function (callback) { var self = this, $ctx = this.$ctx; $('a', $ctx).on('click', function() { var message = $('.message', $ctx).text(); self.fire('message', { name: 'drowner', message: message }); return false; }); callback(); } Nothing special here, but mention the new naming of the hooks in TerrificJS v2.0 Remo Brunschwiler 10. July 2012 # 43
  • 47. Hands on! Create a skin for your Victim that lets him drown when there is no help from one of the heroes ‣ Create skin “Drown” for your Victim ‣ Write a simple drown functionality (eg. fadeOut) ‣ Trigger this functionality automatically after ~5 seconds ‣ Do not let your Victim drown when he calls for help within the given time frame Remo Brunschwiler 10. July 2012 # 44
  • 48. Layouts Let’s say thanks to TWIG & Assetic
  • 49. Layouts A layouts job is to do stuff that is common to several pages ‣ javascripts ‣ styles ‣ meta tags ‣ header, footer, sidebar etc. Thanks to TWIG & Assetic, layouts are no longer a big & inflexible thing… Remo Brunschwiler 10. July 2012 # 46
  • 50. Twig Layout Approach In Twig a layout is nothing more than an inherited template ‣ http://symfony.com/doc/current/book/templating.html#template- inheritance-and-layouts In your page: this is your layout {% extends 'TerrificComposition::base.html.twig' %} {% block title %}Terrific Composer - Welcome{% endblock %} {% block body %} <div class="page"> … here comes your stuff … </div> {% endblock %} Remo Brunschwiler 10. July 2012 # 47
  • 51. Twig Layout Approach In TerrificComposition::base.html.twig {% extends 'TerrificCoreBundle::base.html.twig' %} Terrific Core Layout {% block title %}Terrific Composer{% endblock %} … {# content that is the same on every page goes into composition #} {% block composition %} {# your page content goes into body #} {% block body %} this block is overridden in your page {% endblock %} {% endblock %} … Remo Brunschwiler 10. July 2012 # 48
  • 52. Including JavaScripts Symfony comes bundled with a very nice Assetic integration Including JavaScripts has never been easier concatenates – and minifies in production {% block scripts %} mode – all files in this directory {# here comes your scripts #} {% javascripts '@TerrificComposition/Resources/public/js/*.*' output='js/compiled/statics.js' the name of the compiled file %} <script src="{{ asset_url }}" type="text/javascript"></script> {% endjavascripts %} {# scripts from parent (terrific core) layout #} {{ parent() }} includes the content of the parent block {% endblock %} Remo Brunschwiler 10. July 2012 # 49
  • 53. Including Stylesheets … and the same for stylesheets concatenates – and minifies in production mode – all of the given files {% block styles %} {% stylesheets '@TerrificComposition/Resources/public/css/reset.less' '@TerrificComposition/Resources/public/css/grid.less' '@TerrificComposition/Resources/public/css/elements.less' output="css/compiled/project.css" the name of the compiled file %} <link rel="stylesheet" href="{{ asset_url }}" /> {% endstylesheets %} {# styles from parent (terrific core) layout #} {{ parent() }} includes the content of the parent block {% endblock %} Remo Brunschwiler 10. July 2012 # 50
  • 54. Dev -> Prod Prepare your assets for the real world
  • 55. Productive The productive version is… ‣ available under / (instead of /app_dev.php) Dumping assets ‣ php app/console assets:install web Compile CSS / JS ‣ php app/console assetic:dump --env=prod Remo Brunschwiler 10. July 2012 # 52
  • 58. More… Lets keep talking ‣ http://terrifically.org ‣ remo@terrifically.org ‣ https://github.com/brunschgi ‣ http://twitter.com/#!/brunschgi Remo Brunschwiler 10. July 2012 # 55
  • 59. Remo Brunschwiler 10. July 2012 # 56