├── 01-hello-world ├── misc │ └── 01.png └── README.md ├── 02-simple-page ├── misc │ ├── 01.png │ └── 02.png ├── app │ ├── Dockerfile │ ├── index.js │ └── package.json └── README.md ├── 03-composed-application ├── misc │ └── 01.png ├── app │ ├── web │ │ ├── favicon.ico │ │ ├── apple-touch-icon.png │ │ ├── robots.txt │ │ ├── fonts │ │ │ ├── lato │ │ │ │ ├── Lato-Bold.woff │ │ │ │ ├── Lato-Italic.woff │ │ │ │ ├── Lato-Regular.woff │ │ │ │ └── Lato-BoldItalic.woff │ │ │ └── font-awesome │ │ │ │ ├── FontAwesome.otf │ │ │ │ ├── fontawesome-webfont.eot │ │ │ │ ├── fontawesome-webfont.ttf │ │ │ │ ├── fontawesome-webfont.woff │ │ │ │ └── fontawesome-webfont.woff2 │ │ ├── app_dev.php │ │ ├── app.php │ │ └── .htaccess │ ├── app │ │ ├── AppCache.php │ │ ├── .htaccess │ │ ├── Resources │ │ │ ├── assets │ │ │ │ ├── scss │ │ │ │ │ ├── font-awesome │ │ │ │ │ │ ├── _fixed-width.scss │ │ │ │ │ │ ├── _bordered-pulled.scss │ │ │ │ │ │ ├── _larger.scss │ │ │ │ │ │ ├── _list.scss │ │ │ │ │ │ ├── _core.scss │ │ │ │ │ │ ├── _stacked.scss │ │ │ │ │ │ ├── _rotated-flipped.scss │ │ │ │ │ │ ├── _path.scss │ │ │ │ │ │ ├── _animated.scss │ │ │ │ │ │ └── _mixins.scss │ │ │ │ │ ├── bootstrap │ │ │ │ │ │ ├── mixins │ │ │ │ │ │ │ ├── _center-block.scss │ │ │ │ │ │ │ ├── _opacity.scss │ │ │ │ │ │ │ ├── _size.scss │ │ │ │ │ │ │ ├── _text-overflow.scss │ │ │ │ │ │ │ ├── _tab-focus.scss │ │ │ │ │ │ │ ├── _labels.scss │ │ │ │ │ │ │ ├── _resize.scss │ │ │ │ │ │ │ ├── _text-emphasis.scss │ │ │ │ │ │ │ ├── _progress-bar.scss │ │ │ │ │ │ │ ├── _background-variant.scss │ │ │ │ │ │ │ ├── _reset-filter.scss │ │ │ │ │ │ │ ├── _nav-divider.scss │ │ │ │ │ │ │ ├── _alerts.scss │ │ │ │ │ │ │ ├── _nav-vertical-align.scss │ │ │ │ │ │ │ ├── _pagination.scss │ │ │ │ │ │ │ ├── _border-radius.scss │ │ │ │ │ │ │ ├── _responsive-visibility.scss │ │ │ │ │ │ │ ├── _panels.scss │ │ │ │ │ │ │ ├── _hide-text.scss │ │ │ │ │ │ │ ├── _clearfix.scss │ │ │ │ │ │ │ ├── _list-group.scss │ │ │ │ │ │ │ ├── _table-row.scss │ │ │ │ │ │ │ ├── _buttons.scss │ │ │ │ │ │ │ ├── _image.scss │ │ │ │ │ │ │ ├── _grid-framework.scss │ │ │ │ │ │ │ └── _forms.scss │ │ │ │ │ │ ├── _wells.scss │ │ │ │ │ │ ├── _breadcrumbs.scss │ │ │ │ │ │ ├── _responsive-embed.scss │ │ │ │ │ │ ├── _close.scss │ │ │ │ │ │ ├── _component-animations.scss │ │ │ │ │ │ ├── _utilities.scss │ │ │ │ │ │ ├── _media.scss │ │ │ │ │ │ ├── _thumbnails.scss │ │ │ │ │ │ ├── _pager.scss │ │ │ │ │ │ ├── _mixins.scss │ │ │ │ │ │ ├── _jumbotron.scss │ │ │ │ │ │ ├── _labels.scss │ │ │ │ │ │ ├── _badges.scss │ │ │ │ │ │ ├── _code.scss │ │ │ │ │ │ ├── _grid.scss │ │ │ │ │ │ ├── _alerts.scss │ │ │ │ │ │ ├── _progress-bars.scss │ │ │ │ │ │ ├── _pagination.scss │ │ │ │ │ │ ├── _print.scss │ │ │ │ │ │ └── _tooltip.scss │ │ │ │ │ ├── bootstrap-flatly.scss │ │ │ │ │ ├── font-awesome.scss │ │ │ │ │ └── _bootstrap.scss │ │ │ │ ├── css │ │ │ │ │ ├── font-lato.css │ │ │ │ │ └── highlight-solarized-light.css │ │ │ │ └── js │ │ │ │ │ └── main.js │ │ │ ├── views │ │ │ │ ├── blog │ │ │ │ │ ├── comment_form_error.html.twig │ │ │ │ │ ├── about.html.twig │ │ │ │ │ ├── index.html.twig │ │ │ │ │ ├── _delete_post_confirmation.html.twig │ │ │ │ │ ├── _comment_form.html.twig │ │ │ │ │ └── post_show.html.twig │ │ │ │ ├── form │ │ │ │ │ └── fields.html.twig │ │ │ │ ├── admin │ │ │ │ │ ├── blog │ │ │ │ │ │ ├── edit.html.twig │ │ │ │ │ │ ├── new.html.twig │ │ │ │ │ │ ├── _form.html.twig │ │ │ │ │ │ ├── show.html.twig │ │ │ │ │ │ └── index.html.twig │ │ │ │ │ └── layout.html.twig │ │ │ │ └── default │ │ │ │ │ ├── _flash_messages.html.twig │ │ │ │ │ └── homepage.html.twig │ │ │ ├── TwigBundle │ │ │ │ └── views │ │ │ │ │ └── Exception │ │ │ │ │ ├── error404.html.twig │ │ │ │ │ ├── error500.html.twig │ │ │ │ │ ├── error403.html.twig │ │ │ │ │ └── error.html.twig │ │ │ └── translations │ │ │ │ ├── validators.ja.xliff │ │ │ │ ├── validators.de.xliff │ │ │ │ ├── validators.sl.xliff │ │ │ │ ├── validators.en.xliff │ │ │ │ ├── validators.id.xliff │ │ │ │ ├── validators.nl.xliff │ │ │ │ ├── validators.pl.xliff │ │ │ │ ├── validators.it.xliff │ │ │ │ ├── validators.uk.xliff │ │ │ │ ├── validators.ro.xliff │ │ │ │ ├── validators.pt_BR.xliff │ │ │ │ ├── validators.fr.xliff │ │ │ │ ├── validators.ru.xliff │ │ │ │ ├── validators.ca.xliff │ │ │ │ ├── validators.es.xliff │ │ │ │ └── validators.cs.xliff │ │ ├── autoload.php │ │ ├── config │ │ │ ├── config_test.yml │ │ │ ├── config_prod.yml │ │ │ ├── parameters.yml.dist │ │ │ ├── config_dev.yml │ │ │ ├── routing_dev.yml │ │ │ ├── routing.yml │ │ │ ├── services.yml │ │ │ └── security.yml │ │ └── AppKernel.php │ ├── src │ │ ├── .htaccess │ │ ├── CodeExplorerBundle │ │ │ ├── CodeExplorerBundle.php │ │ │ ├── Resources │ │ │ │ ├── config │ │ │ │ │ └── services.yml │ │ │ │ └── views │ │ │ │ │ └── source_code.html.twig │ │ │ ├── DependencyInjection │ │ │ │ └── CodeExplorerExtension.php │ │ │ └── EventListener │ │ │ │ └── ControllerListener.php │ │ └── AppBundle │ │ │ ├── Utils │ │ │ ├── Slugger.php │ │ │ ├── Markdown.php │ │ │ └── MomentFormatConverter.php │ │ │ ├── Repository │ │ │ ├── UserRepository.php │ │ │ └── PostRepository.php │ │ │ ├── AppBundle.php │ │ │ ├── Controller │ │ │ └── SecurityController.php │ │ │ ├── Form │ │ │ ├── CommentType.php │ │ │ ├── Type │ │ │ │ └── DateTimePickerType.php │ │ │ └── PostType.php │ │ │ ├── Twig │ │ │ └── AppExtension.php │ │ │ └── Entity │ │ │ ├── Comment.php │ │ │ └── User.php │ ├── .editorconfig │ ├── .gitignore │ ├── .travis.yml │ ├── app.json │ ├── appveyor.yml │ ├── CONTRIBUTING.md │ ├── bin │ │ └── console │ ├── phpunit.xml.dist │ ├── LICENSE │ ├── tests │ │ └── AppBundle │ │ │ ├── Controller │ │ │ ├── BlogControllerTest.php │ │ │ ├── Admin │ │ │ │ └── BlogControllerTest.php │ │ │ └── DefaultControllerTest.php │ │ │ └── Utils │ │ │ └── SluggerTest.php │ └── README.md ├── dckr │ ├── php5 │ │ └── Dockerfile │ └── php7 │ │ └── Dockerfile ├── docker-compose.yml └── README.md ├── .gitignore ├── 05-tips ├── php-in-docker.sh └── README.md ├── LICENSE.md ├── README.md └── 04-gui └── README.md /01-hello-world/misc/01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nowdoc/2016-docker-workshop/HEAD/01-hello-world/misc/01.png -------------------------------------------------------------------------------- /02-simple-page/misc/01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nowdoc/2016-docker-workshop/HEAD/02-simple-page/misc/01.png -------------------------------------------------------------------------------- /02-simple-page/misc/02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nowdoc/2016-docker-workshop/HEAD/02-simple-page/misc/02.png -------------------------------------------------------------------------------- /03-composed-application/misc/01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nowdoc/2016-docker-workshop/HEAD/03-composed-application/misc/01.png -------------------------------------------------------------------------------- /03-composed-application/app/web/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nowdoc/2016-docker-workshop/HEAD/03-composed-application/app/web/favicon.ico -------------------------------------------------------------------------------- /02-simple-page/app/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:6-slim 2 | #FROM iron/node:latest 3 | 4 | MAINTAINER Milan Felix Sulc 5 | 6 | CMD node /srv 7 | -------------------------------------------------------------------------------- /03-composed-application/app/web/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nowdoc/2016-docker-workshop/HEAD/03-composed-application/app/web/apple-touch-icon.png -------------------------------------------------------------------------------- /03-composed-application/app/web/robots.txt: -------------------------------------------------------------------------------- 1 | # www.robotstxt.org/ 2 | # www.google.com/support/webmasters/bin/answer.py?hl=en&answer=156449 3 | 4 | User-agent: * 5 | -------------------------------------------------------------------------------- /03-composed-application/app/app/AppCache.php: -------------------------------------------------------------------------------- 1 | 2 | Require all denied 3 | 4 | 5 | Order deny,allow 6 | Deny from all 7 | 8 | -------------------------------------------------------------------------------- /03-composed-application/app/src/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | Require all denied 3 | 4 | 5 | Order deny,allow 6 | Deny from all 7 | 8 | -------------------------------------------------------------------------------- /03-composed-application/app/web/fonts/font-awesome/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nowdoc/2016-docker-workshop/HEAD/03-composed-application/app/web/fonts/font-awesome/fontawesome-webfont.eot -------------------------------------------------------------------------------- /03-composed-application/app/web/fonts/font-awesome/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nowdoc/2016-docker-workshop/HEAD/03-composed-application/app/web/fonts/font-awesome/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /03-composed-application/app/web/fonts/font-awesome/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nowdoc/2016-docker-workshop/HEAD/03-composed-application/app/web/fonts/font-awesome/fontawesome-webfont.woff -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # IDE 2 | /.idea 3 | 4 | # 03 5 | /03-composed-application/data/db 6 | /03-composed-application/app/var/cache/ 7 | /03-composed-application/app/var/logs/ 8 | /03-composed-application/app/var/sessions/ 9 | -------------------------------------------------------------------------------- /03-composed-application/app/web/fonts/font-awesome/fontawesome-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nowdoc/2016-docker-workshop/HEAD/03-composed-application/app/web/fonts/font-awesome/fontawesome-webfont.woff2 -------------------------------------------------------------------------------- /03-composed-application/app/.editorconfig: -------------------------------------------------------------------------------- 1 | ; top-most EditorConfig file 2 | root = true 3 | 4 | ; Unix-style newlines 5 | [*] 6 | end_of_line = LF 7 | 8 | [*.php] 9 | indent_style = space 10 | indent_size = 4 11 | -------------------------------------------------------------------------------- /05-tips/php-in-docker.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | DIR=$(pwd) 3 | docker run -i --rm -v "${DIR}":"${DIR}" -e XDEBUG_CONFIG="remote_host=172.17.0.1" -v /tmp/:/tmp/ --net=host --sig-proxy=true --pid=host php "$@" 4 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/font-awesome/_fixed-width.scss: -------------------------------------------------------------------------------- 1 | // Fixed Width Icons 2 | // ------------------------- 3 | .#{$fa-css-prefix}-fw { 4 | width: (18em / 14); 5 | text-align: center; 6 | } 7 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/bootstrap/mixins/_center-block.scss: -------------------------------------------------------------------------------- 1 | // Center-align a block level element 2 | 3 | @mixin center-block() { 4 | display: block; 5 | margin-left: auto; 6 | margin-right: auto; 7 | } 8 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/bootstrap-flatly.scss: -------------------------------------------------------------------------------- 1 | // Flatly variables 2 | @import "bootswatch-flatly/variables"; 3 | // Standard bootstrap 4 | @import "bootstrap"; 5 | // Flatly specific styles 6 | @import "bootswatch-flatly/bootswatch"; -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/bootstrap/mixins/_opacity.scss: -------------------------------------------------------------------------------- 1 | // Opacity 2 | 3 | @mixin opacity($opacity) { 4 | opacity: $opacity; 5 | // IE8 filter 6 | $opacity-ie: ($opacity * 100); 7 | filter: alpha(opacity=$opacity-ie); 8 | } 9 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/bootstrap/mixins/_size.scss: -------------------------------------------------------------------------------- 1 | // Sizing shortcuts 2 | 3 | @mixin size($width, $height) { 4 | width: $width; 5 | height: $height; 6 | } 7 | 8 | @mixin square($size) { 9 | @include size($size, $size); 10 | } 11 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/bootstrap/mixins/_text-overflow.scss: -------------------------------------------------------------------------------- 1 | // Text overflow 2 | // Requires inline-block or block for proper styling 3 | 4 | @mixin text-overflow() { 5 | overflow: hidden; 6 | text-overflow: ellipsis; 7 | white-space: nowrap; 8 | } 9 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/bootstrap/mixins/_tab-focus.scss: -------------------------------------------------------------------------------- 1 | // WebKit-style focus 2 | 3 | @mixin tab-focus() { 4 | // Default 5 | outline: thin dotted; 6 | // WebKit 7 | outline: 5px auto -webkit-focus-ring-color; 8 | outline-offset: -2px; 9 | } 10 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/bootstrap/mixins/_labels.scss: -------------------------------------------------------------------------------- 1 | // Labels 2 | 3 | @mixin label-variant($color) { 4 | background-color: $color; 5 | 6 | &[href] { 7 | &:hover, 8 | &:focus { 9 | background-color: darken($color, 10%); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/bootstrap/mixins/_resize.scss: -------------------------------------------------------------------------------- 1 | // Resize anything 2 | 3 | @mixin resizable($direction) { 4 | resize: $direction; // Options: horizontal, vertical, both 5 | overflow: auto; // Per CSS3 UI, `resize` only applies when `overflow` isn't `visible` 6 | } 7 | -------------------------------------------------------------------------------- /02-simple-page/app/index.js: -------------------------------------------------------------------------------- 1 | const http = require('http'); 2 | 3 | const server = http.createServer((req, res) => { 4 | res.statusCode = 200; 5 | res.setHeader('Content-Type', 'text/plain'); 6 | res.end('Hello World\n'); 7 | }); 8 | 9 | server.listen(80); 10 | console.log(`Server running. CTRL+C to terminate.`); 11 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/bootstrap/mixins/_text-emphasis.scss: -------------------------------------------------------------------------------- 1 | // Typography 2 | 3 | // [converter] $parent hack 4 | @mixin text-emphasis-variant($parent, $color) { 5 | #{$parent} { 6 | color: $color; 7 | } 8 | a#{$parent}:hover { 9 | color: darken($color, 10%); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/bootstrap/mixins/_progress-bar.scss: -------------------------------------------------------------------------------- 1 | // Progress bars 2 | 3 | @mixin progress-bar-variant($color) { 4 | background-color: $color; 5 | 6 | // Deprecated parent class requirement as of v3.2.0 7 | .progress-striped & { 8 | @include gradient-striped; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/bootstrap/mixins/_background-variant.scss: -------------------------------------------------------------------------------- 1 | // Contextual backgrounds 2 | 3 | // [converter] $parent hack 4 | @mixin bg-variant($parent, $color) { 5 | #{$parent} { 6 | background-color: $color; 7 | } 8 | a#{$parent}:hover { 9 | background-color: darken($color, 10%); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/bootstrap/mixins/_reset-filter.scss: -------------------------------------------------------------------------------- 1 | // Reset filters for IE 2 | // 3 | // When you need to remove a gradient background, do not forget to use this to reset 4 | // the IE filter for IE9 and below. 5 | 6 | @mixin reset-filter() { 7 | filter: progid:DXImageTransform.Microsoft.gradient(enabled = false); 8 | } 9 | -------------------------------------------------------------------------------- /03-composed-application/app/.gitignore: -------------------------------------------------------------------------------- 1 | /app/config/parameters.yml 2 | /build/ 3 | /phpunit.xml 4 | /var/* 5 | !/var/cache 6 | /var/cache/* 7 | !var/cache/.gitkeep 8 | !/var/logs 9 | /var/logs/* 10 | !var/logs/.gitkeep 11 | !/var/sessions 12 | /var/sessions/* 13 | !var/sessions/.gitkeep 14 | !var/SymfonyRequirements.php 15 | /vendor/ 16 | /web/bundles/ 17 | /.idea -------------------------------------------------------------------------------- /03-composed-application/app/app/autoload.php: -------------------------------------------------------------------------------- 1 | {{ 'title.comment_error'|trans }} 7 | 8 |
9 | {{ include('blog/_comment_form.html.twig') }} 10 |
11 | {% endblock %} 12 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/bootstrap/mixins/_alerts.scss: -------------------------------------------------------------------------------- 1 | // Alerts 2 | 3 | @mixin alert-variant($background, $border, $text-color) { 4 | background-color: $background; 5 | border-color: $border; 6 | color: $text-color; 7 | 8 | hr { 9 | border-top-color: darken($border, 5%); 10 | } 11 | .alert-link { 12 | color: darken($text-color, 10%); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/font-awesome/_bordered-pulled.scss: -------------------------------------------------------------------------------- 1 | // Bordered & Pulled 2 | // ------------------------- 3 | 4 | .#{$fa-css-prefix}-border { 5 | padding: .2em .25em .15em; 6 | border: solid .08em $fa-border-color; 7 | border-radius: .1em; 8 | } 9 | 10 | .pull-right { float: right; } 11 | .pull-left { float: left; } 12 | 13 | .#{$fa-css-prefix} { 14 | &.pull-left { margin-right: .3em; } 15 | &.pull-right { margin-left: .3em; } 16 | } 17 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/bootstrap/mixins/_nav-vertical-align.scss: -------------------------------------------------------------------------------- 1 | // Navbar vertical align 2 | // 3 | // Vertically center elements in the navbar. 4 | // Example: an element has a height of 30px, so write out `.navbar-vertical-align(30px);` to calculate the appropriate top margin. 5 | 6 | @mixin navbar-vertical-align($element-height) { 7 | margin-top: (($navbar-height - $element-height) / 2); 8 | margin-bottom: (($navbar-height - $element-height) / 2); 9 | } 10 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/font-awesome/_larger.scss: -------------------------------------------------------------------------------- 1 | // Icon Sizes 2 | // ------------------------- 3 | 4 | /* makes the font 33% larger relative to the icon container */ 5 | .#{$fa-css-prefix}-lg { 6 | font-size: (4em / 3); 7 | line-height: (3em / 4); 8 | vertical-align: -15%; 9 | } 10 | .#{$fa-css-prefix}-2x { font-size: 2em; } 11 | .#{$fa-css-prefix}-3x { font-size: 3em; } 12 | .#{$fa-css-prefix}-4x { font-size: 4em; } 13 | .#{$fa-css-prefix}-5x { font-size: 5em; } 14 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/font-awesome/_list.scss: -------------------------------------------------------------------------------- 1 | // List Icons 2 | // ------------------------- 3 | 4 | .#{$fa-css-prefix}-ul { 5 | padding-left: 0; 6 | margin-left: $fa-li-width; 7 | list-style-type: none; 8 | > li { position: relative; } 9 | } 10 | .#{$fa-css-prefix}-li { 11 | position: absolute; 12 | left: -$fa-li-width; 13 | width: $fa-li-width; 14 | top: (2em / 14); 15 | text-align: center; 16 | &.#{$fa-css-prefix}-lg { 17 | left: -$fa-li-width + (4em / 14); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /03-composed-application/app/.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | sudo: false 3 | 4 | cache: 5 | directories: 6 | - $HOME/.composer/cache/files 7 | 8 | matrix: 9 | fast_finish: true 10 | include: 11 | - php: 5.5 12 | - php: 5.6 13 | - php: 7.0 14 | - php: hhvm 15 | allow_failures: 16 | - php: hhvm 17 | 18 | before_install: 19 | - if [[ "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then phpenv config-rm xdebug.ini; fi 20 | - composer self-update 21 | 22 | install: 23 | - composer install 24 | 25 | script: 26 | - ./vendor/bin/phpunit 27 | -------------------------------------------------------------------------------- /03-composed-application/app/src/CodeExplorerBundle/CodeExplorerBundle.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace CodeExplorerBundle; 13 | 14 | use Symfony\Component\HttpKernel\Bundle\Bundle; 15 | 16 | /** 17 | * @author Oleg Voronkovich 18 | */ 19 | class CodeExplorerBundle extends Bundle 20 | { 21 | } 22 | -------------------------------------------------------------------------------- /03-composed-application/dckr/php5/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:5.6-fpm 2 | 3 | RUN apt-get update && \ 4 | apt-get upgrade -y && \ 5 | apt-get install -y curl git zlib1g-dev && \ 6 | docker-php-ext-install mysqli && \ 7 | docker-php-ext-install zip && \ 8 | curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && \ 9 | composer global require "hirak/prestissimo:^0.3" && \ 10 | apt-get clean -y && apt-get autoclean -y && apt-get autoremove -y && \ 11 | rm -rf /var/lib/apt/lists/* /var/lib/log/* /tmp/* /var/tmp/* 12 | 13 | WORKDIR /srv 14 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/font-awesome/_core.scss: -------------------------------------------------------------------------------- 1 | // Base Class Definition 2 | // ------------------------- 3 | 4 | .#{$fa-css-prefix} { 5 | display: inline-block; 6 | font: normal normal normal #{$fa-font-size-base}/1 FontAwesome; // shortening font declaration 7 | font-size: inherit; // can't have font-size inherit on line above, so need to override 8 | text-rendering: auto; // optimizelegibility throws things off #1094 9 | -webkit-font-smoothing: antialiased; 10 | -moz-osx-font-smoothing: grayscale; 11 | transform: translate(0, 0); // ensures no half-pixel rendering in firefox 12 | 13 | } 14 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/bootstrap/mixins/_pagination.scss: -------------------------------------------------------------------------------- 1 | // Pagination 2 | 3 | @mixin pagination-size($padding-vertical, $padding-horizontal, $font-size, $border-radius) { 4 | > li { 5 | > a, 6 | > span { 7 | padding: $padding-vertical $padding-horizontal; 8 | font-size: $font-size; 9 | } 10 | &:first-child { 11 | > a, 12 | > span { 13 | @include border-left-radius($border-radius); 14 | } 15 | } 16 | &:last-child { 17 | > a, 18 | > span { 19 | @include border-right-radius($border-radius); 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/font-awesome/_stacked.scss: -------------------------------------------------------------------------------- 1 | // Stacked Icons 2 | // ------------------------- 3 | 4 | .#{$fa-css-prefix}-stack { 5 | position: relative; 6 | display: inline-block; 7 | width: 2em; 8 | height: 2em; 9 | line-height: 2em; 10 | vertical-align: middle; 11 | } 12 | .#{$fa-css-prefix}-stack-1x, .#{$fa-css-prefix}-stack-2x { 13 | position: absolute; 14 | left: 0; 15 | width: 100%; 16 | text-align: center; 17 | } 18 | .#{$fa-css-prefix}-stack-1x { line-height: inherit; } 19 | .#{$fa-css-prefix}-stack-2x { font-size: 2em; } 20 | .#{$fa-css-prefix}-inverse { color: $fa-inverse; } 21 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/bootstrap/mixins/_border-radius.scss: -------------------------------------------------------------------------------- 1 | // Single side border-radius 2 | 3 | @mixin border-top-radius($radius) { 4 | border-top-right-radius: $radius; 5 | border-top-left-radius: $radius; 6 | } 7 | @mixin border-right-radius($radius) { 8 | border-bottom-right-radius: $radius; 9 | border-top-right-radius: $radius; 10 | } 11 | @mixin border-bottom-radius($radius) { 12 | border-bottom-right-radius: $radius; 13 | border-bottom-left-radius: $radius; 14 | } 15 | @mixin border-left-radius($radius) { 16 | border-bottom-left-radius: $radius; 17 | border-top-left-radius: $radius; 18 | } 19 | -------------------------------------------------------------------------------- /03-composed-application/app/app/config/config_test.yml: -------------------------------------------------------------------------------- 1 | imports: 2 | - { resource: config_dev.yml } 3 | 4 | framework: 5 | test: ~ 6 | session: 7 | storage_id: session.storage.mock_file 8 | profiler: 9 | collect: false 10 | 11 | web_profiler: 12 | toolbar: false 13 | intercept_redirects: false 14 | 15 | swiftmailer: 16 | disable_delivery: true 17 | 18 | # this configuration simplifies testing URLs protected by the security mechanism 19 | # See http://symfony.com/doc/current/cookbook/testing/http_authentication.html 20 | security: 21 | firewalls: 22 | secured_area: 23 | http_basic: ~ 24 | -------------------------------------------------------------------------------- /03-composed-application/app/src/CodeExplorerBundle/Resources/config/services.yml: -------------------------------------------------------------------------------- 1 | services: 2 | code_explorer.twig.source_code_extension: 3 | public: false 4 | class: CodeExplorerBundle\Twig\SourceCodeExtension 5 | arguments: ['%kernel.root_dir%'] 6 | tags: 7 | - { name: twig.extension } 8 | 9 | code_explorer.controller_listener: 10 | class: CodeExplorerBundle\EventListener\ControllerListener 11 | arguments: ['@code_explorer.twig.source_code_extension'] 12 | tags: 13 | - { name: kernel.event_listener, event: kernel.controller, method: registerCurrentController } 14 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/bootstrap/mixins/_responsive-visibility.scss: -------------------------------------------------------------------------------- 1 | // Responsive utilities 2 | 3 | // 4 | // More easily include all the states for responsive-utilities.less. 5 | // [converter] $parent hack 6 | @mixin responsive-visibility($parent) { 7 | #{$parent} { 8 | display: block !important; 9 | } 10 | table#{$parent} { display: table; } 11 | tr#{$parent} { display: table-row !important; } 12 | th#{$parent}, 13 | td#{$parent} { display: table-cell !important; } 14 | } 15 | 16 | // [converter] $parent hack 17 | @mixin responsive-invisibility($parent) { 18 | #{$parent} { 19 | display: none !important; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/views/blog/about.html.twig: -------------------------------------------------------------------------------- 1 |
2 |
3 |

