The document provides an overview of Twig, a templating language for PHP. It discusses some key benefits of Twig over plain PHP templates, including terse syntax, automatic HTML escaping, and ability to create custom templating extensions. The document also covers various Twig features like conditionals, loops, macros, template inheritance with blocks, and extending Twig with filters, functions, globals, tests, operators, token parsers and node visitors.
> De l'échantillonnage à « N = Tout »
> Conséquences sur les données
> Créer une application dans Java
> Principales fonctionnalités de MongoDB
> Établir des liens
Principe 1 – Les tests montrent la présence de défauts
Principe 2 – Les tests exhaustifs sont impossibles
Principe 3 – Tester tôt
Principe 4 – Regroupement des défauts
Principe 5 – Paradoxe du pesticide
Principe 6 – Les tests dépendent du contexte
Principe 7 – L’illusion de l’absence d’erreurs
Quelle est la différence entre la vérification et la validation ?
> De l'échantillonnage à « N = Tout »
> Conséquences sur les données
> Créer une application dans Java
> Principales fonctionnalités de MongoDB
> Établir des liens
Principe 1 – Les tests montrent la présence de défauts
Principe 2 – Les tests exhaustifs sont impossibles
Principe 3 – Tester tôt
Principe 4 – Regroupement des défauts
Principe 5 – Paradoxe du pesticide
Principe 6 – Les tests dépendent du contexte
Principe 7 – L’illusion de l’absence d’erreurs
Quelle est la différence entre la vérification et la validation ?
Les jointures sont un moyen en Transact-SQL pour récupérer des informations provenant de plusieurs objets distincts, qu’il s’agisse de tables, tables temporaires ou vues en utilisant si, possible, leurs clefs primaires et étrangères.
SQL Server comprend deux types de syntaxe pour respecter une compatibilité ascendante :
- Le standard ANSI SQL 89 utilisé sur les SGBD SQL Server 6.5 et 7
- Le standard ANSI SQL 92 exploité réellement à partir de la version 2000 de SQL Server
Il existe différents types de jointures, chacune répondant à des besoins précis :
- Les jointures internes,
- Les jointures externes,
- Les jointures multiples,
- L’auto-jointure.
Fiche de TP 3 sur les bases de données avec les SGBD(Système de Gestion des B...ATPENSC-Group
Fiche de Travaux Pratiques sur les bases de données que l'apprenant devra réaliser avec un SGBD(Système de Gestion des Bases de Données) de son choix. Cette fiche a été réalisée dans cadre des cours d'IAE (informatique appliquée à l'économie) et de CGAO (comptabilité et gestion assistée par ordinateur) pour les élèves des classes de 1ère et Tle SES (Science économie et sociale).
this slide contains about basic introduction of java.it will be helpful for a java beginner. it also useful for java lecture course in your versity.programming with java is very essential for every student.this silde may help you to progress your skill & lernt abc about java.
Qu'est ce que Java et JEE ?
Comment se fait l'évolution de Java ?
Les architectures SOA.
Les technologies (JSR).
Les frameworks.
Le middleware.
Les outils.
Wordpress Plugin Development Practicesserversideup
These slides are from a presentation given by Dan Pastori of 521 Dimensions that were presented at Milwaukee Wordcamp in June of 2012. These slides represent the best practices when it comes to developing a Wordpress Plugin.
Les jointures sont un moyen en Transact-SQL pour récupérer des informations provenant de plusieurs objets distincts, qu’il s’agisse de tables, tables temporaires ou vues en utilisant si, possible, leurs clefs primaires et étrangères.
SQL Server comprend deux types de syntaxe pour respecter une compatibilité ascendante :
- Le standard ANSI SQL 89 utilisé sur les SGBD SQL Server 6.5 et 7
- Le standard ANSI SQL 92 exploité réellement à partir de la version 2000 de SQL Server
Il existe différents types de jointures, chacune répondant à des besoins précis :
- Les jointures internes,
- Les jointures externes,
- Les jointures multiples,
- L’auto-jointure.
Fiche de TP 3 sur les bases de données avec les SGBD(Système de Gestion des B...ATPENSC-Group
Fiche de Travaux Pratiques sur les bases de données que l'apprenant devra réaliser avec un SGBD(Système de Gestion des Bases de Données) de son choix. Cette fiche a été réalisée dans cadre des cours d'IAE (informatique appliquée à l'économie) et de CGAO (comptabilité et gestion assistée par ordinateur) pour les élèves des classes de 1ère et Tle SES (Science économie et sociale).
this slide contains about basic introduction of java.it will be helpful for a java beginner. it also useful for java lecture course in your versity.programming with java is very essential for every student.this silde may help you to progress your skill & lernt abc about java.
Qu'est ce que Java et JEE ?
Comment se fait l'évolution de Java ?
Les architectures SOA.
Les technologies (JSR).
Les frameworks.
Le middleware.
Les outils.
Wordpress Plugin Development Practicesserversideup
These slides are from a presentation given by Dan Pastori of 521 Dimensions that were presented at Milwaukee Wordcamp in June of 2012. These slides represent the best practices when it comes to developing a Wordpress Plugin.
Symfony2 and MongoDB - MidwestPHP 2013 Pablo Godel
In this talk we will see how to use MongoDB in Symfony2 projects to speed up the development of web applications. We will give an introduction of MongoDB as a NoSQL database server and look at the options on how to work with it from Symfony2 and PHP applications.
Part 3 of a bespoke in-company training. Complete set of slides under:
Part 1: https://www.slideshare.net/VasilyKartashov/effective-php-part-1
Part 2: https://www.slideshare.net/VasilyKartashov/effective-php-part-2
Part 3: https://www.slideshare.net/VasilyKartashov/effective-php-part-3
Part 4: https://www.slideshare.net/VasilyKartashov/effective-php-part-4
Part 5: https://www.slideshare.net/VasilyKartashov/effective-php-part-5
Part 6: https://www.slideshare.net/VasilyKartashov/effective-php-part-6
More about the author: http://notes.kartashov.com/about/
Building maintainable javascript applicationsequisodie
In this presentation I share some tips about how to improve the quality and readability of JavaScript code, more specifically:
- Object Oriented JavaScript (comparing JS with Java)
- Bad practices
- Good practices
- Guidelines
- Recommended books
Dependency injection is a powerful technique allowing different parts of a system to collaborate with each other. Injection is the passing of a dependency (such as a service or database connection) to an object that would use it. This way, the object need not change because the outside service changed. This often also allows the object to be more easily tested by injecting a mock or stub service as the dependency.
If you have a problem, if no one else can help... and if you can find them, m...bitcoder
Ever had a problem?
No one could help you?
Please call the BASH Team!
This presentation starts with some preliminary thoughts about software integration.
Shell scripting means knowing your system and the applications you have available that can do the dirty stuff for you.
BASH is all about gluing... so what are the ways we can use to control resources and integrate software through scripting?
Some set of "advanced" features of BASH are explained and I'm sure you'll find them very handy to enhance your scripts. The BASH recipes can be used for common daily tasks of end users or administrators.
"Hacking" web sites can also be done using BASH and some command line tools. We'll talk a bit about it.
Learn also with real examples explained, namely:
- fetch music streams from web URL's to disk, from a popular Portuguese radio station
- emulate a user/replicate online banking tasks and extract values automatically, with a real bank example (by means of "reverse engineering" web pages)
- send SMS from command line, using a mobile operator's site (by means of "reverse engineering" web pages)
This is not intended to be a BASH tutorial for beginners, neither a simple plain tutorial. It's more a kind of BASH "hacking" guide.
Lithium: The Framework for People Who Hate FrameworksNate Abele
This is the presentation was given at ConFoo on March 11th by Nate Abele and Joël Perras, and is an introduction to the architectural problems with other frameworks that Lithium was designed to address, and how it addresses them. It also introduces programming paradigms like functional and aspect-oriented programming which address issues that OOP doesn't account for.
Finally, the talk provides a quick overview of the innovative and unparalleled features that Lithium provides, including the data layer, which supports both relational and non-relational databases.
Drupal 8 configuration system for coders and site builders - DrupalCamp Balti...swentel
Session given at DrupalCamp Baltics 2013. Overview of the configuration management system in Drupal 8. Covers the api, config entities, context system.
Make Apache bend to your will! We'll look at two ways to have fun with apache and mod_perl.
First, we'll see how to write a simple Apache2 module that acts as an output filter (munging text in certain pages) according to parameters from your Apache configuration.
Next, we'll look at a more drastic modification - changing Apache::Registry itself to add some new behaviors, such as sending an email when a perl script dies.
This topic is based on modules developed at the Sol Genomics Network, http://sgn.cornell.edu. Attendees will be encouraged to adapt these techniques for their own nefarious purposes.
2. ABOUT ME
Team lead at FreshBooks
Lead Developer of CakePHP
Contributor to Twig
Saturday, 3 November, 12
3. WHAT IS IT
Templating language for PHP.
Uses syntax and ideas from jinja2.
Flexible and extensible at every layer.
Saturday, 3 November, 12
4. BUT PHP IS A
TEMPLATING
LANGUAGE DUMMY
Saturday, 3 November, 12
5. PHP SUCKS FOR TEMPLATING
// In Plain PHP
<?php echo $var; ?> (XSS you lose)
<?php echo htmlspecialchars($var, ENT_QUOTES, ‘UTF-8’); ?>
<?php echo h($var); ?> (sugar for htmlentities)
// In Twig - autoescaping enabled
{{ var }}
Saturday, 3 November, 12
6. BENEFITS OF TWIG
Terse syntax, and sugar.
Automatic HTML escaping.
Sandbox mode, which enables user editable templates.
Ability to create custom DSL’s using application tags, operators
and functions.
Saturday, 3 November, 12
15. IMPORTING MACROS
// import all the macros
{% import ‘/import/formatting.twig’ as formatting %}
{{ formatting.username(user) }}
// import one macro
{% from ‘/import/formatting.twig’ import username %}
{{ username(user) }}
// import one & alias it.
{% from ‘/import/formatting.twig’ import username as un %}
{{ un(user) }}
Saturday, 3 November, 12
16. INHERITANCE & BLOCKS
Extending views & blocks work hand in hand.
Blocks are like slots or holes in a template, that the child can fill.
Blocks can be used out of order, which is pretty sweet.
Blocks can be imported from other templates, similar to traits.
Saturday, 3 November, 12
17. INHERITANCE
{# layout/base.twig #}
Company X - Official Email template
{% block content ‘Super important’ %}
Copyright 2012
Saturday, 3 November, 12
18. INHERITANCE
{# email/winner.twig #}
{% extend ‘/layout/base.twig’ %}
{% block content %}
To whom it may concern,
You win!
{% endblock %}
Saturday, 3 November, 12
19. INHERITANCE
{# email/winner.twig #}
{% extend ‘/layout/base.twig’ %}
{% block content %}
To whom it may concern,
{{ parent() }} You win!
{% endblock %}
Saturday, 3 November, 12
20. INHERITANCE TIPS
Don’t use {% block %} inside a loop. It doesn’t do what you
want.
You can use {{ block(name) }} to dynamically call blocks.
Saturday, 3 November, 12
22. EXTENDING TWIG
Twig can be extended in several ways.
Filters, Functions, Globals, Tests, Operators, TokenParsers,
NodeVisitors.
You should use extensions to package up your enhancements.
Saturday, 3 November, 12
24. LOADING EXTENSIONS
$loader = new Twig_Loader_FileSystem(APP . ‘/templates’);
$twig = new Twig_Environment($loader, $options);
$twig->addExtension(new App_Extension_Url());
Saturday, 3 November, 12
25. ENVIRONMENT FACTORY
class AppTwig {
static function loadTemplate($template, $options = array()) {
$loader = new Twig_Loader_FileSystem(APP . ‘/templates’);
$twig = new Twig_Environment($loader, $options);
$twig->addExtension(new App_Extension_Url());
// Load more extensions
return $twig->loadTemplate($template);
}
}
$template = AppTwig::loadTemplate(‘/users/profile.twig’);
Saturday, 3 November, 12
26. EXTENSION EXAMPLE
<?php
class App_Extension_Url extends Twig_Extension {
public function getName() {
return ‘app.url’;
}
public function getFilters() {
return array(
‘name’ => new Twig_Filter_Method($this, ‘formatName’),
);
}
}
Saturday, 3 November, 12
27. GLOBALS
Can be used to expose application or framework objects.
Great for migrating an older codebase to use Twig.
E.g {{ html.link(...) }}
Saturday, 3 November, 12
28. FUNCTIONS
Global functions added to a template context.
Great for providing shortcuts to application features, like url
generation or built-in PHP functions.
Example {{ form_input(model, ‘name’) }}
Saturday, 3 November, 12
29. FILTERS
Filters are intended for simple formatting functions.
The filtered variable is the first argument to the filter function.
Filters can have additional arguments as well.
Example: {{ invoice.amount|currency(‘CAD’) }}
Saturday, 3 November, 12
30. TESTS
Allow you to implement custom conditional logic. In an
expressive manner with domain objects.
Value being compared is supplied as the first argument. Other
arguments follow.
{% if user is paying %}
{% if number is divisibleby(3) %}
Saturday, 3 November, 12
31. NODE VISITORS
Allows you to visit each node in the Abstract syntax tree.
Applied before template is compiled.
Commonly used for optimizing the AST, or applying
transformations to, or reading data from nodes in the tree.
Saturday, 3 November, 12
40. TOKEN PARSERS
Used to implement custom tags or DSL features.
The most complex feature to add.
Each tag is composed of two parts:
TokenParser - parses the tag and validates its syntax.
Node - Added to the AST and compiles the PHP code used
in templates.
Saturday, 3 November, 12
41. TAG EXAMPLE
{% debug %}
{% debug my_var %}
{% debug 2 > 1 %}
Saturday, 3 November, 12
42. TOKEN PARSER
class App_TokenParser_Debug extends Twig_TokenParser {
public function parse(Twig_Token $token) {
$line = $token->getLine();
$expr = null;
if (!$this->parser->getStream()->test(Twig_Token::BLOCK_END_TYPE)) {
$expr = $this->parser->getExpressionParser->parseExpression();
}
$this->parse->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
return new App_Node_Debug($expr, $line, $this->getTag());
}
}
Saturday, 3 November, 12
43. NODE COMPILER
class App_Node_Debug extends Twig_Node {
public function __construct(Twig_Node_Expression $ex, $line, $tag) {
parent::__construct(array(‘expr’ => $ex), $line, $tag);
}
public function compile(Twig_Compiler $compiler) {
$compiler->write(‘if ($this->env->isDebug()) {‘);
if ($this->getNode(‘expr’) === null) {
// Print all vars.
} else {
$compiler->write(‘var_dump(‘)
->subcompile($this->getNode(‘expr’))
->raw(‘);’);
}
$compiler->write(‘}’);
}
}
Saturday, 3 November, 12
44. OPERATORS
Allow you to add additional boolean operators.
I’ve never used this feature.
Saturday, 3 November, 12
46. TWIG IN PRODUCTION
FreshBooks (the app, not the website).
520+ templates.
Twig templates are used for almost all HTML & E-mail content.
Saturday, 3 November, 12
57. TWIG C EXTENSION
You can also install ext/twig.
This pushes the most frequently used method
Twig_Template::getAttribute() into C which increases
performance considerably.
The C extension is in the Twig repository.
Saturday, 3 November, 12