4 | {{ 'help.app_description'|trans|raw }} 5 |

6 |

7 | {{ 'help.more_information'|trans|raw }} 8 |

9 |
10 |
11 | 12 | {# it's not mandatory to set the timezone in localizeddate(). This is done to 13 | avoid errors when the 'intl' PHP extension is not available and the application 14 | is forced to use the limited "intl polyfill", which only supports UTC and GMT #} 15 | 16 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/font-awesome.scss: -------------------------------------------------------------------------------- 1 | /*! 2 | * Font Awesome 4.3.0 by @davegandy - http://fontawesome.io - @fontawesome 3 | * License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License) 4 | */ 5 | 6 | @import "font-awesome/variables"; 7 | @import "font-awesome/mixins"; 8 | @import "font-awesome/path"; 9 | @import "font-awesome/core"; 10 | @import "font-awesome/larger"; 11 | @import "font-awesome/fixed-width"; 12 | @import "font-awesome/list"; 13 | @import "font-awesome/bordered-pulled"; 14 | @import "font-awesome/animated"; 15 | @import "font-awesome/rotated-flipped"; 16 | @import "font-awesome/stacked"; 17 | @import "font-awesome/icons"; 18 | -------------------------------------------------------------------------------- /02-simple-page/app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "workshop", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/trainit/2016-docker-workshop.git" 12 | }, 13 | "keywords": [ 14 | "docker", 15 | "nodejs", 16 | "javascript", 17 | "spa" 18 | ], 19 | "author": "Milan Felix Sulc", 20 | "license": "MIT", 21 | "bugs": { 22 | "url": "https://github.com/trainit/2016-docker-workshop/issues" 23 | }, 24 | "homepage": "https://github.com/trainit/2016-docker-workshop#readme" 25 | } 26 | -------------------------------------------------------------------------------- /03-composed-application/app/app/config/config_prod.yml: -------------------------------------------------------------------------------- 1 | imports: 2 | - { resource: config.yml } 3 | 4 | #framework: 5 | # cache: 6 | # system: cache.adapter.apcu 7 | 8 | #doctrine: 9 | # orm: 10 | # metadata_cache_driver: apc 11 | # result_cache_driver: apc 12 | # query_cache_driver: apc 13 | 14 | monolog: 15 | handlers: 16 | main: 17 | type: fingers_crossed 18 | action_level: error 19 | handler: nested 20 | nested: 21 | type: stream 22 | path: "%kernel.logs_dir%/%kernel.environment%.log" 23 | level: debug 24 | console: 25 | type: console 26 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/bootstrap/mixins/_panels.scss: -------------------------------------------------------------------------------- 1 | // Panels 2 | 3 | @mixin panel-variant($border, $heading-text-color, $heading-bg-color, $heading-border) { 4 | border-color: $border; 5 | 6 | & > .panel-heading { 7 | color: $heading-text-color; 8 | background-color: $heading-bg-color; 9 | border-color: $heading-border; 10 | 11 | + .panel-collapse > .panel-body { 12 | border-top-color: $border; 13 | } 14 | .badge { 15 | color: $heading-bg-color; 16 | background-color: $heading-text-color; 17 | } 18 | } 19 | & > .panel-footer { 20 | + .panel-collapse > .panel-body { 21 | border-bottom-color: $border; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /02-simple-page/README.md: -------------------------------------------------------------------------------- 1 | # 02 - Single Page Application (SPA) 2 | 3 | ## Requirements 4 | 5 | - Docker (https://docs.docker.com/engine/installation/ 6 | 7 | ## Containers 8 | 9 | - NodeJS 6.x (`node:6` / `node:6-slim` / `iron/node:latest`) 10 | 11 | ## Manual 12 | 13 | 1. Build image with `docker build -t spa app` command. 14 | 2. Type `docker run -it -v $(pwd)/app:/srv -p 8000:80 spa` to run container. 15 | 3. Open browser on `http://localhost:8000` and heureka! 16 | 17 | ![](https://raw.githubusercontent.com/trainit/2016-docker-workshop/master/02-simple-page/misc/01.png "NodeJS Application!") 18 | 19 | ![](https://raw.githubusercontent.com/trainit/2016-docker-workshop/master/02-simple-page/misc/02.png "NodeJS Application!") 20 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/bootstrap/_wells.scss: -------------------------------------------------------------------------------- 1 | // 2 | // Wells 3 | // -------------------------------------------------- 4 | 5 | 6 | // Base class 7 | .well { 8 | min-height: 20px; 9 | padding: 19px; 10 | margin-bottom: 20px; 11 | background-color: $well-bg; 12 | border: 1px solid $well-border; 13 | border-radius: $border-radius-base; 14 | @include box-shadow(inset 0 1px 1px rgba(0,0,0,.05)); 15 | blockquote { 16 | border-color: #ddd; 17 | border-color: rgba(0,0,0,.15); 18 | } 19 | } 20 | 21 | // Sizes 22 | .well-lg { 23 | padding: 24px; 24 | border-radius: $border-radius-large; 25 | } 26 | .well-sm { 27 | padding: 9px; 28 | border-radius: $border-radius-small; 29 | } 30 | -------------------------------------------------------------------------------- /03-composed-application/app/app/config/parameters.yml.dist: -------------------------------------------------------------------------------- 1 | # This file defines the canonical configuration parameters of the application. 2 | # Symfony uses this file as a template to generate the real app/config/parameters.yml 3 | # used by the application. 4 | # See http://symfony.com/doc/current/best_practices/configuration.html#canonical-parameters 5 | parameters: 6 | database_driver: mysqli 7 | database_host: db 8 | database_user: root 9 | database_password: root 10 | database_dbname: symfony_demo 11 | 12 | mailer_transport: smtp 13 | mailer_host: 127.0.0.1 14 | mailer_user: ~ 15 | mailer_password: ~ 16 | 17 | locale: en 18 | secret: 'secret_value_for_symfony_demo_application' 19 | -------------------------------------------------------------------------------- /03-composed-application/app/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Symfony Demo Application", 3 | "description": "The official demo application for the Symfony framework.", 4 | "keywords": [ 5 | "php", 6 | "symfony" 7 | ], 8 | "website": "https://symfony.com/download", 9 | "repository": "https://github.com/symfony/symfony-demo", 10 | "logo": "https://symfony.com/images/v5/pictos/demoapp.svg?v=4", 11 | "success_url": "/", 12 | "env": { 13 | "SYMFONY_ENV": "prod", 14 | "SYMFONY_SECRET": { 15 | "description": "Extra entropy for %kernel.secret%; used for CSRF tokens, cookies and signed URLs.", 16 | "generator": "secret" 17 | } 18 | }, 19 | "image": "heroku/php" 20 | } 21 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/bootstrap/mixins/_hide-text.scss: -------------------------------------------------------------------------------- 1 | // CSS image replacement 2 | // 3 | // Heads up! v3 launched with with only `.hide-text()`, but per our pattern for 4 | // mixins being reused as classes with the same name, this doesn't hold up. As 5 | // of v3.0.1 we have added `.text-hide()` and deprecated `.hide-text()`. 6 | // 7 | // Source: https://github.com/h5bp/html5-boilerplate/commit/aa0396eae757 8 | 9 | // Deprecated as of v3.0.1 (will be removed in v4) 10 | @mixin hide-text() { 11 | font: 0/0 a; 12 | color: transparent; 13 | text-shadow: none; 14 | background-color: transparent; 15 | border: 0; 16 | } 17 | 18 | // New mixin to use as of v3.0.1 19 | @mixin text-hide() { 20 | @include hide-text; 21 | } 22 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/bootstrap/_breadcrumbs.scss: -------------------------------------------------------------------------------- 1 | // 2 | // Breadcrumbs 3 | // -------------------------------------------------- 4 | 5 | 6 | .breadcrumb { 7 | padding: $breadcrumb-padding-vertical $breadcrumb-padding-horizontal; 8 | margin-bottom: $line-height-computed; 9 | list-style: none; 10 | background-color: $breadcrumb-bg; 11 | border-radius: $border-radius-base; 12 | 13 | > li { 14 | display: inline-block; 15 | 16 | + li:before { 17 | content: "#{$breadcrumb-separator}\00a0"; // Unicode space added since inline-block means non-collapsing white-space 18 | padding: 0 5px; 19 | color: $breadcrumb-color; 20 | } 21 | } 22 | 23 | > .active { 24 | color: $breadcrumb-active-color; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/bootstrap/_responsive-embed.scss: -------------------------------------------------------------------------------- 1 | // Embeds responsive 2 | // 3 | // Credit: Nicolas Gallagher and SUIT CSS. 4 | 5 | .embed-responsive { 6 | position: relative; 7 | display: block; 8 | height: 0; 9 | padding: 0; 10 | overflow: hidden; 11 | 12 | .embed-responsive-item, 13 | iframe, 14 | embed, 15 | object, 16 | video { 17 | position: absolute; 18 | top: 0; 19 | left: 0; 20 | bottom: 0; 21 | height: 100%; 22 | width: 100%; 23 | border: 0; 24 | } 25 | } 26 | 27 | // Modifier class for 16:9 aspect ratio 28 | .embed-responsive-16by9 { 29 | padding-bottom: 56.25%; 30 | } 31 | 32 | // Modifier class for 4:3 aspect ratio 33 | .embed-responsive-4by3 { 34 | padding-bottom: 75%; 35 | } 36 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/bootstrap/mixins/_clearfix.scss: -------------------------------------------------------------------------------- 1 | // Clearfix 2 | // 3 | // For modern browsers 4 | // 1. The space content is one way to avoid an Opera bug when the 5 | // contenteditable attribute is included anywhere else in the document. 6 | // Otherwise it causes space to appear at the top and bottom of elements 7 | // that are clearfixed. 8 | // 2. The use of `table` rather than `block` is only necessary if using 9 | // `:before` to contain the top-margins of child elements. 10 | // 11 | // Source: http://nicolasgallagher.com/micro-clearfix-hack/ 12 | 13 | @mixin clearfix() { 14 | &:before, 15 | &:after { 16 | content: " "; // 1 17 | display: table; // 2 18 | } 19 | &:after { 20 | clear: both; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/bootstrap/mixins/_list-group.scss: -------------------------------------------------------------------------------- 1 | // List Groups 2 | 3 | @mixin list-group-item-variant($state, $background, $color) { 4 | .list-group-item-#{$state} { 5 | color: $color; 6 | background-color: $background; 7 | 8 | // [converter] extracted a& to a.list-group-item-#{$state} 9 | } 10 | 11 | a.list-group-item-#{$state} { 12 | color: $color; 13 | 14 | .list-group-item-heading { 15 | color: inherit; 16 | } 17 | 18 | &:hover, 19 | &:focus { 20 | color: $color; 21 | background-color: darken($background, 5%); 22 | } 23 | &.active, 24 | &.active:hover, 25 | &.active:focus { 26 | color: #fff; 27 | background-color: $color; 28 | border-color: $color; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/font-awesome/_rotated-flipped.scss: -------------------------------------------------------------------------------- 1 | // Rotated & Flipped Icons 2 | // ------------------------- 3 | 4 | .#{$fa-css-prefix}-rotate-90 { @include fa-icon-rotate(90deg, 1); } 5 | .#{$fa-css-prefix}-rotate-180 { @include fa-icon-rotate(180deg, 2); } 6 | .#{$fa-css-prefix}-rotate-270 { @include fa-icon-rotate(270deg, 3); } 7 | 8 | .#{$fa-css-prefix}-flip-horizontal { @include fa-icon-flip(-1, 1, 0); } 9 | .#{$fa-css-prefix}-flip-vertical { @include fa-icon-flip(1, -1, 2); } 10 | 11 | // Hook for IE8-9 12 | // ------------------------- 13 | 14 | :root .#{$fa-css-prefix}-rotate-90, 15 | :root .#{$fa-css-prefix}-rotate-180, 16 | :root .#{$fa-css-prefix}-rotate-270, 17 | :root .#{$fa-css-prefix}-flip-horizontal, 18 | :root .#{$fa-css-prefix}-flip-vertical { 19 | filter: none; 20 | } 21 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/views/form/fields.html.twig: -------------------------------------------------------------------------------- 1 | {# 2 | Each field type is rendered by a template fragment, which is determined 3 | by the name of your form type class (DateTimePickerType -> date_time_picker) 4 | and the suffix "_widget". This can be controlled by overriding getBlockPrefix() 5 | in DateTimePickerType. 6 | 7 | See http://symfony.com/doc/current/cookbook/form/create_custom_field_type.html#creating-a-template-for-the-field 8 | #} 9 | 10 | {% block date_time_picker_widget %} 11 | {% spaceless %} 12 |
13 | {{ block('datetime_widget') }} 14 | 15 | 16 | 17 |
18 | {% endspaceless %} 19 | {% endblock %} 20 | -------------------------------------------------------------------------------- /03-composed-application/dckr/php7/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7.0-fpm 2 | 3 | RUN apt-get update && \ 4 | apt-get upgrade -y && \ 5 | apt-get install -y curl git zlib1g-dev && \ 6 | docker-php-ext-install mysqli && \ 7 | docker-php-ext-install zip && \ 8 | # echo "/usr/local/lib/php/extensions/no-debug-non-zts-20151012/xdebug.so" >> /usr/local/etc/php/conf.d/xdebug.ini && \ 9 | # echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/xdebug.ini && \ 10 | # echo "xdebug.remote_autostart=off" >> /usr/local/etc/php/conf.d/xdebug.ini && \ 11 | curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && \ 12 | composer global require "hirak/prestissimo:^0.3" && \ 13 | apt-get clean -y && apt-get autoclean -y && apt-get autoremove -y && \ 14 | rm -rf /var/lib/apt/lists/* /var/lib/log/* /tmp/* /var/tmp/* 15 | 16 | WORKDIR /srv 17 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/css/font-lato.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'Lato'; 3 | font-style: normal; 4 | font-weight: 400; 5 | src: local('Lato Regular'), local('Lato-Regular'), url('../fonts/lato/Lato-Regular.woff') format('woff'); 6 | } 7 | @font-face { 8 | font-family: 'Lato'; 9 | font-style: normal; 10 | font-weight: 700; 11 | src: local('Lato Bold'), local('Lato-Bold'), url('../fonts/lato/Lato-Bold.woff') format('woff'); 12 | } 13 | @font-face { 14 | font-family: 'Lato'; 15 | font-style: italic; 16 | font-weight: 400; 17 | src: local('Lato Italic'), local('Lato-Italic'), url('../fonts/lato/Lato-Italic.woff') format('woff'); 18 | } 19 | @font-face { 20 | font-family: 'Lato'; 21 | font-style: italic; 22 | font-weight: 700; 23 | src: local('Lato Bold Italic'), local('Lato-BoldItalic'), url('../fonts/lato/Lato-BoldItalic.woff') format('woff'); 24 | } 25 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/font-awesome/_path.scss: -------------------------------------------------------------------------------- 1 | /* FONT PATH 2 | * -------------------------- */ 3 | 4 | @font-face { 5 | font-family: 'FontAwesome'; 6 | src: url('#{$fa-font-path}/fontawesome-webfont.eot?v=#{$fa-version}'); 7 | src: url('#{$fa-font-path}/fontawesome-webfont.eot?#iefix&v=#{$fa-version}') format('embedded-opentype'), 8 | url('#{$fa-font-path}/fontawesome-webfont.woff2?v=#{$fa-version}') format('woff2'), 9 | url('#{$fa-font-path}/fontawesome-webfont.woff?v=#{$fa-version}') format('woff'), 10 | url('#{$fa-font-path}/fontawesome-webfont.ttf?v=#{$fa-version}') format('truetype'), 11 | url('#{$fa-font-path}/fontawesome-webfont.svg?v=#{$fa-version}#fontawesomeregular') format('svg'); 12 | // src: url('#{$fa-font-path}/FontAwesome.otf') format('opentype'); // used when developing fonts 13 | font-weight: normal; 14 | font-style: normal; 15 | } 16 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/bootstrap/mixins/_table-row.scss: -------------------------------------------------------------------------------- 1 | // Tables 2 | 3 | @mixin table-row-variant($state, $background) { 4 | // Exact selectors below required to override `.table-striped` and prevent 5 | // inheritance to nested tables. 6 | .table > thead > tr, 7 | .table > tbody > tr, 8 | .table > tfoot > tr { 9 | > td.#{$state}, 10 | > th.#{$state}, 11 | &.#{$state} > td, 12 | &.#{$state} > th { 13 | background-color: $background; 14 | } 15 | } 16 | 17 | // Hover states for `.table-hover` 18 | // Note: this is not available for cells or rows within `thead` or `tfoot`. 19 | .table-hover > tbody > tr { 20 | > td.#{$state}:hover, 21 | > th.#{$state}:hover, 22 | &.#{$state}:hover > td, 23 | &:hover > .#{$state}, 24 | &.#{$state}:hover > th { 25 | background-color: darken($background, 5%); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/views/blog/index.html.twig: -------------------------------------------------------------------------------- 1 | {% extends 'base.html.twig' %} 2 | 3 | {% block body_id 'blog_index' %} 4 | 5 | {% block main %} 6 | {% for post in posts %} 7 | 16 | {% else %} 17 |
{{ 'post.no_posts_found'|trans }}
18 | {% endfor %} 19 | 20 | 23 | {% endblock %} 24 | 25 | {% block sidebar %} 26 | {{ parent() }} 27 | 28 | {{ show_source_code(_self) }} 29 | {% endblock %} 30 | -------------------------------------------------------------------------------- /03-composed-application/app/src/AppBundle/Utils/Slugger.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace AppBundle\Utils; 13 | 14 | /** 15 | * This class is used to provide an example of integrating simple classes as 16 | * services into a Symfony application. 17 | * 18 | * @author Ryan Weaver 19 | * @author Javier Eguiluz 20 | */ 21 | class Slugger 22 | { 23 | /** 24 | * @param string $string 25 | * 26 | * @return string 27 | */ 28 | public function slugify($string) 29 | { 30 | return trim(preg_replace('/[^a-z0-9]+/', '-', strtolower(strip_tags($string))), '-'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/font-awesome/_animated.scss: -------------------------------------------------------------------------------- 1 | // Spinning Icons 2 | // -------------------------- 3 | 4 | .#{$fa-css-prefix}-spin { 5 | -webkit-animation: fa-spin 2s infinite linear; 6 | animation: fa-spin 2s infinite linear; 7 | } 8 | 9 | .#{$fa-css-prefix}-pulse { 10 | -webkit-animation: fa-spin 1s infinite steps(8); 11 | animation: fa-spin 1s infinite steps(8); 12 | } 13 | 14 | @-webkit-keyframes fa-spin { 15 | 0% { 16 | -webkit-transform: rotate(0deg); 17 | transform: rotate(0deg); 18 | } 19 | 100% { 20 | -webkit-transform: rotate(359deg); 21 | transform: rotate(359deg); 22 | } 23 | } 24 | 25 | @keyframes fa-spin { 26 | 0% { 27 | -webkit-transform: rotate(0deg); 28 | transform: rotate(0deg); 29 | } 30 | 100% { 31 | -webkit-transform: rotate(359deg); 32 | transform: rotate(359deg); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/views/admin/blog/edit.html.twig: -------------------------------------------------------------------------------- 1 | {% extends 'admin/layout.html.twig' %} 2 | 3 | {% block body_id 'admin_post_edit' %} 4 | 5 | {% block main %} 6 |

{{ 'title.edit_post'|trans({'%id%': post.id}) }}

7 | 8 | {{ include('admin/blog/_form.html.twig', { 9 | form: edit_form, 10 | button_label: 'action.save'|trans, 11 | include_back_to_home_link: true, 12 | }, with_context = false) }} 13 | {% endblock %} 14 | 15 | {% block sidebar %} 16 |
17 | {{ include('admin/blog/_form.html.twig', { 18 | form: delete_form, 19 | button_label: 'action.delete_post'|trans, 20 | button_css: 'btn btn-lg btn-block btn-danger', 21 | show_confirmation: true, 22 | }, with_context = false) }} 23 |
24 | 25 | {{ parent() }} 26 | 27 | {{ show_source_code(_self) }} 28 | {% endblock %} 29 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/views/blog/_delete_post_confirmation.html.twig: -------------------------------------------------------------------------------- 1 | {# Bootstrap modal, see http://getbootstrap.com/javascript/#modals #} 2 | 20 | -------------------------------------------------------------------------------- /03-composed-application/app/src/AppBundle/Repository/UserRepository.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace AppBundle\Repository; 13 | 14 | use Doctrine\ORM\EntityRepository; 15 | 16 | /** 17 | * This custom Doctrine repository is empty because so far we don't need any custom 18 | * method to query for application user information. But it's always a good practice 19 | * to define a custom repository that will be used when the application grows. 20 | * See http://symfony.com/doc/current/book/doctrine.html#custom-repository-classes 21 | * 22 | * @author Ryan Weaver 23 | * @author Javier Eguiluz 24 | */ 25 | class UserRepository extends EntityRepository 26 | { 27 | } 28 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/views/admin/layout.html.twig: -------------------------------------------------------------------------------- 1 | {# 2 | This is the base template of the all backend pages. Since this layout is similar 3 | to the global layout, we inherit from it to just change the contents of some 4 | blocks. In practice, backend templates are using a three-level inheritance, 5 | showing how powerful, yet easy to use, is Twig's inheritance mechanism. 6 | See http://symfony.com/doc/current/book/templating.html#template-inheritance-and-layouts 7 | #} 8 | {% extends 'base.html.twig' %} 9 | 10 | {% block header_navigation_links %} 11 |
  • 12 | 13 | {{ 'menu.post_list'|trans }} 14 | 15 |
  • 16 |
  • 17 | 18 | {{ 'menu.back_to_blog'|trans }} 19 | 20 |
  • 21 | {% endblock %} 22 | -------------------------------------------------------------------------------- /03-composed-application/app/appveyor.yml: -------------------------------------------------------------------------------- 1 | build: false 2 | platform: x86 3 | clone_folder: c:\projects\symfony-demo 4 | 5 | cache: 6 | - '%LOCALAPPDATA%\Composer\files' 7 | 8 | init: 9 | - SET PATH=C:\Program Files\OpenSSL;c:\tools\php;%PATH% 10 | 11 | install: 12 | - cinst -y OpenSSL.Light 13 | - cinst -y php 14 | - cd c:\tools\php 15 | - copy php.ini-production php.ini /Y 16 | - echo date.timezone="UTC" >> php.ini 17 | - echo extension_dir=ext >> php.ini 18 | - echo extension=php_openssl.dll >> php.ini 19 | - echo extension=php_mbstring.dll >> php.ini 20 | - echo extension=php_intl.dll >> php.ini 21 | - echo extension=php_pdo_sqlite.dll >> php.ini 22 | - echo memory_limit=1G >> php.ini 23 | - cd %APPVEYOR_BUILD_FOLDER% 24 | - php -r "readfile('http://getcomposer.org/installer');" | php 25 | - php composer.phar install --no-interaction --no-progress 26 | 27 | test_script: 28 | - cd %APPVEYOR_BUILD_FOLDER% 29 | - php ./vendor/bin/phpunit --verbose 30 | -------------------------------------------------------------------------------- /03-composed-application/app/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Contributing 2 | ============ 3 | 4 | The Symfony Demo application is an open source project. Contributions made by 5 | the community are welcome. Send us your ideas, code reviews, pull requests and 6 | feature requests to help us improve this project. All contributions must follow 7 | the [usual Symfony contribution requirements](http://symfony.com/doc/current/contributing/index.html). 8 | 9 | Web Assets Management 10 | --------------------- 11 | 12 | This project manages its web assets in a special way to allow them to work 13 | without configuring any option, installing any tool or executing any command. 14 | If your contribution changes CSS styles or JavaScript code in any way, make 15 | sure to regenerate the `web/css/app.css` and `web/js/app.js` files. To do so, 16 | uncomment the Assetic blocks in the `app/Resources/views/base.html.twig` and 17 | execute the following command: 18 | 19 | ```bash 20 | $ php bin/console assetic:dump --no-debug 21 | ``` 22 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/views/admin/blog/new.html.twig: -------------------------------------------------------------------------------- 1 | {% extends 'admin/layout.html.twig' %} 2 | 3 | {% block body_id 'admin_post_new' %} 4 | 5 | {% block main %} 6 |

    {{ 'title.post_new'|trans }}

    7 | 8 | {{ form_start(form) }} 9 | {{ form_row(form.title) }} 10 | {{ form_row(form.summary) }} 11 | {{ form_row(form.content) }} 12 | {{ form_row(form.authorEmail) }} 13 | {{ form_row(form.publishedAt) }} 14 | 15 | 16 | 17 | {{ form_widget(form.saveAndCreateNew, { label: 'label.save_and_create_new', attr: { class: 'btn btn-primary' } }) }} 18 | 19 | 20 | {{ 'action.back_to_list'|trans }} 21 | 22 | {{ form_end(form) }} 23 | {% endblock %} 24 | 25 | {% block sidebar %} 26 | {{ parent() }} 27 | 28 | {{ show_source_code(_self) }} 29 | {% endblock %} 30 | -------------------------------------------------------------------------------- /03-composed-application/app/bin/console: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | getParameterOption(['--env', '-e'], getenv('SYMFONY_ENV') ?: 'dev'); 21 | $debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(['--no-debug', '']) && $env !== 'prod'; 22 | 23 | if ($debug) { 24 | Debug::enable(); 25 | } 26 | 27 | $kernel = new AppKernel($env, $debug); 28 | $application = new Application($kernel); 29 | $application->run($input); 30 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/bootstrap/_close.scss: -------------------------------------------------------------------------------- 1 | // 2 | // Close icons 3 | // -------------------------------------------------- 4 | 5 | 6 | .close { 7 | float: right; 8 | font-size: ($font-size-base * 1.5); 9 | font-weight: $close-font-weight; 10 | line-height: 1; 11 | color: $close-color; 12 | text-shadow: $close-text-shadow; 13 | @include opacity(.2); 14 | 15 | &:hover, 16 | &:focus { 17 | color: $close-color; 18 | text-decoration: none; 19 | cursor: pointer; 20 | @include opacity(.5); 21 | } 22 | 23 | // [converter] extracted button& to button.close 24 | } 25 | 26 | // Additional properties for button version 27 | // iOS requires the button element instead of an anchor tag. 28 | // If you want the anchor version, it requires `href="#"`. 29 | // See https://developer.mozilla.org/en-US/docs/Web/Events/click#Safari_Mobile 30 | button.close { 31 | padding: 0; 32 | cursor: pointer; 33 | background: transparent; 34 | border: 0; 35 | -webkit-appearance: none; 36 | } 37 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/bootstrap/_component-animations.scss: -------------------------------------------------------------------------------- 1 | // 2 | // Component animations 3 | // -------------------------------------------------- 4 | 5 | // Heads up! 6 | // 7 | // We don't use the `.opacity()` mixin here since it causes a bug with text 8 | // fields in IE7-8. Source: https://github.com/twbs/bootstrap/pull/3552. 9 | 10 | .fade { 11 | opacity: 0; 12 | @include transition(opacity .15s linear); 13 | &.in { 14 | opacity: 1; 15 | } 16 | } 17 | 18 | .collapse { 19 | display: none; 20 | 21 | &.in { display: block; } 22 | // [converter] extracted tr&.in to tr.collapse.in 23 | // [converter] extracted tbody&.in to tbody.collapse.in 24 | } 25 | 26 | tr.collapse.in { display: table-row; } 27 | 28 | tbody.collapse.in { display: table-row-group; } 29 | 30 | .collapsing { 31 | position: relative; 32 | height: 0; 33 | overflow: hidden; 34 | @include transition-property(height, visibility); 35 | @include transition-duration(.35s); 36 | @include transition-timing-function(ease); 37 | } 38 | -------------------------------------------------------------------------------- /03-composed-application/app/src/CodeExplorerBundle/DependencyInjection/CodeExplorerExtension.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace CodeExplorerBundle\DependencyInjection; 13 | 14 | use Symfony\Component\Config\FileLocator; 15 | use Symfony\Component\DependencyInjection\ContainerBuilder; 16 | use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; 17 | use Symfony\Component\HttpKernel\DependencyInjection\Extension; 18 | 19 | /** 20 | * @author Oleg Voronkovich 21 | */ 22 | class CodeExplorerExtension extends Extension 23 | { 24 | public function load(array $configs, ContainerBuilder $container) 25 | { 26 | $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); 27 | 28 | $loader->load('services.yml'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /03-composed-application/app/app/config/config_dev.yml: -------------------------------------------------------------------------------- 1 | imports: 2 | - { resource: config.yml } 3 | 4 | framework: 5 | router: 6 | resource: "%kernel.root_dir%/config/routing_dev.yml" 7 | strict_requirements: true 8 | profiler: { only_exceptions: false } 9 | 10 | web_profiler: 11 | toolbar: '%kernel.debug%' 12 | intercept_redirects: false 13 | 14 | monolog: 15 | handlers: 16 | main: 17 | type: stream 18 | path: "%kernel.logs_dir%/%kernel.environment%.log" 19 | level: info 20 | console: 21 | type: console 22 | bubble: false 23 | # uncomment to get logging in your browser 24 | # you may have to allow bigger header sizes in your Web server configuration 25 | #firephp: 26 | # type: firephp 27 | # level: info 28 | #chromephp: 29 | # type: chromephp 30 | # level: info 31 | 32 | assetic: 33 | use_controller: true 34 | 35 | #swiftmailer: 36 | # delivery_address: me@example.com 37 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/views/admin/blog/_form.html.twig: -------------------------------------------------------------------------------- 1 | {# 2 | By default, forms enable client-side validation. This means that you can't 3 | test the server-side validation errors from the browser. To temporarily 4 | disable this validation, add the 'novalidate' attribute: 5 | 6 | {{ form_start(form, { attr: { novalidate: 'novalidate' } }) }} 7 | #} 8 | 9 | {% if show_confirmation|default(false) %} 10 | {% set attr = {'data-confirmation': 'true'} %} 11 | {{ include('blog/_delete_post_confirmation.html.twig') }} 12 | {% endif %} 13 | 14 | {{ form_start(form, { attr: attr|default({}) }) }} 15 | {{ form_widget(form) }} 16 | 17 | 19 | 20 | {% if include_back_to_home_link|default(false) %} 21 | 22 | {{ 'action.back_to_list'|trans }} 23 | 24 | {% endif %} 25 | {{ form_end(form) }} 26 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/bootstrap/_utilities.scss: -------------------------------------------------------------------------------- 1 | // 2 | // Utility classes 3 | // -------------------------------------------------- 4 | 5 | 6 | // Floats 7 | // ------------------------- 8 | 9 | .clearfix { 10 | @include clearfix; 11 | } 12 | .center-block { 13 | @include center-block; 14 | } 15 | .pull-right { 16 | float: right !important; 17 | } 18 | .pull-left { 19 | float: left !important; 20 | } 21 | 22 | 23 | // Toggling content 24 | // ------------------------- 25 | 26 | // Note: Deprecated .hide in favor of .hidden or .sr-only (as appropriate) in v3.0.1 27 | .hide { 28 | display: none !important; 29 | } 30 | .show { 31 | display: block !important; 32 | } 33 | .invisible { 34 | visibility: hidden; 35 | } 36 | .text-hide { 37 | @include text-hide; 38 | } 39 | 40 | 41 | // Hide from screenreaders and browsers 42 | // 43 | // Credit: HTML5 Boilerplate 44 | 45 | .hidden { 46 | display: none !important; 47 | } 48 | 49 | 50 | // For Affix plugin 51 | // ------------------------- 52 | 53 | .affix { 54 | position: fixed; 55 | } 56 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/TwigBundle/views/Exception/error404.html.twig: -------------------------------------------------------------------------------- 1 | {# 2 | This template is used to render errors of type HTTP 404 (Not Found) 3 | 4 | This is the simplest way to customize error pages in Symfony applications. 5 | In case you need it, you can also hook into the internal exception handling 6 | made by Symfony. This allows you to perform advanced tasks and even recover 7 | your application from some errors. 8 | See http://symfony.com/doc/current/cookbook/controller/error_pages.html 9 | #} 10 | 11 | {% extends 'base.html.twig' %} 12 | 13 | {% block body_id 'error' %} 14 | 15 | {% block main %} 16 |

    {{ 'http_error.name'|trans({ '%status_code%': 404 }) }}

    17 | 18 |

    19 | {{ 'http_error_404.description'|trans }} 20 |

    21 |

    22 | {{ 'http_error_404.suggestion'|trans({ '%url%': path('blog_index') })|raw }} 23 |

    24 | {% endblock %} 25 | 26 | {% block sidebar %} 27 | {{ parent() }} 28 | 29 | {{ show_source_code(_self) }} 30 | {% endblock %} 31 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/TwigBundle/views/Exception/error500.html.twig: -------------------------------------------------------------------------------- 1 | {# 2 | This template is used to render errors of type HTTP 500 (Internal Server Error) 3 | 4 | This is the simplest way to customize error pages in Symfony applications. 5 | In case you need it, you can also hook into the internal exception handling 6 | made by Symfony. This allows you to perform advanced tasks and even recover 7 | your application from some errors. 8 | See http://symfony.com/doc/current/cookbook/controller/error_pages.html 9 | #} 10 | 11 | {% extends 'base.html.twig' %} 12 | 13 | {% block body_id 'error' %} 14 | 15 | {% block main %} 16 |

    {{ 'http_error.name'|trans({ '%status_code%': 500 }) }}

    17 | 18 |

    19 | {{ 'http_error_500.description'|trans }} 20 |

    21 |

    22 | {{ 'http_error_500.suggestion'|trans({ '%url%': path('blog_index') })|raw }} 23 |

    24 | {% endblock %} 25 | 26 | {% block sidebar %} 27 | {{ parent() }} 28 | 29 | {{ show_source_code(_self) }} 30 | {% endblock %} 31 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/TwigBundle/views/Exception/error403.html.twig: -------------------------------------------------------------------------------- 1 | {# 2 | This template is used to render errors of type HTTP 403 (Forbidden) 3 | 4 | This is the simplest way to customize error pages in Symfony applications. 5 | In case you need it, you can also hook into the internal exception handling 6 | made by Symfony. This allows you to perform advanced tasks and even recover 7 | your application from some errors. 8 | See http://symfony.com/doc/current/cookbook/controller/error_pages.html 9 | #} 10 | 11 | {% extends 'base.html.twig' %} 12 | 13 | {% block body_id 'error' %} 14 | 15 | {% block main %} 16 |

    {{ 'http_error.name'|trans({ '%status_code%': 403 }) }}

    17 | 18 |

    19 | {{ 'http_error_403.description'|trans }} 20 |

    21 |

    22 | {{ 'http_error_403.suggestion'|trans }} 23 |

    24 | {% endblock %} 25 | 26 | {% block sidebar %} 27 | {{ parent() }} 28 | 29 | {{ show_source_code(_self) }} 30 | {% endblock %} 31 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/bootstrap/_media.scss: -------------------------------------------------------------------------------- 1 | .media { 2 | // Proper spacing between instances of .media 3 | margin-top: 15px; 4 | 5 | &:first-child { 6 | margin-top: 0; 7 | } 8 | } 9 | 10 | .media, 11 | .media-body { 12 | zoom: 1; 13 | overflow: hidden; 14 | } 15 | 16 | .media-body { 17 | width: 10000px; 18 | } 19 | 20 | .media-object { 21 | display: block; 22 | } 23 | 24 | .media-right, 25 | .media > .pull-right { 26 | padding-left: 10px; 27 | } 28 | 29 | .media-left, 30 | .media > .pull-left { 31 | padding-right: 10px; 32 | } 33 | 34 | .media-left, 35 | .media-right, 36 | .media-body { 37 | display: table-cell; 38 | vertical-align: top; 39 | } 40 | 41 | .media-middle { 42 | vertical-align: middle; 43 | } 44 | 45 | .media-bottom { 46 | vertical-align: bottom; 47 | } 48 | 49 | // Reset margins on headings for tighter default spacing 50 | .media-heading { 51 | margin-top: 0; 52 | margin-bottom: 5px; 53 | } 54 | 55 | // Media list variation 56 | // 57 | // Undo default ul/ol styles 58 | .media-list { 59 | padding-left: 0; 60 | list-style: none; 61 | } 62 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/bootstrap/_thumbnails.scss: -------------------------------------------------------------------------------- 1 | // 2 | // Thumbnails 3 | // -------------------------------------------------- 4 | 5 | 6 | // Mixin and adjust the regular image class 7 | .thumbnail { 8 | display: block; 9 | padding: $thumbnail-padding; 10 | margin-bottom: $line-height-computed; 11 | line-height: $line-height-base; 12 | background-color: $thumbnail-bg; 13 | border: 1px solid $thumbnail-border; 14 | border-radius: $thumbnail-border-radius; 15 | @include transition(border .2s ease-in-out); 16 | 17 | > img, 18 | a > img { 19 | @include img-responsive; 20 | margin-left: auto; 21 | margin-right: auto; 22 | } 23 | 24 | // [converter] extracted a&:hover, a&:focus, a&.active to a.thumbnail:hover, a.thumbnail:focus, a.thumbnail.active 25 | 26 | // Image captions 27 | .caption { 28 | padding: $thumbnail-caption-padding; 29 | color: $thumbnail-caption-color; 30 | } 31 | } 32 | 33 | // Add a hover state for linked versions only 34 | a.thumbnail:hover, 35 | a.thumbnail:focus, 36 | a.thumbnail.active { 37 | border-color: $link-color; 38 | } 39 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/TwigBundle/views/Exception/error.html.twig: -------------------------------------------------------------------------------- 1 | {# 2 | This template is used to render any error different from 403, 404 and 500. 3 | 4 | This is the simplest way to customize error pages in Symfony applications. 5 | In case you need it, you can also hook into the internal exception handling 6 | made by Symfony. This allows you to perform advanced tasks and even recover 7 | your application from some errors. 8 | See http://symfony.com/doc/current/cookbook/controller/error_pages.html 9 | #} 10 | 11 | {% extends 'base.html.twig' %} 12 | 13 | {% block body_id 'error' %} 14 | 15 | {% block main %} 16 |

    {{ 'http_error.name'|trans({ '%status_code%': status_code }) }}

    17 | 18 |

    19 | {{ 'http_error.description'|trans({ '%status_code%': status_code }) }} 20 |

    21 |

    22 | {{ 'http_error.suggestion'|trans({ '%url%': path('blog_index') })|raw }} 23 |

    24 | {% endblock %} 25 | 26 | {% block sidebar %} 27 | {{ parent() }} 28 | 29 | {{ show_source_code(_self) }} 30 | {% endblock %} 31 | -------------------------------------------------------------------------------- /03-composed-application/app/phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | tests 18 | 19 | 20 | 21 | 22 | 23 | src 24 | 25 | src/*Bundle/Resources 26 | src/*/*Bundle/Resources 27 | src/*/Bundle/*Bundle/Resources 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Train+it 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /03-composed-application/app/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 Fabien Potencier 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is furnished 8 | to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/bootstrap/_pager.scss: -------------------------------------------------------------------------------- 1 | // 2 | // Pager pagination 3 | // -------------------------------------------------- 4 | 5 | 6 | .pager { 7 | padding-left: 0; 8 | margin: $line-height-computed 0; 9 | list-style: none; 10 | text-align: center; 11 | @include clearfix; 12 | li { 13 | display: inline; 14 | > a, 15 | > span { 16 | display: inline-block; 17 | padding: 5px 14px; 18 | background-color: $pager-bg; 19 | border: 1px solid $pager-border; 20 | border-radius: $pager-border-radius; 21 | } 22 | 23 | > a:hover, 24 | > a:focus { 25 | text-decoration: none; 26 | background-color: $pager-hover-bg; 27 | } 28 | } 29 | 30 | .next { 31 | > a, 32 | > span { 33 | float: right; 34 | } 35 | } 36 | 37 | .previous { 38 | > a, 39 | > span { 40 | float: left; 41 | } 42 | } 43 | 44 | .disabled { 45 | > a, 46 | > a:hover, 47 | > a:focus, 48 | > span { 49 | color: $pager-disabled-color; 50 | background-color: $pager-bg; 51 | cursor: $cursor-disabled; 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/font-awesome/_mixins.scss: -------------------------------------------------------------------------------- 1 | // Mixins 2 | // -------------------------- 3 | 4 | @mixin fa-icon() { 5 | display: inline-block; 6 | font: normal normal normal #{$fa-font-size-base}/1 FontAwesome; // shortening font declaration 7 | font-size: inherit; // can't have font-size inherit on line above, so need to override 8 | text-rendering: auto; // optimizelegibility throws things off #1094 9 | -webkit-font-smoothing: antialiased; 10 | -moz-osx-font-smoothing: grayscale; 11 | transform: translate(0, 0); // ensures no half-pixel rendering in firefox 12 | 13 | } 14 | 15 | @mixin fa-icon-rotate($degrees, $rotation) { 16 | filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=#{$rotation}); 17 | -webkit-transform: rotate($degrees); 18 | -ms-transform: rotate($degrees); 19 | transform: rotate($degrees); 20 | } 21 | 22 | @mixin fa-icon-flip($horiz, $vert, $rotation) { 23 | filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=#{$rotation}); 24 | -webkit-transform: scale($horiz, $vert); 25 | -ms-transform: scale($horiz, $vert); 26 | transform: scale($horiz, $vert); 27 | } 28 | -------------------------------------------------------------------------------- /03-composed-application/app/app/config/routing_dev.yml: -------------------------------------------------------------------------------- 1 | # this imports the routes used to display the web debug toolbar at the bottom of each page 2 | _wdt: 3 | resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml" 4 | prefix: /_wdt 5 | 6 | # this imports the routes needed to display the Symfony Profiler information 7 | _profiler: 8 | resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml" 9 | prefix: /_profiler 10 | 11 | # this imports the route used to test error pages. Just browse the following URL: 12 | # /{_locale}/_error/{status_code}.{format} 13 | # (e.g. /en/_error/404, /en/_error/403.json, /fr/_error/500.xml) 14 | # See http://symfony.com/doc/current/cookbook/controller/error_pages.html#testing-error-pages-during-development 15 | _errors: 16 | resource: "@TwigBundle/Resources/config/routing/errors.xml" 17 | prefix: /{_locale}/_error 18 | requirements: 19 | _locale: '%app_locales%' 20 | defaults: 21 | _locale: '%locale%' 22 | 23 | # this loads the main routing file, which usually defines the routes available 24 | # in any environment (production, development, etc.) 25 | _main: 26 | resource: routing.yml 27 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/bootstrap/_mixins.scss: -------------------------------------------------------------------------------- 1 | // Mixins 2 | // -------------------------------------------------- 3 | 4 | // Utilities 5 | @import "mixins/hide-text"; 6 | @import "mixins/opacity"; 7 | @import "mixins/image"; 8 | @import "mixins/labels"; 9 | @import "mixins/reset-filter"; 10 | @import "mixins/resize"; 11 | @import "mixins/responsive-visibility"; 12 | @import "mixins/size"; 13 | @import "mixins/tab-focus"; 14 | @import "mixins/text-emphasis"; 15 | @import "mixins/text-overflow"; 16 | @import "mixins/vendor-prefixes"; 17 | 18 | // Components 19 | @import "mixins/alerts"; 20 | @import "mixins/buttons"; 21 | @import "mixins/panels"; 22 | @import "mixins/pagination"; 23 | @import "mixins/list-group"; 24 | @import "mixins/nav-divider"; 25 | @import "mixins/forms"; 26 | @import "mixins/progress-bar"; 27 | @import "mixins/table-row"; 28 | 29 | // Skins 30 | @import "mixins/background-variant"; 31 | @import "mixins/border-radius"; 32 | @import "mixins/gradients"; 33 | 34 | // Layout 35 | @import "mixins/clearfix"; 36 | @import "mixins/center-block"; 37 | @import "mixins/nav-vertical-align"; 38 | @import "mixins/grid-framework"; 39 | @import "mixins/grid"; 40 | -------------------------------------------------------------------------------- /03-composed-application/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | services: 3 | php7: 4 | build: ./dckr/php7 5 | 6 | links: 7 | - db 8 | 9 | volumes_from: 10 | - data 11 | 12 | php5: 13 | build: ./dckr/php5 14 | 15 | links: 16 | - db 17 | 18 | volumes_from: 19 | - data 20 | 21 | nginx: 22 | image: nginx:1.11 23 | 24 | ports: 25 | - 8000:8000 26 | - 8001:8001 27 | - 8010:8010 28 | - 8011:8011 29 | 30 | links: 31 | - php7 32 | - php5 33 | 34 | volumes: 35 | - ./conf/nginx.conf:/etc/nginx/nginx.conf:ro 36 | 37 | volumes_from: 38 | - data 39 | 40 | db: 41 | image: mariadb 42 | 43 | volumes: 44 | - ./data/db:/var/lib/mysql 45 | 46 | volumes_from: 47 | - data 48 | 49 | environment: 50 | - MYSQL_ROOT_PASSWORD=root 51 | 52 | adminer: 53 | image: dockette/adminer:mysql-php7 54 | 55 | ports: 56 | - 10000:80 57 | 58 | links: 59 | - db 60 | 61 | data: 62 | image: busybox:latest 63 | 64 | volumes: 65 | - ./app:/srv 66 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/views/default/_flash_messages.html.twig: -------------------------------------------------------------------------------- 1 | {# 2 | This is a template fragment designed to be included in other templates 3 | See http://symfony.com/doc/current/book/templating.html#including-other-templates 4 | 5 | A common practice to better distinguish between templates and fragments is to 6 | prefix fragments with an underscore. That's why this template is called 7 | '_flash_messages.html.twig' instead of 'flash_messages.html.twig' 8 | #} 9 | 10 | {% if app.session.started and app.session.flashBag.peekAll is not empty %} 11 |
    12 | {% for type, messages in app.session.flashBag.all %} 13 | {% for message in messages %} 14 | {# Bootstrap alert, see http://getbootstrap.com/components/#alerts #} 15 | 22 | {% endfor %} 23 | {% endfor %} 24 |
    25 | {% endif %} 26 | -------------------------------------------------------------------------------- /03-composed-application/app/tests/AppBundle/Controller/BlogControllerTest.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace Tests\AppBundle\Controller; 13 | 14 | use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; 15 | use AppBundle\Entity\Post; 16 | 17 | /** 18 | * Functional test for the controllers defined inside BlogController. 19 | * See http://symfony.com/doc/current/book/testing.html#functional-tests 20 | * 21 | * Execute the application tests using this command (requires PHPUnit to be installed): 22 | * 23 | * $ cd your-symfony-project/ 24 | * $ phpunit -c app 25 | * 26 | */ 27 | class BlogControllerTest extends WebTestCase 28 | { 29 | public function testIndex() 30 | { 31 | $client = static::createClient(); 32 | $crawler = $client->request('GET', '/en/blog/'); 33 | 34 | $this->assertCount( 35 | Post::NUM_ITEMS, 36 | $crawler->filter('article.post'), 37 | 'The homepage displays the right number of posts.' 38 | ); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/bootstrap/_jumbotron.scss: -------------------------------------------------------------------------------- 1 | // 2 | // Jumbotron 3 | // -------------------------------------------------- 4 | 5 | 6 | .jumbotron { 7 | padding: $jumbotron-padding ($jumbotron-padding / 2); 8 | margin-bottom: $jumbotron-padding; 9 | color: $jumbotron-color; 10 | background-color: $jumbotron-bg; 11 | 12 | h1, 13 | .h1 { 14 | color: $jumbotron-heading-color; 15 | } 16 | 17 | p { 18 | margin-bottom: ($jumbotron-padding / 2); 19 | font-size: $jumbotron-font-size; 20 | font-weight: 200; 21 | } 22 | 23 | > hr { 24 | border-top-color: darken($jumbotron-bg, 10%); 25 | } 26 | 27 | .container &, 28 | .container-fluid & { 29 | border-radius: $border-radius-large; // Only round corners at higher resolutions if contained in a container 30 | } 31 | 32 | .container { 33 | max-width: 100%; 34 | } 35 | 36 | @media screen and (min-width: $screen-sm-min) { 37 | padding: ($jumbotron-padding * 1.6) 0; 38 | 39 | .container &, 40 | .container-fluid & { 41 | padding-left: ($jumbotron-padding * 2); 42 | padding-right: ($jumbotron-padding * 2); 43 | } 44 | 45 | h1, 46 | .h1 { 47 | font-size: ($font-size-base * 4.5); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /03-composed-application/app/app/config/routing.yml: -------------------------------------------------------------------------------- 1 | # These first lines load the all routes defined as @Route() annotations in any 2 | # controller defined inside the src/AppBundle/Controller/ directory. Controllers 3 | # are loaded recursively, so you can separate them into subdirectories. 4 | # If you don't like to add annotations in your applications, you can also define 5 | # the routes in YAML, XML or PHP files. 6 | # See http://symfony.com/doc/current/book/routing.html 7 | app: 8 | resource: '@AppBundle/Controller/' 9 | type: annotation 10 | prefix: /{_locale} 11 | requirements: 12 | _locale: '%app_locales%' 13 | defaults: 14 | _locale: '%locale%' 15 | 16 | # These lines define a route using YAML configuration. The controller used by 17 | # the route (FrameworkBundle:Template:template) is a convenient shortcut when 18 | # the template can be rendered without executing any logic in your own controller. 19 | # See http://symfony.com/doc/current/cookbook/templating/render_without_controller.html 20 | homepage: 21 | path: /{_locale} 22 | requirements: 23 | _locale: '%app_locales%' 24 | defaults: 25 | _controller: FrameworkBundle:Template:template 26 | template: default/homepage.html.twig 27 | _locale: '%locale%' 28 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/bootstrap/mixins/_buttons.scss: -------------------------------------------------------------------------------- 1 | // Button variants 2 | // 3 | // Easily pump out default styles, as well as :hover, :focus, :active, 4 | // and disabled options for all buttons 5 | 6 | @mixin button-variant($color, $background, $border) { 7 | color: $color; 8 | background-color: $background; 9 | border-color: $border; 10 | 11 | &:hover, 12 | &:focus, 13 | &.focus, 14 | &:active, 15 | &.active, 16 | .open > &.dropdown-toggle { 17 | color: $color; 18 | background-color: darken($background, 10%); 19 | border-color: darken($border, 12%); 20 | } 21 | &:active, 22 | &.active, 23 | .open > &.dropdown-toggle { 24 | background-image: none; 25 | } 26 | &.disabled, 27 | &[disabled], 28 | fieldset[disabled] & { 29 | &, 30 | &:hover, 31 | &:focus, 32 | &.focus, 33 | &:active, 34 | &.active { 35 | background-color: $background; 36 | border-color: $border; 37 | } 38 | } 39 | 40 | .badge { 41 | color: $background; 42 | background-color: $color; 43 | } 44 | } 45 | 46 | // Button sizes 47 | @mixin button-size($padding-vertical, $padding-horizontal, $font-size, $line-height, $border-radius) { 48 | padding: $padding-vertical $padding-horizontal; 49 | font-size: $font-size; 50 | line-height: $line-height; 51 | border-radius: $border-radius; 52 | } 53 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/bootstrap/mixins/_image.scss: -------------------------------------------------------------------------------- 1 | // Image Mixins 2 | // - Responsive image 3 | // - Retina image 4 | 5 | 6 | // Responsive image 7 | // 8 | // Keep images from scaling beyond the width of their parents. 9 | @mixin img-responsive($display: block) { 10 | display: $display; 11 | max-width: 100%; // Part 1: Set a maximum relative to the parent 12 | height: auto; // Part 2: Scale the height according to the width, otherwise you get stretching 13 | } 14 | 15 | 16 | // Retina image 17 | // 18 | // Short retina mixin for setting background-image and -size. Note that the 19 | // spelling of `min--moz-device-pixel-ratio` is intentional. 20 | @mixin img-retina($file-1x, $file-2x, $width-1x, $height-1x) { 21 | background-image: url(if($bootstrap-sass-asset-helper, twbs-image-path("#{$file-1x}"), "#{$file-1x}")); 22 | 23 | @media 24 | only screen and (-webkit-min-device-pixel-ratio: 2), 25 | only screen and ( min--moz-device-pixel-ratio: 2), 26 | only screen and ( -o-min-device-pixel-ratio: 2/1), 27 | only screen and ( min-device-pixel-ratio: 2), 28 | only screen and ( min-resolution: 192dpi), 29 | only screen and ( min-resolution: 2dppx) { 30 | background-image: url(if($bootstrap-sass-asset-helper, twbs-image-path("#{$file-2x}"), "#{$file-2x}")); 31 | background-size: $width-1x $height-1x; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /03-composed-application/app/tests/AppBundle/Utils/SluggerTest.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace Tests\AppBundle\Utils; 13 | 14 | use AppBundle\Utils\Slugger; 15 | 16 | /** 17 | * Unit test for the application utils. 18 | * See http://symfony.com/doc/current/book/testing.html#unit-tests 19 | * 20 | * Execute the application tests using this command (requires PHPUnit to be installed): 21 | * 22 | * $ cd your-symfony-project/ 23 | * $ phpunit -c app 24 | * 25 | */ 26 | class SluggerTest extends \PHPUnit_Framework_TestCase 27 | { 28 | /** 29 | * @dataProvider getSlugs 30 | */ 31 | public function testSlugify($string, $slug) 32 | { 33 | $slugger = new Slugger(); 34 | $result = $slugger->slugify($string); 35 | 36 | $this->assertEquals($slug, $result); 37 | } 38 | 39 | public function getSlugs() 40 | { 41 | yield ['Lorem Ipsum' , 'lorem-ipsum']; 42 | yield [' Lorem Ipsum ' , 'lorem-ipsum']; 43 | yield [' lOrEm iPsUm ' , 'lorem-ipsum']; 44 | yield ['!Lorem Ipsum!' , 'lorem-ipsum']; 45 | yield ['lorem-ipsum' , 'lorem-ipsum']; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/bootstrap/_labels.scss: -------------------------------------------------------------------------------- 1 | // 2 | // Labels 3 | // -------------------------------------------------- 4 | 5 | .label { 6 | display: inline; 7 | padding: .2em .6em .3em; 8 | font-size: 75%; 9 | font-weight: bold; 10 | line-height: 1; 11 | color: $label-color; 12 | text-align: center; 13 | white-space: nowrap; 14 | vertical-align: baseline; 15 | border-radius: .25em; 16 | 17 | // [converter] extracted a& to a.label 18 | 19 | // Empty labels collapse automatically (not available in IE8) 20 | &:empty { 21 | display: none; 22 | } 23 | 24 | // Quick fix for labels in buttons 25 | .btn & { 26 | position: relative; 27 | top: -1px; 28 | } 29 | } 30 | 31 | // Add hover effects, but only for links 32 | a.label { 33 | &:hover, 34 | &:focus { 35 | color: $label-link-hover-color; 36 | text-decoration: none; 37 | cursor: pointer; 38 | } 39 | } 40 | 41 | // Colors 42 | // Contextual variations (linked labels get darker on :hover) 43 | 44 | .label-default { 45 | @include label-variant($label-default-bg); 46 | } 47 | 48 | .label-primary { 49 | @include label-variant($label-primary-bg); 50 | } 51 | 52 | .label-success { 53 | @include label-variant($label-success-bg); 54 | } 55 | 56 | .label-info { 57 | @include label-variant($label-info-bg); 58 | } 59 | 60 | .label-warning { 61 | @include label-variant($label-warning-bg); 62 | } 63 | 64 | .label-danger { 65 | @include label-variant($label-danger-bg); 66 | } 67 | -------------------------------------------------------------------------------- /03-composed-application/app/src/AppBundle/Utils/Markdown.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace AppBundle\Utils; 13 | 14 | /** 15 | * This class is a light interface between an external Markdown parser library 16 | * and the application. It's generally recommended to create these light interfaces 17 | * to decouple your application from the implementation details of the third-party library. 18 | * 19 | * @author Ryan Weaver 20 | * @author Javier Eguiluz 21 | */ 22 | class Markdown 23 | { 24 | /** 25 | * @var \Parsedown 26 | */ 27 | private $parser; 28 | 29 | /** 30 | * @var \HTMLPurifier 31 | */ 32 | private $purifier; 33 | 34 | public function __construct() 35 | { 36 | $this->parser = new \Parsedown(); 37 | 38 | $purifierConfig = \HTMLPurifier_Config::create([ 39 | 'Cache.DefinitionImpl' => null, // Disable caching 40 | ]); 41 | $this->purifier = new \HTMLPurifier($purifierConfig); 42 | } 43 | 44 | /** 45 | * @param string $text 46 | * 47 | * @return string 48 | */ 49 | public function toHtml($text) 50 | { 51 | $html = $this->parser->text($text); 52 | $safeHtml = $this->purifier->purify($html); 53 | 54 | return $safeHtml; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/bootstrap/_badges.scss: -------------------------------------------------------------------------------- 1 | // 2 | // Badges 3 | // -------------------------------------------------- 4 | 5 | 6 | // Base class 7 | .badge { 8 | display: inline-block; 9 | min-width: 10px; 10 | padding: 3px 7px; 11 | font-size: $font-size-small; 12 | font-weight: $badge-font-weight; 13 | color: $badge-color; 14 | line-height: $badge-line-height; 15 | vertical-align: baseline; 16 | white-space: nowrap; 17 | text-align: center; 18 | background-color: $badge-bg; 19 | border-radius: $badge-border-radius; 20 | 21 | // Empty badges collapse automatically (not available in IE8) 22 | &:empty { 23 | display: none; 24 | } 25 | 26 | // Quick fix for badges in buttons 27 | .btn & { 28 | position: relative; 29 | top: -1px; 30 | } 31 | 32 | .btn-xs &, 33 | .btn-group-xs > .btn & { 34 | top: 0; 35 | padding: 1px 5px; 36 | } 37 | 38 | // [converter] extracted a& to a.badge 39 | 40 | // Account for badges in navs 41 | .list-group-item.active > &, 42 | .nav-pills > .active > a > & { 43 | color: $badge-active-color; 44 | background-color: $badge-active-bg; 45 | } 46 | 47 | .list-group-item > & { 48 | float: right; 49 | } 50 | 51 | .list-group-item > & + & { 52 | margin-right: 5px; 53 | } 54 | 55 | .nav-pills > li > a > & { 56 | margin-left: 3px; 57 | } 58 | } 59 | 60 | // Hover state, but only for links 61 | a.badge { 62 | &:hover, 63 | &:focus { 64 | color: $badge-link-hover-color; 65 | text-decoration: none; 66 | cursor: pointer; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /01-hello-world/README.md: -------------------------------------------------------------------------------- 1 | # 01 - Hello World 2 | 3 | ## Requirements 4 | 5 | - Docker (https://docs.docker.com/engine/installation/) 6 | 7 | ## Installation 8 | 9 | - Docker (https://dckr.cz/) 10 | - `apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D` 11 | - `apt-get install apt-transport-https ca-certificates` 12 | - **Debian** 13 | - `deb http://http.debian.net/debian wheezy-backports main` 14 | - `deb https://apt.dockerproject.org/repo debian-wheezy main` 15 | - `deb https://apt.dockerproject.org/repo debian-jessie main` 16 | - `deb https://apt.dockerproject.org/repo debian-stretch main` 17 | - **Ubuntu** 18 | - `deb https://apt.dockerproject.org/repo ubuntu-precise main` 19 | - `deb https://apt.dockerproject.org/repo ubuntu-trusty main` 20 | - `deb https://apt.dockerproject.org/repo ubuntu-wily main` 21 | - `deb https://apt.dockerproject.org/repo ubuntu-xenial main` 22 | - `sudo apt-get update` 23 | - `sudo apt-get install docker-engine` 24 | 25 | - Make sure your user is in the `docker` group. (Type `groups` for more details) 26 | - `sudo groupadd docker` 27 | - `sudo gpasswd -a ${USER} docker` 28 | - `sudo service docker restart` 29 | 30 | # Containers 31 | 32 | - Hello world (`hello-world`) 33 | 34 | ## Manual 35 | 36 | 1. Download and install docker. 37 | 2. Solve all problem with docker installation. :sweat_smile: 38 | 3. Type `docker ps` 39 | 4. Try `docker run hello-world` 40 | 41 | ![alt text](https://raw.githubusercontent.com/trainit/2016-docker-workshop/master/01-hello-world/misc/01.png "Hello World!") 42 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/views/default/homepage.html.twig: -------------------------------------------------------------------------------- 1 | {% extends 'base.html.twig' %} 2 | 3 | {% block body_id 'homepage' %} 4 | 5 | {# 6 | the homepage is a special page which displays neither a header nor a footer. 7 | this is done with the 'trick' of defining empty Twig blocks without any content 8 | #} 9 | {% block header %}{% endblock %} 10 | {% block footer %}{% endblock %} 11 | 12 | {% block body %} 13 | 16 | 17 |
    18 |
    19 |
    20 |

    21 | {{ 'help.browse_app'|trans|raw }} 22 |

    23 |

    24 | 25 | {{ 'action.browse_app'|trans }} 26 | 27 |

    28 |
    29 |
    30 | 31 |
    32 |
    33 |

    34 | {{ 'help.browse_admin'|trans|raw }} 35 |

    36 |

    37 | 38 | {{ 'action.browse_admin'|trans }} 39 | 40 |

    41 |
    42 |
    43 |
    44 | {% endblock %} 45 | -------------------------------------------------------------------------------- /03-composed-application/app/src/AppBundle/Utils/MomentFormatConverter.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace AppBundle\Utils; 13 | 14 | /** 15 | * This class is used to convert PHP date format to moment.js format 16 | * 17 | * @author Yonel Ceruto 18 | */ 19 | class MomentFormatConverter 20 | { 21 | /** 22 | * This defines the mapping between PHP ICU date format (key) and moment.js date format (value) 23 | * For ICU formats see http://userguide.icu-project.org/formatparse/datetime#TOC-Date-Time-Format-Syntax 24 | * For Moment formats see http://momentjs.com/docs/#/displaying/format/ 25 | * 26 | * @var array 27 | */ 28 | private static $formatConvertRules = [ 29 | // year 30 | 'yyyy' => 'YYYY', 'yy' => 'YY', 'y' => 'YYYY', 31 | // day 32 | 'dd' => 'DD', 'd' => 'D', 33 | // day of week 34 | 'EE' => 'ddd', 'EEEEEE' => 'dd', 35 | // timezone 36 | 'ZZZZZ' => 'Z', 'ZZZ' => 'ZZ', 37 | // letter 'T' 38 | '\'T\'' => 'T', 39 | ]; 40 | 41 | /** 42 | * Returns associated moment.js format. 43 | * 44 | * @param string $format PHP Date format 45 | * 46 | * @return string 47 | */ 48 | public function convert($format) 49 | { 50 | return strtr($format, self::$formatConvertRules); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/views/blog/_comment_form.html.twig: -------------------------------------------------------------------------------- 1 | {# 2 | By default, forms enable client-side validation. This means that you can't 3 | test the server-side validation errors from the browser. To temporarily 4 | disable this validation, add the 'novalidate' attribute: 5 | 6 | {{ form_start(form, { method: ..., action: ..., attr: { novalidate: 'novalidate' } }) }} 7 | #} 8 | 9 | {{ form_start(form, { method: 'POST', action: path('comment_new', { 'postSlug': post.slug }) }) }} 10 | {# instead of displaying form fields one by one, you can also display them 11 | all with their default options and styles just by calling to this function: 12 | 13 | {{ form_widget(form) }} 14 | #} 15 | 16 |
    17 | {{ 'title.add_comment'|trans }} 18 | 19 | {# Render any global form error (e.g. when a constraint on a public getter method failed) #} 20 | {{ form_errors(form) }} 21 | 22 |
    23 | {{ form_label(form.content, 'label.content', { label_attr: { class: 'hidden' }}) }} 24 | 25 | {# Render any errors for the "content" field (e.g. when a class property constraint failed) #} 26 | {{ form_errors(form.content) }} 27 | 28 | {{ form_widget(form.content, { attr: { rows: 10 } }) }} 29 |
    30 | 31 |
    32 | 33 |
    34 |
    35 | {{ form_end(form) }} 36 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/_bootstrap.scss: -------------------------------------------------------------------------------- 1 | // Core variables and mixins 2 | @import "bootstrap/variables"; 3 | @import "bootstrap/mixins"; 4 | 5 | // Reset and dependencies 6 | @import "bootstrap/normalize"; 7 | @import "bootstrap/print"; 8 | // don't import glyphicons because we use FontAwesome icons 9 | // @import "bootstrap/glyphicons"; 10 | 11 | // Core CSS 12 | @import "bootstrap/scaffolding"; 13 | @import "bootstrap/type"; 14 | @import "bootstrap/code"; 15 | @import "bootstrap/grid"; 16 | @import "bootstrap/tables"; 17 | @import "bootstrap/forms"; 18 | @import "bootstrap/buttons"; 19 | 20 | // Components 21 | @import "bootstrap/component-animations"; 22 | @import "bootstrap/dropdowns"; 23 | @import "bootstrap/button-groups"; 24 | @import "bootstrap/input-groups"; 25 | @import "bootstrap/navs"; 26 | @import "bootstrap/navbar"; 27 | @import "bootstrap/breadcrumbs"; 28 | @import "bootstrap/pagination"; 29 | @import "bootstrap/pager"; 30 | @import "bootstrap/labels"; 31 | @import "bootstrap/badges"; 32 | @import "bootstrap/jumbotron"; 33 | @import "bootstrap/thumbnails"; 34 | @import "bootstrap/alerts"; 35 | @import "bootstrap/progress-bars"; 36 | @import "bootstrap/media"; 37 | @import "bootstrap/list-group"; 38 | @import "bootstrap/panels"; 39 | @import "bootstrap/responsive-embed"; 40 | @import "bootstrap/wells"; 41 | @import "bootstrap/close"; 42 | 43 | // Components w/ JavaScript 44 | @import "bootstrap/modals"; 45 | @import "bootstrap/tooltip"; 46 | @import "bootstrap/popovers"; 47 | @import "bootstrap/carousel"; 48 | 49 | // Utility classes 50 | @import "bootstrap/utilities"; 51 | @import "bootstrap/responsive-utilities"; 52 | -------------------------------------------------------------------------------- /03-composed-application/app/web/app_dev.php: -------------------------------------------------------------------------------- 1 | loadClassCache(); 36 | $request = Request::createFromGlobals(); 37 | $response = $kernel->handle($request); 38 | $response->send(); 39 | $kernel->terminate($request, $response); 40 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Docker Workshop 2016 2 | 3 | | ID | Project | Description | 4 | |---- |------------------------------------------------------------------------------------------------------------- |----------------------------------------------------------------------------------------- | 5 | | 01 | [Hello World](https://github.com/trainit/2016-docker-workshop/tree/master/01-hello-world) | First kick-off with Docker. | 6 | | 02 | [Simple Application](https://github.com/trainit/2016-docker-workshop/tree/master/02-simple-page) | Single Page Application (SPA) with NodeJS and Docker. | 7 | | 03 | [Composed Application](https://github.com/trainit/2016-docker-workshop/tree/master/03-composed-application) | Symfony (PHP7/PHP5), Server (Nginx), SQL(MariaDB), Adminer and Docker / Docker Compose. | 8 | | 04 | [GUI](https://github.com/trainit/2016-docker-workshop/tree/master/04-gui) | Fun with Docker. Desktop applications with GUI in isolated Docker container. | 9 | | 05 | [Tips](https://github.com/trainit/2016-docker-workshop/tree/master/05-tips) | Collection of useful tips and tricks. | 10 | 11 | ## Hotlinks 12 | 13 | http://bit.ly/symfonyhk2016 14 | 15 | ## Authors 16 | 17 | **Milan Felix Šulc** / rkfelix@gmail.com 18 | 19 | **Pavel Spajx Stejskal** / spajxo@gmail.com 20 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/translations/validators.ja.xliff: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | post.blank_summary 7 | 要約を入力してください。 8 | 9 | 10 | post.blank_content 11 | 本文を入力してください。 12 | 13 | 14 | post.too_short_content 15 | 本文が短すぎます ({{ limit }} 文字以上必要です) 16 | 17 | 18 | comment.blank 19 | コメントを入力してください。 20 | 21 | 22 | comment.too_short 23 | コメントが短すぎます ({{ limit }} 文字以上必要です) 24 | 25 | 26 | comment.too_long 27 | コメントが長すぎます ({{ limit }} 文字以下にしてください) 28 | 29 | 30 | comment.is_spam 31 | コメントの内容がスパムと判定されました。 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /03-composed-application/README.md: -------------------------------------------------------------------------------- 1 | # 03 - Composed Application (Dynamic) 2 | 3 | ## Requirements 4 | 5 | - Docker (https://docs.docker.com/engine/installation/) 6 | - Docker Compose (https://docs.docker.com/compose/) 7 | 8 | ## Installation 9 | 10 | Be sure you are a root user. Hell ya! 11 | 12 | ```sh 13 | curl -L https://github.com/docker/compose/releases/download/1.8.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose 14 | chmod +x /usr/local/bin/docker-compose 15 | ``` 16 | 17 | ## Containers 18 | 19 | - PHP 7.x-FPM (`php:7-fpm`) 20 | - PHP 5.6.x-FPM (`php:5.6-fpm`) 21 | - Nginx 1.11.x (`nginx:1.11`) 22 | - MariaDB (`mariadb`) 23 | - Adminer (`dockette/adminer:mysql-php7`) 24 | 25 | ## Manual 26 | 27 | 1. Run `docker-compose -v` to see your docker-compose version. 28 | 2. Start connected containers with `docker-compose up`. 29 | 3. Connect to container `docker exec -it bash`. 30 | 4. Go to folder `/srv` and update chmod of **var** folder. `chmod -R 0777 /srv/var`. 31 | 5. Download dependencies with `composer install`. Maybe purge `var/cache`, `var/logs`, `var/sessions`. 32 | 6. Setup database with following commands: 33 | - `bin/console doctrine:database:create` 34 | - `bin/console doctrine:schema:create` 35 | - `bin/console doctrine:fixtures:load` 36 | 7. Open browser. 37 | - PHP 7 38 | - `http://localhost:8000` is development version. 39 | - `http://localhost:8001` is production version. 40 | - PHP 5.6 41 | - `http://localhost:8010` is development version. 42 | - `http://localhost:8011` is production version. 43 | - `http://localhost:10000` occupies Adminer. 44 | 45 | ![](https://raw.githubusercontent.com/trainit/2016-docker-workshop/master/03-composed-application/misc/01.png "Composed Application!") 46 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/bootstrap/_code.scss: -------------------------------------------------------------------------------- 1 | // 2 | // Code (inline and block) 3 | // -------------------------------------------------- 4 | 5 | 6 | // Inline and block code styles 7 | code, 8 | kbd, 9 | pre, 10 | samp { 11 | font-family: $font-family-monospace; 12 | } 13 | 14 | // Inline code 15 | code { 16 | padding: 2px 4px; 17 | font-size: 90%; 18 | color: $code-color; 19 | background-color: $code-bg; 20 | border-radius: $border-radius-base; 21 | } 22 | 23 | // User input typically entered via keyboard 24 | kbd { 25 | padding: 2px 4px; 26 | font-size: 90%; 27 | color: $kbd-color; 28 | background-color: $kbd-bg; 29 | border-radius: $border-radius-small; 30 | box-shadow: inset 0 -1px 0 rgba(0,0,0,.25); 31 | 32 | kbd { 33 | padding: 0; 34 | font-size: 100%; 35 | font-weight: bold; 36 | box-shadow: none; 37 | } 38 | } 39 | 40 | // Blocks of code 41 | pre { 42 | display: block; 43 | padding: (($line-height-computed - 1) / 2); 44 | margin: 0 0 ($line-height-computed / 2); 45 | font-size: ($font-size-base - 1); // 14px to 13px 46 | line-height: $line-height-base; 47 | word-break: break-all; 48 | word-wrap: break-word; 49 | color: $pre-color; 50 | background-color: $pre-bg; 51 | border: 1px solid $pre-border-color; 52 | border-radius: $border-radius-base; 53 | 54 | // Account for some code outputs that place code tags in pre tags 55 | code { 56 | padding: 0; 57 | font-size: inherit; 58 | color: inherit; 59 | white-space: pre-wrap; 60 | background-color: transparent; 61 | border-radius: 0; 62 | } 63 | } 64 | 65 | // Enable scrollable blocks of code 66 | .pre-scrollable { 67 | max-height: $pre-scrollable-max-height; 68 | overflow-y: scroll; 69 | } 70 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/translations/validators.de.xliff: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | post.blank_summary 7 | Gib deinem Beitrag eine Zusammenfassung! 8 | 9 | 10 | post.blank_content 11 | Dein Beitrag sollte einen Inhalt haben! 12 | 13 | 14 | post.too_short_content 15 | Der Beitragsinhalt ist zu kurz (mindestens {{ limit }} Zeichen) 16 | 17 | 18 | comment.blank 19 | Bitte gib einen Kommentar ein! 20 | 21 | 22 | comment.too_short 23 | Der Kommentar ist zu kurz (mindestens {{ limit }} Zeichen) 24 | 25 | 26 | comment.too_long 27 | Der Kommentar ist zu lang (maximal {{ limit }} Zeichen) 28 | 29 | 30 | comment.is_spam 31 | Der Inhalt des Kommentars wird als Spam eingestuft. 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /04-gui/README.md: -------------------------------------------------------------------------------- 1 | # 04 - GUI 2 | 3 | ## Hotlinks 4 | 5 | - https://github.com/jfrazelle/dockerfiles 6 | 7 | ## Xhost 8 | 9 | If you have a problem with your display or you don't see any application. Try to setup xhost. 10 | 11 | ```bash 12 | xhost + 13 | ``` 14 | 15 | ## Resources 16 | 17 | - https://github.com/jfrazelle/dockerfiles 18 | - http://wiki.ros.org/docker/Tutorials/GUI 19 | - http://fabiorehm.com/blog/2014/09/11/running-gui-apps-with-docker/ 20 | - https://blog.jessfraz.com/post/docker-containers-on-the-desktop/ 21 | - http://linoxide.com/how-tos/20-docker-containers-desktop-user/ 22 | - https://oliverveits.wordpress.com/2016/04/28/running-gui-apps-with-docker-for-remote-access/ 23 | 24 | ## Sublime ([Dockerfile](https://github.com/jfrazelle/dockerfiles/blob/master/sublime-text-3/Dockerfile)) 25 | 26 | ``` bash 27 | docker run --rm -it \ 28 | -v /tmp/.X11-unix:/tmp/.X11-unix \ 29 | -v $HOME/.local/share/recently-used.xbel:$HOME/.local/share/recently-used.xbel \ 30 | -e DISPLAY=$DISPLAY \ 31 | -e NEWUSER=$USER \ 32 | -e LANG=en_US.UTF-8 \ 33 | jess/sublime-text-3 34 | ``` 35 | 36 | ## Chrome ([Dockerfile](https://github.com/jfrazelle/dockerfiles/blob/master/chrome/stable/Dockerfile)) 37 | 38 | ``` bash 39 | docker run --rm -it \ 40 | --net host \ 41 | --cpuset-cpus 0 \ 42 | --memory 512mb \ 43 | -v /tmp/.X11-unix:/tmp/.X11-unix \ 44 | -e DISPLAY=unix$DISPLAY \ 45 | --device /dev/snd \ 46 | -v /dev/shm:/dev/shm \ 47 | jess/chrome 48 | ``` 49 | 50 | ## Skype ([Dockerfile](https://github.com/jfrazelle/dockerfiles/blob/master/skype/Dockerfile)) 51 | 52 | ``` bash 53 | docker run --rm -it \ 54 | -v /tmp/.X11-unix:/tmp/.X11-unix:ro \ 55 | -e DISPLAY="unix$DISPLAY" \ 56 | tianon/skype 57 | ``` 58 | -------------------------------------------------------------------------------- /03-composed-application/app/src/AppBundle/Repository/PostRepository.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace AppBundle\Repository; 13 | 14 | use AppBundle\Entity\Post; 15 | use Doctrine\ORM\EntityRepository; 16 | use Doctrine\ORM\Query; 17 | use Pagerfanta\Adapter\DoctrineORMAdapter; 18 | use Pagerfanta\Pagerfanta; 19 | 20 | /** 21 | * This custom Doctrine repository contains some methods which are useful when 22 | * querying for blog post information. 23 | * See http://symfony.com/doc/current/book/doctrine.html#custom-repository-classes 24 | * 25 | * @author Ryan Weaver 26 | * @author Javier Eguiluz 27 | */ 28 | class PostRepository extends EntityRepository 29 | { 30 | /** 31 | * @return Query 32 | */ 33 | public function queryLatest() 34 | { 35 | return $this->getEntityManager() 36 | ->createQuery(' 37 | SELECT p 38 | FROM AppBundle:Post p 39 | WHERE p.publishedAt <= :now 40 | ORDER BY p.publishedAt DESC 41 | ') 42 | ->setParameter('now', new \DateTime()) 43 | ; 44 | } 45 | 46 | /** 47 | * @param int $page 48 | * 49 | * @return Pagerfanta 50 | */ 51 | public function findLatest($page = 1) 52 | { 53 | $paginator = new Pagerfanta(new DoctrineORMAdapter($this->queryLatest(), false)); 54 | $paginator->setMaxPerPage(Post::NUM_ITEMS); 55 | $paginator->setCurrentPage($page); 56 | 57 | return $paginator; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/translations/validators.sl.xliff: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | post.blank_summary 7 | Dodajte vaši objavi povzetek! 8 | 9 | 10 | post.blank_content 11 | Vaša objava mora imeti nekaj vsebine! 12 | 13 | 14 | post.too_short_content 15 | Vsebina objave je prekratka (vsaj {{ limit }} znakov) 16 | 17 | 18 | comment.blank 19 | Ne pustite vašega komentarja praznega! 20 | 21 | 22 | comment.too_short 23 | Komentar je prekratek (vsaj {{ limit }} znakov) 24 | 25 | 26 | comment.too_long 27 | Komentar je predolg (največ {{ limit }} znakov) 28 | 29 | 30 | comment.is_spam 31 | Vsebina tega komentarja se smatra za spam. 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/translations/validators.en.xliff: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | post.blank_summary 7 | Give your post a summary! 8 | 9 | 10 | post.blank_content 11 | Your post should have some content! 12 | 13 | 14 | post.too_short_content 15 | Post content is too short ({{ limit }} characters minimum) 16 | 17 | 18 | comment.blank 19 | Please don't leave your comment blank! 20 | 21 | 22 | comment.too_short 23 | Comment is too short ({{ limit }} characters minimum) 24 | 25 | 26 | comment.too_long 27 | Comment is too long ({{ limit }} characters maximum) 28 | 29 | 30 | comment.is_spam 31 | The content of this comment is considered spam. 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/translations/validators.id.xliff: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | post.blank_summary 7 | Beri posting anda ringkasan! 8 | 9 | 10 | post.blank_content 11 | Posting anda harus mempunyai konten! 12 | 13 | 14 | post.too_short_content 15 | Konten terlalu singkat (Minimal {{ limit }} karakter) 16 | 17 | 18 | comment.blank 19 | Mohon jangan tinggalkan komentar kosong! 20 | 21 | 22 | comment.too_short 23 | Komentar terlalu singkat (Minimal {{ limit }} karakter) 24 | 25 | 26 | comment.too_long 27 | Komentar terlalu panjang (Maksimal {{ limit }} karakter) 28 | 29 | 30 | comment.is_spam 31 | Konten komentar ini dianggap sebagai spam. 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/translations/validators.nl.xliff: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | post.blank_summary 7 | Geef uw bericht een samenvatting. 8 | 9 | 10 | post.blank_content 11 | Uw bericht heeft nog geen inhoud. 12 | 13 | 14 | post.too_short_content 15 | Bericht inhoud is te kort (minimaal {{ limit }} karakters) 16 | 17 | 18 | comment.blank 19 | Vul alstublieft een reactie in. 20 | 21 | 22 | comment.too_short 23 | Reactie is te kort (minimaal {{ limit }} karakters) 24 | 25 | 26 | comment.too_long 27 | Reactie is te lang (maximaal {{ limit }} karakters) 28 | 29 | 30 | comment.is_spam 31 | De inhoud van deze reactie wordt als spam gemarkeerd. 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/translations/validators.pl.xliff: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | post.blank_summary 7 | Dodaj podsumowanie Twojego artykułu! 8 | 9 | 10 | post.blank_content 11 | Treść artykułu nie może być pusta! 12 | 13 | 14 | post.too_short_content 15 | Treść artykułu jest za krótka (minimum: {{ limit }} znaków) 16 | 17 | 18 | comment.blank 19 | Pole komentarza nie może być puste! 20 | 21 | 22 | comment.too_short 23 | Twój komentarz jest za krótki (minimum: {{ limit }} znaków) 24 | 25 | 26 | comment.too_long 27 | Twój komentarz jest za długi (maksimum: {{ limit }} znaków) 28 | 29 | 30 | comment.is_spam 31 | Twój komentarz został uznany za spam. 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /03-composed-application/app/src/CodeExplorerBundle/EventListener/ControllerListener.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace CodeExplorerBundle\EventListener; 13 | 14 | use Symfony\Component\HttpKernel\Event\FilterControllerEvent; 15 | use CodeExplorerBundle\Twig\SourceCodeExtension; 16 | 17 | /** 18 | * Defines the method that 'listens' to the 'kernel.controller' event, which is 19 | * triggered whenever a controller is executed in the application. 20 | * See http://symfony.com/doc/current/book/internals.html#kernel-controller-event 21 | * 22 | * Tip: listeners are common in Symfony applications, but this particular listener 23 | * is too advanced and too specific for the demo application needs. For more common 24 | * examples see http://symfony.com/doc/current/cookbook/service_container/event_listener.html 25 | * 26 | * @author Ryan Weaver 27 | * @author Javier Eguiluz 28 | */ 29 | class ControllerListener 30 | { 31 | private $twigExtension; 32 | 33 | public function __construct(SourceCodeExtension $twigExtension) 34 | { 35 | $this->twigExtension = $twigExtension; 36 | } 37 | 38 | public function registerCurrentController(FilterControllerEvent $event) 39 | { 40 | // this check is needed because in Symfony a request can perform any 41 | // number of sub-requests. See 42 | // http://symfony.com/doc/current/components/http_kernel/introduction.html#sub-requests 43 | if ($event->isMasterRequest()) { 44 | $this->twigExtension->setController($event->getController()); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/js/main.js: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the Symfony package. 3 | * 4 | * (c) Fabien Potencier 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | (function ($) { 11 | $(document).ready(function () { 12 | hljs.initHighlightingOnLoad(); 13 | 14 | // Datetime picker initialization. 15 | // See http://eonasdan.github.io/bootstrap-datetimepicker/ 16 | $('[data-toggle="datetimepicker"]').datetimepicker({ 17 | icons: { 18 | time: 'fa fa-clock-o', 19 | date: 'fa fa-calendar', 20 | up: 'fa fa-chevron-up', 21 | down: 'fa fa-chevron-down', 22 | previous: 'fa fa-chevron-left', 23 | next: 'fa fa-chevron-right', 24 | today: 'fa fa-check-circle-o', 25 | clear: 'fa fa-trash', 26 | close: 'fa fa-remove' 27 | } 28 | }); 29 | }); 30 | 31 | // Handling the modal confirmation message. 32 | $(document).on('submit', 'form[data-confirmation]', function (event) { 33 | var $form = $(this), 34 | $confirm = $('#confirmationModal'); 35 | 36 | if ($confirm.data('result') !== 'yes') { 37 | //cancel submit event 38 | event.preventDefault(); 39 | 40 | $confirm 41 | .off('click', '#btnYes') 42 | .on('click', '#btnYes', function () { 43 | $confirm.data('result', 'yes'); 44 | $form.find('input[type="submit"]').attr('disabled', 'disabled'); 45 | $form.submit(); 46 | }) 47 | .modal('show'); 48 | } 49 | }); 50 | })(window.jQuery); 51 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/bootstrap/_grid.scss: -------------------------------------------------------------------------------- 1 | // 2 | // Grid system 3 | // -------------------------------------------------- 4 | 5 | 6 | // Container widths 7 | // 8 | // Set the container width, and override it for fixed navbars in media queries. 9 | 10 | .container { 11 | @include container-fixed; 12 | 13 | @media (min-width: $screen-sm-min) { 14 | width: $container-sm; 15 | } 16 | @media (min-width: $screen-md-min) { 17 | width: $container-md; 18 | } 19 | @media (min-width: $screen-lg-min) { 20 | width: $container-lg; 21 | } 22 | } 23 | 24 | 25 | // Fluid container 26 | // 27 | // Utilizes the mixin meant for fixed width containers, but without any defined 28 | // width for fluid, full width layouts. 29 | 30 | .container-fluid { 31 | @include container-fixed; 32 | } 33 | 34 | 35 | // Row 36 | // 37 | // Rows contain and clear the floats of your columns. 38 | 39 | .row { 40 | @include make-row; 41 | } 42 | 43 | 44 | // Columns 45 | // 46 | // Common styles for small and large grid columns 47 | 48 | @include make-grid-columns; 49 | 50 | 51 | // Extra small grid 52 | // 53 | // Columns, offsets, pushes, and pulls for extra small devices like 54 | // smartphones. 55 | 56 | @include make-grid(xs); 57 | 58 | 59 | // Small grid 60 | // 61 | // Columns, offsets, pushes, and pulls for the small device range, from phones 62 | // to tablets. 63 | 64 | @media (min-width: $screen-sm-min) { 65 | @include make-grid(sm); 66 | } 67 | 68 | 69 | // Medium grid 70 | // 71 | // Columns, offsets, pushes, and pulls for the desktop device range. 72 | 73 | @media (min-width: $screen-md-min) { 74 | @include make-grid(md); 75 | } 76 | 77 | 78 | // Large grid 79 | // 80 | // Columns, offsets, pushes, and pulls for the large desktop device range. 81 | 82 | @media (min-width: $screen-lg-min) { 83 | @include make-grid(lg); 84 | } 85 | -------------------------------------------------------------------------------- /03-composed-application/app/src/AppBundle/AppBundle.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace AppBundle; 13 | 14 | use Symfony\Component\HttpKernel\Bundle\Bundle; 15 | 16 | /** 17 | * This class is the one that transforms the src/AppBundle/ directory into a real 18 | * Symfony bundle. There are two types of bundles: 19 | * 20 | * * Reusable Bundles: they are meant to be shared between different applications. 21 | * A lot of them are even publicly available in sites like packagist.org. 22 | * See http://symfony.com/doc/current/cookbook/bundles/best_practices.html 23 | * * Application bundles: they are never shared, not even with other of your 24 | * applications. This allows them to be less strict in some conventions and 25 | * their code is usually simpler. 26 | * See http://symfony.com/doc/current/best_practices/business-logic.html 27 | * 28 | * The AppBundle is an application bundle that is already created when you install 29 | * Symfony. Using AppBundle to start developing your Symfony application is 30 | * considered a good practice, but you can also split your application code into 31 | * as many bundles as you want. 32 | * 33 | * @author Ryan Weaver 34 | * @author Javier Eguiluz 35 | */ 36 | class AppBundle extends Bundle 37 | { 38 | // At first it's common to leave this class empty, but when the application grows, 39 | // you may need to add some initialization code in the boot() method. 40 | // 41 | // Checkout the Symfony\Component\HttpKernel\Bundle\Bundle class to see all 42 | // the available methods for bundles. 43 | } 44 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/translations/validators.it.xliff: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | post.blank_summary 7 | Da' una descrizione al tuo post! 8 | 9 | 10 | post.blank_content 11 | Da' un contenuto al tuo post! 12 | 13 | 14 | post.too_short_content 15 | Il contenuto del post è troppo breve (minimo {{ limit }} caratteri) 16 | 17 | 18 | comment.blank 19 | Per favore non lasciare in bianco il tuo commento! 20 | 21 | 22 | comment.too_short 23 | Il commento è troppo breve (minimo {{ limit }} caratteri) 24 | 25 | 26 | comment.too_long 27 | Il commento è troppo lungo (massimo {{ limit }} caratteri) 28 | 29 | 30 | comment.is_spam 31 | Il contenuto di questo commento è considerato come spam. 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/translations/validators.uk.xliff: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | post.blank_summary 7 | Введіть короткий зміст вашого запису! 8 | 9 | 10 | post.blank_content 11 | Ваш запис повинен містити хоч якийсь зміст! 12 | 13 | 14 | post.too_short_content 15 | Зміст запису занадто короткий (мінімум {{limit}} символів). 16 | 17 | 18 | comment.blank 19 | Будь ласка, не залишайте текст коментаря порожнім! 20 | 21 | 22 | comment.too_short 23 | Коментар занадто короткий, (мінімум {{limit}} символів). 24 | 25 | 26 | comment.too_long 27 | Коментар занадто довгий, (максимум {{limit}} символів). 28 | 29 | 30 | comment.is_spam 31 | Зміст цього коментаря було розцінено як спам. 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/translations/validators.ro.xliff: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | post.blank_summary 7 | Dă articolului tău un rezumat! 8 | 9 | 10 | post.blank_content 11 | Articolul ar trebui să aibe conținut! 12 | 13 | 14 | post.too_short_content 15 | Conţinutul articolului este prea scurt (minimum {{ limit }} caractere) 16 | 17 | 18 | comment.blank 19 | Te rugăm nu lăsa comentariul tău necompletat! 20 | 21 | 22 | comment.too_short 23 | Comentariul este prea scurt (minimum {{ limit }} caractere) 24 | 25 | 26 | comment.too_long 27 | Comentariul este prea lung (maximum {{ limit }} caractere) 28 | 29 | 30 | comment.is_spam 31 | Conţinutul acestui comentariu este considerat spam. 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /03-composed-application/app/src/AppBundle/Controller/SecurityController.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace AppBundle\Controller; 13 | 14 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; 15 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; 16 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; 17 | 18 | /** 19 | * Controller used to manage the application security. 20 | * See http://symfony.com/doc/current/cookbook/security/form_login_setup.html. 21 | * 22 | * @author Ryan Weaver 23 | * @author Javier Eguiluz 24 | */ 25 | class SecurityController extends Controller 26 | { 27 | /** 28 | * @Route("/login", name="security_login") 29 | */ 30 | public function loginAction() 31 | { 32 | $helper = $this->get('security.authentication_utils'); 33 | 34 | return $this->render('security/login.html.twig', [ 35 | // last username entered by the user (if any) 36 | 'last_username' => $helper->getLastUsername(), 37 | // last authentication error (if any) 38 | 'error' => $helper->getLastAuthenticationError(), 39 | ]); 40 | } 41 | 42 | /** 43 | * This is the route the user can use to logout. 44 | * 45 | * But, this will never be executed. Symfony will intercept this first 46 | * and handle the logout automatically. See logout in app/config/security.yml 47 | * 48 | * @Route("/logout", name="security_logout") 49 | */ 50 | public function logoutAction() 51 | { 52 | throw new \Exception('This should never be reached!'); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/translations/validators.pt_BR.xliff: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | post.blank_summary 7 | Informe um sumário para o seu post! 8 | 9 | 10 | post.blank_content 11 | Informe um conteúdo para o seu post! 12 | 13 | 14 | post.too_short_content 15 | O conteúdo do post está muito curto (mínimo de {{ limit }} caracteres) 16 | 17 | 18 | comment.blank 19 | Por favor, não deixe seu comentário vazio! 20 | 21 | 22 | comment.too_short 23 | O comentário está muito curto (mínimo de {{ limit }} caracteres) 24 | 25 | 26 | comment.too_long 27 | O comentário está muito grande (máximo de {{ limit }} caracteres) 28 | 29 | 30 | comment.is_spam 31 | O conteúdo desse comentário é considerado spam. 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /03-composed-application/app/app/config/services.yml: -------------------------------------------------------------------------------- 1 | services: 2 | # First we define some basic services to make these utilities available in 3 | # the entire application 4 | slugger: 5 | class: AppBundle\Utils\Slugger 6 | 7 | markdown: 8 | class: AppBundle\Utils\Markdown 9 | 10 | # These are the Twig extensions that create new filters and functions for 11 | # using them in the templates 12 | app.twig.app_extension: 13 | public: false 14 | class: AppBundle\Twig\AppExtension 15 | arguments: ['@markdown', '%app_locales%'] 16 | tags: 17 | - { name: twig.extension } 18 | 19 | app.twig.intl_extension: 20 | public: false 21 | class: Twig_Extensions_Extension_Intl 22 | tags: 23 | - { name: twig.extension } 24 | 25 | app.redirect_to_preferred_locale_listener: 26 | class: AppBundle\EventListener\RedirectToPreferredLocaleListener 27 | arguments: ['@router', '%app_locales%', '%locale%'] 28 | tags: 29 | - { name: kernel.event_listener, event: kernel.request, method: onKernelRequest } 30 | 31 | # Uncomment the following lines to define a service for the Post Doctrine repository. 32 | # It's not mandatory to create these services, but if you use repositories a lot, 33 | # these services simplify your code: 34 | # 35 | # app.post_repository: 36 | # class: Doctrine\ORM\EntityRepository 37 | # factory: ['@doctrine.orm.entity_manager', getRepository] 38 | # arguments: [AppBundle\Entity\Post] 39 | # 40 | # // traditional code inside a controller 41 | # $entityManager = $this->getDoctrine()->getManager(); 42 | # $posts = $entityManager->getRepository('AppBundle:Post')->findAll(); 43 | # 44 | # // same code using repository services 45 | # $posts = $this->get('app.post_repository')->findAll(); 46 | -------------------------------------------------------------------------------- /03-composed-application/app/src/CodeExplorerBundle/Resources/views/source_code.html.twig: -------------------------------------------------------------------------------- 1 |
    2 |

    3 | {{ 'help.show_code'|trans|raw }} 4 |

    5 | 6 | 9 | 10 | 35 |
    36 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/translations/validators.fr.xliff: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | post.blank_summary 7 | Veuillez donner un résumé à votre post. 8 | 9 | 10 | post.blank_content 11 | Veuillez donner un contenu à votre post. 12 | 13 | 14 | post.too_short_content 15 | Le contenu de votre post est trop court ({{ limit }} caractères minimum) 16 | 17 | 18 | comment.blank 19 | Veuillez ne pas laisser votre commentaire vide. 20 | 21 | 22 | comment.too_short 23 | Votre commentaire est trop court ({{ limit }} caractères minimum) 24 | 25 | 26 | comment.too_long 27 | Votre commentaire est trop long ({{ limit }} caractères maximum) 28 | 29 | 30 | comment.is_spam 31 | Le contenu de votre commentaire est considéré comme du spam. 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/translations/validators.ru.xliff: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | post.blank_summary 7 | Введите краткое содержание вашей записи! 8 | 9 | 10 | post.blank_content 11 | Ваша запись должна содержать хоть какое-то содержание! 12 | 13 | 14 | post.too_short_content 15 | Содержание записи слишком короткое (минимум {{ limit }} символов). 16 | 17 | 18 | comment.blank 19 | Пожалуйста, не оставляйте текст комментария пустым! 20 | 21 | 22 | comment.too_short 23 | Комментарий слишком короткий, (минимум {{ limit }} символов). 24 | 25 | 26 | comment.too_long 27 | Комментарий слишком длинный, (максимум {{ limit }} символов). 28 | 29 | 30 | comment.is_spam 31 | Содержание этого комментария было расценено как спам. 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/bootstrap/_alerts.scss: -------------------------------------------------------------------------------- 1 | // 2 | // Alerts 3 | // -------------------------------------------------- 4 | 5 | 6 | // Base styles 7 | // ------------------------- 8 | 9 | .alert { 10 | padding: $alert-padding; 11 | margin-bottom: $line-height-computed; 12 | border: 1px solid transparent; 13 | border-radius: $alert-border-radius; 14 | 15 | // Headings for larger alerts 16 | h4 { 17 | margin-top: 0; 18 | // Specified for the h4 to prevent conflicts of changing $headings-color 19 | color: inherit; 20 | } 21 | 22 | // Provide class for links that match alerts 23 | .alert-link { 24 | font-weight: $alert-link-font-weight; 25 | } 26 | 27 | // Improve alignment and spacing of inner content 28 | > p, 29 | > ul { 30 | margin-bottom: 0; 31 | } 32 | 33 | > p + p { 34 | margin-top: 5px; 35 | } 36 | } 37 | 38 | // Dismissible alerts 39 | // 40 | // Expand the right padding and account for the close button's positioning. 41 | 42 | .alert-dismissable, // The misspelled .alert-dismissable was deprecated in 3.2.0. 43 | .alert-dismissible { 44 | padding-right: ($alert-padding + 20); 45 | 46 | // Adjust close link position 47 | .close { 48 | position: relative; 49 | top: -2px; 50 | right: -21px; 51 | color: inherit; 52 | } 53 | } 54 | 55 | // Alternate styles 56 | // 57 | // Generate contextual modifier classes for colorizing the alert. 58 | 59 | .alert-success { 60 | @include alert-variant($alert-success-bg, $alert-success-border, $alert-success-text); 61 | } 62 | 63 | .alert-info { 64 | @include alert-variant($alert-info-bg, $alert-info-border, $alert-info-text); 65 | } 66 | 67 | .alert-warning { 68 | @include alert-variant($alert-warning-bg, $alert-warning-border, $alert-warning-text); 69 | } 70 | 71 | .alert-danger { 72 | @include alert-variant($alert-danger-bg, $alert-danger-border, $alert-danger-text); 73 | } 74 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/translations/validators.ca.xliff: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | post.blank_summary 7 | No és possible deixar buit el resum de l'article. 8 | 9 | 10 | post.blank_content 11 | No és possible deixar buit el contingut de l'article. 12 | 13 | 14 | post.too_short_content 15 | El contingut de l'article és massa curt ({{ limit }} caràcters com a mínim) 16 | 17 | 18 | comment.blank 19 | No és possible deixar buit el contingut del comentari. 20 | 21 | 22 | comment.too_short 23 | El comentari és massa curt ({{ limit }} caràcters com a mínim) 24 | 25 | 26 | comment.too_long 27 | El comentari és massa llarg ({{ limit }} caràcters com a màxim) 28 | 29 | 30 | comment.is_spam 31 | El contingut del comentari es considera spam. 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /03-composed-application/app/src/AppBundle/Form/CommentType.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace AppBundle\Form; 13 | 14 | use AppBundle\Entity\Comment; 15 | use Symfony\Component\Form\AbstractType; 16 | use Symfony\Component\Form\FormBuilderInterface; 17 | use Symfony\Component\OptionsResolver\OptionsResolver; 18 | 19 | /** 20 | * Defines the form used to create and manipulate blog comments. Although in this 21 | * case the form is trivial and we could build it inside the controller, a good 22 | * practice is to always define your forms as classes. 23 | * See http://symfony.com/doc/current/book/forms.html#creating-form-classes 24 | * 25 | * @author Ryan Weaver 26 | * @author Javier Eguiluz 27 | */ 28 | class CommentType extends AbstractType 29 | { 30 | /** 31 | * {@inheritdoc} 32 | */ 33 | public function buildForm(FormBuilderInterface $builder, array $options) 34 | { 35 | // By default, form fields include the 'required' attribute, which enables 36 | // the client-side form validation. This means that you can't test the 37 | // server-side validation errors from the browser. To temporarily disable 38 | // this validation, set the 'required' attribute to 'false': 39 | // 40 | // $builder->add('content', null, ['required' => false]); 41 | 42 | $builder 43 | ->add('content') 44 | ; 45 | } 46 | 47 | /** 48 | * {@inheritdoc} 49 | */ 50 | public function configureOptions(OptionsResolver $resolver) 51 | { 52 | $resolver->setDefaults([ 53 | 'data_class' => Comment::class, 54 | ]); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/translations/validators.es.xliff: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | post.blank_summary 7 | No es posible dejar el resumen del artículo vacío. 8 | 9 | 10 | post.blank_content 11 | No es posible dejar el contenido del artículo vacío. 12 | 13 | 14 | post.too_short_content 15 | El contenido del artículo es demasiado corto ({{ limit }} caracteres como mínimo) 16 | 17 | 18 | comment.blank 19 | No es posible dejar el contenido del comentario vacío. 20 | 21 | 22 | comment.too_short 23 | El comentario es demasiado corto ({{ limit }} caracteres como mínimo) 24 | 25 | 26 | comment.too_long 27 | El comentario es demasiado largo ({{ limit }} caracteres como máximo) 28 | 29 | 30 | comment.is_spam 31 | El contenido del comentario se considera spam. 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /03-composed-application/app/src/AppBundle/Form/Type/DateTimePickerType.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace AppBundle\Form\Type; 13 | 14 | use AppBundle\Utils\MomentFormatConverter; 15 | use Symfony\Component\Form\AbstractType; 16 | use Symfony\Component\Form\Extension\Core\Type\DateTimeType; 17 | use Symfony\Component\Form\FormInterface; 18 | use Symfony\Component\Form\FormView; 19 | use Symfony\Component\OptionsResolver\OptionsResolver; 20 | 21 | /** 22 | * Defines the custom form field type used to manipulate datetime values across 23 | * Bootstrap Date\Time Picker javascript plugin. 24 | * See http://symfony.com/doc/current/cookbook/form/create_custom_field_type.html 25 | * 26 | * @author Yonel Ceruto 27 | */ 28 | class DateTimePickerType extends AbstractType 29 | { 30 | /** 31 | * @var MomentFormatConverter 32 | */ 33 | private $formatConverter; 34 | 35 | public function __construct() 36 | { 37 | $this->formatConverter = new MomentFormatConverter(); 38 | } 39 | 40 | /** 41 | * {@inheritdoc} 42 | */ 43 | public function buildView(FormView $view, FormInterface $form, array $options) 44 | { 45 | $view->vars['attr']['data-date-format'] = $this->formatConverter->convert($options['format']); 46 | $view->vars['attr']['data-date-locale'] = \Locale::getDefault(); 47 | } 48 | 49 | /** 50 | * {@inheritdoc} 51 | */ 52 | public function configureOptions(OptionsResolver $resolver) 53 | { 54 | $resolver->setDefaults([ 55 | 'widget' => 'single_text', 56 | ]); 57 | } 58 | 59 | /** 60 | * {@inheritdoc} 61 | */ 62 | public function getParent() 63 | { 64 | return DateTimeType::class; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/translations/validators.cs.xliff: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | post.blank_summary 7 | Napište shrnutí příspěvku! 8 | 9 | 10 | post.too_short_content 11 | Příspěvek je příliš krátký (musí mít minimálně {{ limit }} znak)|Příspěvek je příliš krátký (musí mít minimálně {{ limit }} znaky)|Příspěvek je příliš krátký (musí mít minimálně {{ limit }} znaků) 12 | 13 | 14 | comment.blank 15 | Prosím, napište text komentáře! 16 | 17 | 18 | comment.too_short 19 | Komentář je příliš krátký (musí mít minimálně {{ limit }} znak)|Komentář je příliš krátký (musí mít minimálně {{ limit }} znaky)|Komentář je příliš krátký (musí mít minimálně {{ limit }} znaků) 20 | 21 | 22 | comment.too_long 23 | Komentář je příliš dlouhý (musí mít maximálně {{ limit }} znak)|Komentář je příliš dlouhý (musí mít maximálně {{ limit }} znaky)|Komentář je příliš dlouhý (musí mít maximálně {{ limit }} znaků) 24 | 25 | 26 | comment.is_spam 27 | Obsah tohoto komentáře je považován za spam. 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/views/admin/blog/show.html.twig: -------------------------------------------------------------------------------- 1 | {% extends 'admin/layout.html.twig' %} 2 | 3 | {% block body_id 'admin_post_show' %} 4 | 5 | {% block main %} 6 |

    {{ post.title }}

    7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | {# it's not mandatory to set the timezone in localizeddate(). This is done to 25 | avoid errors when the 'intl' PHP extension is not available and the application 26 | is forced to use the limited "intl polyfill", which only supports UTC and GMT #} 27 | 28 | 29 | 30 |
    {{ 'label.summary'|trans }}{{ post.summary|md2html }}
    {{ 'label.content'|trans }}{{ post.content|md2html }}
    {{ 'label.author'|trans }}

    {{ post.authorEmail }}

    {{ 'label.published_at'|trans }}

    {{ post.publishedAt|localizeddate('long', 'medium', null, 'UTC') }}

    31 | {% endblock %} 32 | 33 | {% block sidebar %} 34 | 39 | 40 |
    41 | {{ include('admin/blog/_form.html.twig', { 42 | form: delete_form, 43 | button_label: 'action.delete_post'|trans, 44 | button_css: 'btn btn-lg btn-block btn-danger', 45 | show_confirmation: true, 46 | }, with_context = false) }} 47 |
    48 | 49 | {{ show_source_code(_self) }} 50 | {% endblock %} 51 | -------------------------------------------------------------------------------- /03-composed-application/app/web/app.php: -------------------------------------------------------------------------------- 1 | unregister(); 28 | // $apcLoader->register(true); 29 | 30 | $kernel = new AppKernel('prod', false); 31 | $kernel->loadClassCache(); 32 | 33 | // When using the HTTP Cache to improve application performance, the application 34 | // kernel is wrapped by the AppCache class to activate the built-in reverse proxy. 35 | // See http://symfony.com/doc/current/book/http_cache.html#symfony-reverse-proxy 36 | $kernel = new AppCache($kernel); 37 | 38 | // If you use HTTP Cache and your application relies on the _method request parameter 39 | // to get the intended HTTP method, uncomment this line. 40 | // See http://symfony.com/doc/current/reference/configuration/framework.html#http-method-override 41 | Request::enableHttpMethodParameterOverride(); 42 | 43 | $request = Request::createFromGlobals(); 44 | $response = $kernel->handle($request); 45 | $response->send(); 46 | 47 | $kernel->terminate($request, $response); 48 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/css/highlight-solarized-light.css: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Orginal Style from ethanschoonover.com/solarized (c) Jeremy Hull 4 | 5 | */ 6 | 7 | .hljs { 8 | display: block; 9 | overflow-x: auto; 10 | padding: 0.5em; 11 | background: #fdf6e3; 12 | color: #657b83; 13 | -webkit-text-size-adjust: none; 14 | } 15 | 16 | .hljs-comment, 17 | .diff .hljs-header, 18 | .hljs-doctype, 19 | .hljs-pi, 20 | .lisp .hljs-string, 21 | .hljs-javadoc { 22 | color: #93a1a1; 23 | } 24 | 25 | /* Solarized Green */ 26 | .hljs-keyword, 27 | .hljs-winutils, 28 | .method, 29 | .hljs-addition, 30 | .css .hljs-tag, 31 | .hljs-request, 32 | .hljs-status, 33 | .nginx .hljs-title { 34 | color: #859900; 35 | } 36 | 37 | /* Solarized Cyan */ 38 | .hljs-number, 39 | .hljs-command, 40 | .hljs-string, 41 | .hljs-tag .hljs-value, 42 | .hljs-rules .hljs-value, 43 | .hljs-phpdoc, 44 | .hljs-dartdoc, 45 | .tex .hljs-formula, 46 | .hljs-regexp, 47 | .hljs-hexcolor, 48 | .hljs-link_url { 49 | color: #2aa198; 50 | } 51 | 52 | /* Solarized Blue */ 53 | .hljs-title, 54 | .hljs-localvars, 55 | .hljs-chunk, 56 | .hljs-decorator, 57 | .hljs-built_in, 58 | .hljs-identifier, 59 | .vhdl .hljs-literal, 60 | .hljs-id, 61 | .css .hljs-function { 62 | color: #268bd2; 63 | } 64 | 65 | /* Solarized Yellow */ 66 | .hljs-attribute, 67 | .hljs-variable, 68 | .lisp .hljs-body, 69 | .smalltalk .hljs-number, 70 | .hljs-constant, 71 | .hljs-class .hljs-title, 72 | .hljs-parent, 73 | .hljs-type, 74 | .hljs-link_reference { 75 | color: #b58900; 76 | } 77 | 78 | /* Solarized Orange */ 79 | .hljs-preprocessor, 80 | .hljs-preprocessor .hljs-keyword, 81 | .hljs-pragma, 82 | .hljs-shebang, 83 | .hljs-symbol, 84 | .hljs-symbol .hljs-string, 85 | .diff .hljs-change, 86 | .hljs-special, 87 | .hljs-attr_selector, 88 | .hljs-subst, 89 | .hljs-cdata, 90 | .css .hljs-pseudo, 91 | .hljs-header { 92 | color: #cb4b16; 93 | } 94 | 95 | /* Solarized Red */ 96 | .hljs-deletion, 97 | .hljs-important { 98 | color: #dc322f; 99 | } 100 | 101 | /* Solarized Violet */ 102 | .hljs-link_label { 103 | color: #6c71c4; 104 | } 105 | 106 | .tex .hljs-formula { 107 | background: #eee8d5; 108 | } 109 | -------------------------------------------------------------------------------- /03-composed-application/app/app/config/security.yml: -------------------------------------------------------------------------------- 1 | security: 2 | encoders: 3 | # Our user class and the algorithm we'll use to encode passwords 4 | # http://symfony.com/doc/current/book/security.html#encoding-the-user-s-password 5 | AppBundle\Entity\User: bcrypt 6 | 7 | providers: 8 | # in this example, users are stored via Doctrine in the database 9 | # To see the users at src/AppBundle/DataFixtures/ORM/LoadFixtures.php 10 | # To load users from somewhere else: http://symfony.com/doc/current/cookbook/security/custom_provider.html 11 | database_users: 12 | entity: { class: AppBundle:User, property: username } 13 | 14 | # http://symfony.com/doc/current/book/security.html#firewalls-authentication 15 | firewalls: 16 | secured_area: 17 | # this firewall applies to all URLs 18 | pattern: ^/ 19 | 20 | # but the firewall does not require login on every page 21 | # denying access is done in access_control or in your controllers 22 | anonymous: true 23 | 24 | # This allows the user to login by submitting a username and password 25 | # Reference: http://symfony.com/doc/current/cookbook/security/form_login_setup.html 26 | form_login: 27 | # The route name that the login form submits to 28 | check_path: security_login 29 | # The name of the route where the login form lives 30 | # When the user tries to access a protected page, they are redirected here 31 | login_path: security_login 32 | # Secure the login form against CSRF 33 | # Reference: http://symfony.com/doc/current/cookbook/security/csrf_in_login_form.html 34 | csrf_token_generator: security.csrf.token_manager 35 | 36 | logout: 37 | # The route name the user can go to in order to logout 38 | path: security_logout 39 | # The name of the route to redirect to after logging out 40 | target: homepage 41 | 42 | access_control: 43 | # this is a catch-all for the admin area 44 | # additional security lives in the controllers 45 | - { path: '^/(%app_locales%)/admin', roles: ROLE_ADMIN } 46 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/bootstrap/_progress-bars.scss: -------------------------------------------------------------------------------- 1 | // 2 | // Progress bars 3 | // -------------------------------------------------- 4 | 5 | 6 | // Bar animations 7 | // ------------------------- 8 | 9 | // WebKit 10 | @-webkit-keyframes progress-bar-stripes { 11 | from { background-position: 40px 0; } 12 | to { background-position: 0 0; } 13 | } 14 | 15 | // Spec and IE10+ 16 | @keyframes progress-bar-stripes { 17 | from { background-position: 40px 0; } 18 | to { background-position: 0 0; } 19 | } 20 | 21 | 22 | // Bar itself 23 | // ------------------------- 24 | 25 | // Outer container 26 | .progress { 27 | overflow: hidden; 28 | height: $line-height-computed; 29 | margin-bottom: $line-height-computed; 30 | background-color: $progress-bg; 31 | border-radius: $progress-border-radius; 32 | @include box-shadow(inset 0 1px 2px rgba(0,0,0,.1)); 33 | } 34 | 35 | // Bar of progress 36 | .progress-bar { 37 | float: left; 38 | width: 0%; 39 | height: 100%; 40 | font-size: $font-size-small; 41 | line-height: $line-height-computed; 42 | color: $progress-bar-color; 43 | text-align: center; 44 | background-color: $progress-bar-bg; 45 | @include box-shadow(inset 0 -1px 0 rgba(0,0,0,.15)); 46 | @include transition(width .6s ease); 47 | } 48 | 49 | // Striped bars 50 | // 51 | // `.progress-striped .progress-bar` is deprecated as of v3.2.0 in favor of the 52 | // `.progress-bar-striped` class, which you just add to an existing 53 | // `.progress-bar`. 54 | .progress-striped .progress-bar, 55 | .progress-bar-striped { 56 | @include gradient-striped; 57 | background-size: 40px 40px; 58 | } 59 | 60 | // Call animation for the active one 61 | // 62 | // `.progress.active .progress-bar` is deprecated as of v3.2.0 in favor of the 63 | // `.progress-bar.active` approach. 64 | .progress.active .progress-bar, 65 | .progress-bar.active { 66 | @include animation(progress-bar-stripes 2s linear infinite); 67 | } 68 | 69 | 70 | // Variations 71 | // ------------------------- 72 | 73 | .progress-bar-success { 74 | @include progress-bar-variant($progress-bar-success-bg); 75 | } 76 | 77 | .progress-bar-info { 78 | @include progress-bar-variant($progress-bar-info-bg); 79 | } 80 | 81 | .progress-bar-warning { 82 | @include progress-bar-variant($progress-bar-warning-bg); 83 | } 84 | 85 | .progress-bar-danger { 86 | @include progress-bar-variant($progress-bar-danger-bg); 87 | } 88 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/bootstrap/_pagination.scss: -------------------------------------------------------------------------------- 1 | // 2 | // Pagination (multiple pages) 3 | // -------------------------------------------------- 4 | .pagination { 5 | display: inline-block; 6 | padding-left: 0; 7 | margin: $line-height-computed 0; 8 | border-radius: $border-radius-base; 9 | 10 | > li { 11 | display: inline; // Remove list-style and block-level defaults 12 | > a, 13 | > span { 14 | position: relative; 15 | float: left; // Collapse white-space 16 | padding: $padding-base-vertical $padding-base-horizontal; 17 | line-height: $line-height-base; 18 | text-decoration: none; 19 | color: $pagination-color; 20 | background-color: $pagination-bg; 21 | border: 1px solid $pagination-border; 22 | margin-left: -1px; 23 | } 24 | &:first-child { 25 | > a, 26 | > span { 27 | margin-left: 0; 28 | @include border-left-radius($border-radius-base); 29 | } 30 | } 31 | &:last-child { 32 | > a, 33 | > span { 34 | @include border-right-radius($border-radius-base); 35 | } 36 | } 37 | } 38 | 39 | > li > a, 40 | > li > span { 41 | &:hover, 42 | &:focus { 43 | color: $pagination-hover-color; 44 | background-color: $pagination-hover-bg; 45 | border-color: $pagination-hover-border; 46 | } 47 | } 48 | 49 | > .active > a, 50 | > .active > span { 51 | &, 52 | &:hover, 53 | &:focus { 54 | z-index: 2; 55 | color: $pagination-active-color; 56 | background-color: $pagination-active-bg; 57 | border-color: $pagination-active-border; 58 | cursor: default; 59 | } 60 | } 61 | 62 | > .disabled { 63 | > span, 64 | > span:hover, 65 | > span:focus, 66 | > a, 67 | > a:hover, 68 | > a:focus { 69 | color: $pagination-disabled-color; 70 | background-color: $pagination-disabled-bg; 71 | border-color: $pagination-disabled-border; 72 | cursor: $cursor-disabled; 73 | } 74 | } 75 | } 76 | 77 | // Sizing 78 | // -------------------------------------------------- 79 | 80 | // Large 81 | .pagination-lg { 82 | @include pagination-size($padding-large-vertical, $padding-large-horizontal, $font-size-large, $border-radius-large); 83 | } 84 | 85 | // Small 86 | .pagination-sm { 87 | @include pagination-size($padding-small-vertical, $padding-small-horizontal, $font-size-small, $border-radius-small); 88 | } 89 | -------------------------------------------------------------------------------- /03-composed-application/app/tests/AppBundle/Controller/Admin/BlogControllerTest.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace Tests\AppBundle\Controller\Admin; 13 | 14 | use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; 15 | use Symfony\Component\HttpFoundation\Response; 16 | 17 | /** 18 | * Functional test for the controllers defined inside the BlogController used 19 | * for managing the blog in the backend. 20 | * See http://symfony.com/doc/current/book/testing.html#functional-tests 21 | * 22 | * Whenever you test resources protected by a firewall, consider using the 23 | * technique explained in: 24 | * http://symfony.com/doc/current/cookbook/testing/http_authentication.html 25 | * 26 | * Execute the application tests using this command (requires PHPUnit to be installed): 27 | * 28 | * $ cd your-symfony-project/ 29 | * $ phpunit -c app 30 | * 31 | */ 32 | class BlogControllerTest extends WebTestCase 33 | { 34 | public function testRegularUsersCannotAccessToTheBackend() 35 | { 36 | $client = static::createClient([], [ 37 | 'PHP_AUTH_USER' => 'john_user', 38 | 'PHP_AUTH_PW' => 'kitten', 39 | ]); 40 | 41 | $client->request('GET', '/en/admin/post/'); 42 | 43 | $this->assertEquals(Response::HTTP_FORBIDDEN, $client->getResponse()->getStatusCode()); 44 | } 45 | 46 | public function testAdministratorUsersCanAccessToTheBackend() 47 | { 48 | $client = static::createClient([], [ 49 | 'PHP_AUTH_USER' => 'anna_admin', 50 | 'PHP_AUTH_PW' => 'kitten', 51 | ]); 52 | 53 | $client->request('GET', '/en/admin/post/'); 54 | 55 | $this->assertEquals(Response::HTTP_OK, $client->getResponse()->getStatusCode()); 56 | } 57 | 58 | public function testIndex() 59 | { 60 | $client = static::createClient([], [ 61 | 'PHP_AUTH_USER' => 'anna_admin', 62 | 'PHP_AUTH_PW' => 'kitten', 63 | ]); 64 | 65 | $crawler = $client->request('GET', '/en/admin/post/'); 66 | 67 | $this->assertCount( 68 | 30, 69 | $crawler->filter('body#admin_post_index #main tbody tr'), 70 | 'The backend homepage displays all the available posts.' 71 | ); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /03-composed-application/app/src/AppBundle/Form/PostType.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace AppBundle\Form; 13 | 14 | use AppBundle\Entity\Post; 15 | use AppBundle\Form\Type\DateTimePickerType; 16 | use Symfony\Component\Form\AbstractType; 17 | use Symfony\Component\Form\Extension\Core\Type\TextareaType; 18 | use Symfony\Component\Form\FormBuilderInterface; 19 | use Symfony\Component\OptionsResolver\OptionsResolver; 20 | 21 | /** 22 | * Defines the form used to create and manipulate blog posts. 23 | * 24 | * @author Ryan Weaver 25 | * @author Javier Eguiluz 26 | */ 27 | class PostType extends AbstractType 28 | { 29 | /** 30 | * {@inheritdoc} 31 | */ 32 | public function buildForm(FormBuilderInterface $builder, array $options) 33 | { 34 | // For the full reference of options defined by each form field type 35 | // see http://symfony.com/doc/current/reference/forms/types.html 36 | 37 | // By default, form fields include the 'required' attribute, which enables 38 | // the client-side form validation. This means that you can't test the 39 | // server-side validation errors from the browser. To temporarily disable 40 | // this validation, set the 'required' attribute to 'false': 41 | // 42 | // $builder->add('title', null, ['required' => false, ...]); 43 | 44 | $builder 45 | ->add('title', null, [ 46 | 'attr' => ['autofocus' => true], 47 | 'label' => 'label.title', 48 | ]) 49 | ->add('summary', TextareaType::class, [ 50 | 'label' => 'label.summary', 51 | ]) 52 | ->add('content', null, [ 53 | 'attr' => ['rows' => 20], 54 | 'label' => 'label.content', 55 | ]) 56 | ->add('authorEmail', null, [ 57 | 'label' => 'label.author_email', 58 | ]) 59 | ->add('publishedAt', DateTimePickerType::class, [ 60 | 'label' => 'label.published_at', 61 | ]) 62 | ; 63 | } 64 | 65 | /** 66 | * {@inheritdoc} 67 | */ 68 | public function configureOptions(OptionsResolver $resolver) 69 | { 70 | $resolver->setDefaults([ 71 | 'data_class' => Post::class, 72 | ]); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/views/admin/blog/index.html.twig: -------------------------------------------------------------------------------- 1 | {% extends 'admin/layout.html.twig' %} 2 | 3 | {% block body_id 'admin_post_index' %} 4 | 5 | {% block main %} 6 |

    {{ 'title.post_list'|trans }}

    7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | {% for post in posts %} 19 | 20 | 21 | 22 | {# it's not mandatory to set the timezone in localizeddate(). This is done to 23 | avoid errors when the 'intl' PHP extension is not available and the application 24 | is forced to use the limited "intl polyfill", which only supports UTC and GMT #} 25 | 26 | 39 | 40 | {% else %} 41 | 42 | 43 | 44 | {% endfor %} 45 | 46 |
    {{ 'label.title'|trans }} {{ 'label.author'|trans }} {{ 'label.published_at'|trans }} {{ 'label.actions'|trans }}
    {{ post.title }}{{ post.authorEmail }}{% if post.publishedAt %}{{ post.publishedAt|localizeddate('short', 'short', null, 'UTC') }}{% endif %} 27 |
    28 | 29 | {{ 'action.show'|trans }} 30 | 31 | 32 | {% if post.isAuthor(app.user) %} 33 | 34 | {{ 'action.edit'|trans }} 35 | 36 | {% endif %} 37 |
    38 |
    {{ 'post.no_posts_found'|trans }}
    47 | {% endblock %} 48 | 49 | {% block sidebar %} 50 | 55 | 56 | {{ parent() }} 57 | 58 | {{ show_source_code(_self) }} 59 | {% endblock %} 60 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/bootstrap/mixins/_grid-framework.scss: -------------------------------------------------------------------------------- 1 | // Framework grid generation 2 | // 3 | // Used only by Bootstrap to generate the correct number of grid classes given 4 | // any value of `$grid-columns`. 5 | 6 | // [converter] This is defined recursively in LESS, but Sass supports real loops 7 | @mixin make-grid-columns($i: 1, $list: ".col-xs-#{$i}, .col-sm-#{$i}, .col-md-#{$i}, .col-lg-#{$i}") { 8 | @for $i from (1 + 1) through $grid-columns { 9 | $list: "#{$list}, .col-xs-#{$i}, .col-sm-#{$i}, .col-md-#{$i}, .col-lg-#{$i}"; 10 | } 11 | #{$list} { 12 | position: relative; 13 | // Prevent columns from collapsing when empty 14 | min-height: 1px; 15 | // Inner gutter via padding 16 | padding-left: ($grid-gutter-width / 2); 17 | padding-right: ($grid-gutter-width / 2); 18 | } 19 | } 20 | 21 | 22 | // [converter] This is defined recursively in LESS, but Sass supports real loops 23 | @mixin float-grid-columns($class, $i: 1, $list: ".col-#{$class}-#{$i}") { 24 | @for $i from (1 + 1) through $grid-columns { 25 | $list: "#{$list}, .col-#{$class}-#{$i}"; 26 | } 27 | #{$list} { 28 | float: left; 29 | } 30 | } 31 | 32 | 33 | @mixin calc-grid-column($index, $class, $type) { 34 | @if ($type == width) and ($index > 0) { 35 | .col-#{$class}-#{$index} { 36 | width: percentage(($index / $grid-columns)); 37 | } 38 | } 39 | @if ($type == push) and ($index > 0) { 40 | .col-#{$class}-push-#{$index} { 41 | left: percentage(($index / $grid-columns)); 42 | } 43 | } 44 | @if ($type == push) and ($index == 0) { 45 | .col-#{$class}-push-0 { 46 | left: auto; 47 | } 48 | } 49 | @if ($type == pull) and ($index > 0) { 50 | .col-#{$class}-pull-#{$index} { 51 | right: percentage(($index / $grid-columns)); 52 | } 53 | } 54 | @if ($type == pull) and ($index == 0) { 55 | .col-#{$class}-pull-0 { 56 | right: auto; 57 | } 58 | } 59 | @if ($type == offset) { 60 | .col-#{$class}-offset-#{$index} { 61 | margin-left: percentage(($index / $grid-columns)); 62 | } 63 | } 64 | } 65 | 66 | // [converter] This is defined recursively in LESS, but Sass supports real loops 67 | @mixin loop-grid-columns($columns, $class, $type) { 68 | @for $i from 0 through $columns { 69 | @include calc-grid-column($i, $class, $type); 70 | } 71 | } 72 | 73 | 74 | // Create grid for specific class 75 | @mixin make-grid($class) { 76 | @include float-grid-columns($class); 77 | @include loop-grid-columns($grid-columns, $class, width); 78 | @include loop-grid-columns($grid-columns, $class, pull); 79 | @include loop-grid-columns($grid-columns, $class, push); 80 | @include loop-grid-columns($grid-columns, $class, offset); 81 | } 82 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/bootstrap/_print.scss: -------------------------------------------------------------------------------- 1 | /*! Source: https://github.com/h5bp/html5-boilerplate/blob/master/src/css/main.css */ 2 | 3 | // ========================================================================== 4 | // Print styles. 5 | // Inlined to avoid the additional HTTP request: h5bp.com/r 6 | // ========================================================================== 7 | 8 | @media print { 9 | *, 10 | *:before, 11 | *:after { 12 | background: transparent !important; 13 | color: #000 !important; // Black prints faster: h5bp.com/s 14 | box-shadow: none !important; 15 | text-shadow: none !important; 16 | } 17 | 18 | a, 19 | a:visited { 20 | text-decoration: underline; 21 | } 22 | 23 | a[href]:after { 24 | content: " (" attr(href) ")"; 25 | } 26 | 27 | abbr[title]:after { 28 | content: " (" attr(title) ")"; 29 | } 30 | 31 | // Don't show links that are fragment identifiers, 32 | // or use the `javascript:` pseudo protocol 33 | a[href^="#"]:after, 34 | a[href^="javascript:"]:after { 35 | content: ""; 36 | } 37 | 38 | pre, 39 | blockquote { 40 | border: 1px solid #999; 41 | page-break-inside: avoid; 42 | } 43 | 44 | thead { 45 | display: table-header-group; // h5bp.com/t 46 | } 47 | 48 | tr, 49 | img { 50 | page-break-inside: avoid; 51 | } 52 | 53 | img { 54 | max-width: 100% !important; 55 | } 56 | 57 | p, 58 | h2, 59 | h3 { 60 | orphans: 3; 61 | widows: 3; 62 | } 63 | 64 | h2, 65 | h3 { 66 | page-break-after: avoid; 67 | } 68 | 69 | // Bootstrap specific changes start 70 | // 71 | // Chrome (OSX) fix for https://github.com/twbs/bootstrap/issues/11245 72 | // Once fixed, we can just straight up remove this. 73 | select { 74 | background: #fff !important; 75 | } 76 | 77 | // Bootstrap components 78 | .navbar { 79 | display: none; 80 | } 81 | .btn, 82 | .dropup > .btn { 83 | > .caret { 84 | border-top-color: #000 !important; 85 | } 86 | } 87 | .label { 88 | border: 1px solid #000; 89 | } 90 | 91 | .table { 92 | border-collapse: collapse !important; 93 | 94 | td, 95 | th { 96 | background-color: #fff !important; 97 | } 98 | } 99 | .table-bordered { 100 | th, 101 | td { 102 | border: 1px solid #ddd !important; 103 | } 104 | } 105 | 106 | // Bootstrap specific changes end 107 | } 108 | -------------------------------------------------------------------------------- /03-composed-application/app/tests/AppBundle/Controller/DefaultControllerTest.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace Tests\AppBundle\Controller; 13 | 14 | use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; 15 | 16 | /** 17 | * Functional test that implements a "smoke test" of all the public and secure 18 | * URLs of the application. 19 | * See http://symfony.com/doc/current/best_practices/tests.html#functional-tests. 20 | * 21 | * Execute the application tests using this command (requires PHPUnit to be installed): 22 | * 23 | * $ cd your-symfony-project/ 24 | * $ phpunit -c app 25 | * 26 | */ 27 | class DefaultControllerTest extends WebTestCase 28 | { 29 | /** 30 | * PHPUnit's data providers allow to execute the same tests repeated times 31 | * using a different set of data each time. 32 | * See http://symfony.com/doc/current/cookbook/form/unit_testing.html#testing-against-different-sets-of-data. 33 | * 34 | * @dataProvider getPublicUrls 35 | */ 36 | public function testPublicUrls($url) 37 | { 38 | $client = self::createClient(); 39 | $client->request('GET', $url); 40 | 41 | $this->assertTrue( 42 | $client->getResponse()->isSuccessful(), 43 | sprintf('The %s public URL loads correctly.', $url) 44 | ); 45 | } 46 | 47 | /** 48 | * The application contains a lot of secure URLs which shouldn't be 49 | * publicly accessible. This tests ensures that whenever a user tries to 50 | * access one of those pages, a redirection to the login form is performed. 51 | * 52 | * @dataProvider getSecureUrls 53 | */ 54 | public function testSecureUrls($url) 55 | { 56 | $client = self::createClient(); 57 | $client->request('GET', $url); 58 | 59 | $this->assertTrue($client->getResponse()->isRedirect()); 60 | 61 | $this->assertEquals( 62 | 'http://localhost/en/login', 63 | $client->getResponse()->getTargetUrl(), 64 | sprintf('The %s secure URL redirects to the login form.', $url) 65 | ); 66 | } 67 | 68 | public function getPublicUrls() 69 | { 70 | yield ['/']; 71 | yield ['/en/blog/']; 72 | yield ['/en/blog/posts/morbi-tempus-commodo-mattis']; 73 | yield ['/en/login']; 74 | } 75 | 76 | public function getSecureUrls() 77 | { 78 | yield ['/en/admin/post/']; 79 | yield ['/en/admin/post/new']; 80 | yield ['/en/admin/post/1']; 81 | yield ['/en/admin/post/1/edit']; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /03-composed-application/app/web/.htaccess: -------------------------------------------------------------------------------- 1 | # Use the front controller as index file. It serves as a fallback solution when 2 | # every other rewrite/redirect fails (e.g. in an aliased environment without 3 | # mod_rewrite). Additionally, this reduces the matching process for the 4 | # start page (path "/") because otherwise Apache will apply the rewriting rules 5 | # to each configured DirectoryIndex file (e.g. index.php, index.html, index.pl). 6 | DirectoryIndex app.php 7 | 8 | 9 | RewriteEngine On 10 | 11 | # Determine the RewriteBase automatically and set it as environment variable. 12 | # If you are using Apache aliases to do mass virtual hosting or installed the 13 | # project in a subdirectory, the base path will be prepended to allow proper 14 | # resolution of the app.php file and to redirect to the correct URI. It will 15 | # work in environments without path prefix as well, providing a safe, one-size 16 | # fits all solution. But as you do not need it in this case, you can comment 17 | # the following 2 lines to eliminate the overhead. 18 | RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$ 19 | RewriteRule ^(.*) - [E=BASE:%1] 20 | 21 | # Redirect to URI without front controller to prevent duplicate content 22 | # (with and without `/app.php`). Only do this redirect on the initial 23 | # rewrite by Apache and not on subsequent cycles. Otherwise we would get an 24 | # endless redirect loop (request -> rewrite to front controller -> 25 | # redirect -> request -> ...). 26 | # So in case you get a "too many redirects" error or you always get redirected 27 | # to the start page because your Apache does not expose the REDIRECT_STATUS 28 | # environment variable, you have 2 choices: 29 | # - disable this feature by commenting the following 2 lines or 30 | # - use Apache >= 2.3.9 and replace all L flags by END flags and remove the 31 | # following RewriteCond (best solution) 32 | RewriteCond %{ENV:REDIRECT_STATUS} ^$ 33 | RewriteRule ^app\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L] 34 | 35 | # If the requested filename exists, simply serve it. 36 | # We only want to let Apache serve files and not directories. 37 | RewriteCond %{REQUEST_FILENAME} -f 38 | RewriteRule .? - [L] 39 | 40 | # Rewrite all other queries to the front controller. 41 | RewriteRule .? %{ENV:BASE}/app.php [L] 42 | 43 | 44 | 45 | 46 | # When mod_rewrite is not available, we instruct a temporary redirect of 47 | # the start page to the front controller explicitly so that the website 48 | # and the generated links can still be used. 49 | RedirectMatch 302 ^/$ /app.php/ 50 | # RedirectTemp cannot be used instead 51 | 52 | 53 | -------------------------------------------------------------------------------- /03-composed-application/app/app/AppKernel.php: -------------------------------------------------------------------------------- 1 | getEnvironment(), ['dev', 'test'])) { 40 | $bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle(); 41 | $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle(); 42 | $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle(); 43 | $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle(); 44 | } 45 | 46 | return $bundles; 47 | } 48 | 49 | public function getRootDir() 50 | { 51 | return __DIR__; 52 | } 53 | 54 | public function getCacheDir() 55 | { 56 | return dirname(__DIR__).'/var/cache/'.$this->getEnvironment(); 57 | } 58 | 59 | public function getLogDir() 60 | { 61 | return dirname(__DIR__).'/var/logs'; 62 | } 63 | 64 | public function registerContainerConfiguration(LoaderInterface $loader) 65 | { 66 | $loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml'); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /03-composed-application/app/README.md: -------------------------------------------------------------------------------- 1 | Symfony Demo Application 2 | ======================== 3 | 4 | The "Symfony Demo Application" is a reference application created to show how 5 | to develop Symfony applications following the recommended best practices. 6 | 7 | [![Build Status](https://travis-ci.org/symfony/symfony-demo.svg?branch=master)](https://travis-ci.org/symfony/symfony-demo) 8 | 9 | Requirements 10 | ------------ 11 | 12 | * PHP 5.5.9 or higher; 13 | * PDO-SQLite PHP extension enabled; 14 | * and the [usual Symfony application requirements](http://symfony.com/doc/current/reference/requirements.html). 15 | 16 | If unsure about meeting these requirements, download the demo application and 17 | browse the `http://localhost:8000/config.php` script to get more detailed 18 | information. 19 | 20 | Installation 21 | ------------ 22 | 23 | [![Deploy](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy) 24 | 25 | First, install the [Symfony Installer](https://github.com/symfony/symfony-installer) 26 | if you haven't already. Then, install the Symfony Demo Application executing 27 | this command anywhere in your system: 28 | 29 | ```bash 30 | $ symfony demo 31 | 32 | # if you're using Windows: 33 | $ php symfony demo 34 | ``` 35 | 36 | If the `demo` command is not available, update your Symfony Installer to the 37 | most recent version executing the `symfony self-update` command. 38 | 39 | > **NOTE** 40 | > 41 | > If you can't use the Symfony Installer, download and install the demo 42 | > application using Git and Composer: 43 | > 44 | > $ git clone https://github.com/symfony/symfony-demo 45 | > $ cd symfony-demo/ 46 | > $ composer install --no-interaction 47 | 48 | Usage 49 | ----- 50 | 51 | There is no need to configure a virtual host in your web server to access the application. 52 | Just use the built-in web server: 53 | 54 | ```bash 55 | $ cd symfony-demo/ 56 | $ php bin/console server:run 57 | ``` 58 | 59 | This command will start a web server for the Symfony application. Now you can 60 | access the application in your browser at . You can 61 | stop the built-in web server by pressing `Ctrl + C` while you're in the 62 | terminal. 63 | 64 | > **NOTE** 65 | > 66 | > If you want to use a fully-featured web server (like Nginx or Apache) to run 67 | > Symfony Demo application, configure it to point at the `web/` directory of the project. 68 | > For more details, see: 69 | > http://symfony.com/doc/current/cookbook/configuration/web_server_configuration.html 70 | 71 | Troubleshooting 72 | --------------- 73 | 74 | The current Symfony Demo application uses Symfony 3.x version. If you want to 75 | use the legacy Symfony 2.8 version, clone the Git repository and checkout the 76 | `v0.8.4` tag, which is the last one compatible with Symfony 2.8: 77 | 78 | ```bash 79 | $ git clone https://github.com/symfony/symfony-demo 80 | $ cd symfony-demo/ 81 | $ git checkout tags/v0.8.4 -b v0.8.4 82 | $ composer install 83 | ``` 84 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/views/blog/post_show.html.twig: -------------------------------------------------------------------------------- 1 | {% extends 'base.html.twig' %} 2 | 3 | {% block body_id 'blog_post_show' %} 4 | 5 | {% block main %} 6 |

    {{ post.title }}

    7 | 8 | {{ post.content|md2html }} 9 | 10 |
    11 | {# The 'IS_AUTHENTICATED_FULLY' role ensures that the user has entered 12 | his/her credentials (login + password) during this session. If he/she 13 | is automatically logged via the 'Remember Me' functionality, he/she won't 14 | be able to add a comment. 15 | See http://symfony.com/doc/current/cookbook/security/remember_me.html#forcing-the-user-to-re-authenticate-before-accessing-certain-resources 16 | #} 17 | {% if is_granted('IS_AUTHENTICATED_FULLY') %} 18 | {{ render(controller('AppBundle:Blog:commentForm', { 'id': post.id })) }} 19 | {% else %} 20 |

    21 | 22 | {{ 'action.sign_in'|trans }} 23 | 24 | {{ 'post.to_publish_a_comment'|trans }} 25 |

    26 | {% endif %} 27 |
    28 | 29 |

    {{ 'post.num_comments'|transchoice(post.comments|length) }}

    30 | 31 | {% for comment in post.comments %} 32 |
    33 |

    34 | {{ comment.authorEmail }} {{ 'post.commented_on'|trans }} 35 | {# it's not mandatory to set the timezone in localizeddate(). This is done to 36 | avoid errors when the 'intl' PHP extension is not available and the application 37 | is forced to use the limited "intl polyfill", which only supports UTC and GMT #} 38 | {{ comment.publishedAt|localizeddate('medium', 'short', null, 'UTC') }} 39 |

    40 |
    41 | {{ comment.content|md2html }} 42 |
    43 |
    44 | {% else %} 45 |
    46 |

    {{ 'post.no_comments'|trans }}

    47 |
    48 | {% endfor %} 49 | {% endblock %} 50 | 51 | {% block sidebar %} 52 | {% if app.user and post.isAuthor(app.user) %} 53 | 58 | {% endif %} 59 | 60 | {# the parent() function includes the contents defined by the parent template 61 | ('base.html.twig') for this block ('sidebar'). This is a very convenient way 62 | to share common contents in different templates #} 63 | {{ parent() }} 64 | 65 | {{ show_source_code(_self) }} 66 | {% endblock %} 67 | -------------------------------------------------------------------------------- /05-tips/README.md: -------------------------------------------------------------------------------- 1 | # 05 - Tips 2 | 3 | 1. [ENTRYPOINT vs CMD](#1-entrypoint-vs-cmd) 4 | 2. [File/folder permisions](#2-filefolder-permissions) 5 | 2. [PHP + Xdebug + Phpstorm](#3-php-xdebug-phpstorm) 6 | 7 | ## 1# ENTRYPOINT vs CMD 8 | 9 | **ENTRYPOINT** has two forms: 10 | 11 | - ENTRYPOINT `["executable", "param1", "param2"]` (exec form, preferred) 12 | - ENTRYPOINT `command param1 param2` (shell form) 13 | 14 | An **ENTRYPOINT** allows you to configure a container that will run as an executable. 15 | 16 | The **CMD** instruction has three forms: 17 | 18 | - CMD `["executable","param1","param2"]` (exec form, this is the preferred form) 19 | - CMD `["param1","param2"]` (as default parameters to ENTRYPOINT) 20 | - CMD `command param1 param2` (shell form) 21 | 22 | There can only be one CMD instruction in a Dockerfile. If you list more than one CMD then only the last CMD will take effect. 23 | 24 | You can combine **ENTRYPOINT** and **CMD** together. 25 | 26 | ## 2# File/folder permissions 27 | 28 | You have a nginx/apache webserver and PHP application. PHP creates some cache and it has a `www-data` as user. It's a big thing that makes you a couple nights. 29 | 30 | You have following 31 | 32 | - Delete files/folders as root user. So boring, right? 33 | - `sudo rm -rf` 34 | - Add user to your container and start webserver by this user. Better but unsecure! 35 | - Use linux ACL ([setfacl / getfacl](http://linuxcommand.org/man_pages/setfacl1.html)) 36 | - `setfacl -R -m "u::rwx" ` 37 | - `setfacl -R -m "d:u::rwx" ` 38 | 39 | ## 3# PHP + Xdebug + Phpstorm 40 | 41 | Useful resources: 42 | 43 | - https://gist.github.com/chadrien/c90927ec2d160ffea9c4 44 | - https://sandro-keil.de/blog/2015/10/05/docker-php-xdebug-cli-debugging/ 45 | - http://stackoverflow.com/questions/30668090/how-can-i-debug-my-docker-container-with-phpstorm 46 | - http://obrown.io/2015/12/23/phpunit-docker-phpstorm.html 47 | 48 | Creates [`php-in-docker.sh`](https://github.com/trainit/2016-docker-workshop/blob/master/05-tips/php-in-docker.sh) and copy into following content. Don't forget to setup `chmod +x php-in-docker.sh`. 49 | 50 | ``` 51 | #!/usr/bin/env bash 52 | docker run -i --rm -v $(pwd):$(pwd) -e PHP_IDE_CONFIG="serverName=docker.project" -e XDEBUG_CONFIG="remote_host=172.17.0.1" -v /tmp/:/tmp/ --net=host --sig-proxy=true --pid=host php "$@" 53 | ``` 54 | 55 | Environment possibilities: 56 | 57 | - PHP_IDE_CONFIG="serverName=docker.project" 58 | - XDEBUG_CONFIG="remote_host=172.17.0.1" 59 | - XDEBUG_CONFIG="idekey=PHPSTORM" 60 | 61 | Xdebug configuration: 62 | 63 | ``` 64 | zend_extension=/xdebug.so 65 | xdebug.remote_enable=on 66 | xdebug.remote_autostart=off 67 | ``` 68 | 69 | Phpstorm configuration: 70 | 71 | - Add `php-in-docker.sh` to your `other local PHP interpreter`. Ignore php.ini warnings. 72 | - You have to enable listening (on port `9000` or other) in the toolbar for every debugging in docker container. 73 | - You have to setup your source mapping from host to docker container. 74 | -------------------------------------------------------------------------------- /03-composed-application/app/app/Resources/assets/scss/bootstrap/mixins/_forms.scss: -------------------------------------------------------------------------------- 1 | // Form validation states 2 | // 3 | // Used in forms.less to generate the form validation CSS for warnings, errors, 4 | // and successes. 5 | 6 | @mixin form-control-validation($text-color: #555, $border-color: #ccc, $background-color: #f5f5f5) { 7 | // Color the label and help text 8 | .help-block, 9 | .control-label, 10 | .radio, 11 | .checkbox, 12 | .radio-inline, 13 | .checkbox-inline, 14 | &.radio label, 15 | &.checkbox label, 16 | &.radio-inline label, 17 | &.checkbox-inline label { 18 | color: $text-color; 19 | } 20 | // Set the border and box shadow on specific inputs to match 21 | .form-control { 22 | border-color: $border-color; 23 | @include box-shadow(inset 0 1px 1px rgba(0,0,0,.075)); // Redeclare so transitions work 24 | &:focus { 25 | border-color: darken($border-color, 10%); 26 | $shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 6px lighten($border-color, 20%); 27 | @include box-shadow($shadow); 28 | } 29 | } 30 | // Set validation states also for addons 31 | .input-group-addon { 32 | color: $text-color; 33 | border-color: $border-color; 34 | background-color: $background-color; 35 | } 36 | // Optional feedback icon 37 | .form-control-feedback { 38 | color: $text-color; 39 | } 40 | } 41 | 42 | 43 | // Form control focus state 44 | // 45 | // Generate a customized focus state and for any input with the specified color, 46 | // which defaults to the `$input-border-focus` variable. 47 | // 48 | // We highly encourage you to not customize the default value, but instead use 49 | // this to tweak colors on an as-needed basis. This aesthetic change is based on 50 | // WebKit's default styles, but applicable to a wider range of browsers. Its 51 | // usability and accessibility should be taken into account with any change. 52 | // 53 | // Example usage: change the default blue border and shadow to white for better 54 | // contrast against a dark gray background. 55 | @mixin form-control-focus($color: $input-border-focus) { 56 | $color-rgba: rgba(red($color), green($color), blue($color), .6); 57 | &:focus { 58 | border-color: $color; 59 | outline: 0; 60 | @include box-shadow(inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px $color-rgba); 61 | } 62 | } 63 | 64 | // Form control sizing 65 | // 66 | // Relative text size, padding, and border-radii changes for form controls. For 67 | // horizontal sizing, wrap controls in the predefined grid classes. `