Slide 1

Slide 1 text

Grunt.js for PHP Developers

Slide 2

Slide 2 text

Florian Eckerstorfer Developer in Vienna ViennaPHP, 9 April 2014

Slide 3

Slide 3 text

1 2 3 Grunt.js For PHP Developers Demo

Slide 4

Slide 4 text

Grunt.js 1

Slide 5

Slide 5 text

Task Runner (Phing, Make, Ant, …) Automate repetitive tasks Written in JavaScript Node.js

Slide 6

Slide 6 text

Getting Started Install Node.js nodejs.org Node Packet Manager (NPM)

Slide 7

Slide 7 text

grunt-cli npm install install globally -g

Slide 8

Slide 8 text

grunt npm install --save-dev save to package.json

Slide 9

Slide 9 text

Let’s create some tasks

Slide 10

Slide 10 text

Make Makefile Phing build.xml Ant build.xml Grunt Gruntfile.js

Slide 11

Slide 11 text

Gruntfile.js module.exports = function(grunt) { // Project configuration. grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), ! // Tasks }); ! grunt.loadNpmTasks('PLUGIN_NAME'); ! // Default task(s). grunt.registerTask('default', ['TASK_NAME']); }; ['TASK_NAME_1','TASK_NAME_2']

Slide 12

Slide 12 text

grunt-contrib-cssmin npm install --save-dev

Slide 13

Slide 13 text

Gruntfile.js module.exports = function(grunt) { // Project configuration. grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), cssmin: { dist: { files: { 'css/main.min.css': ['css/main.css'] } } } }); ! grunt.loadNpmTasks('grunt-contrib-cssmin'); ! // Default task(s). grunt.registerTask('default', ['cssmin:dist']); }; Task name Target name Options

Slide 14

Slide 14 text

For PHP Developers 2

Slide 15

Slide 15 text

Backend & Frontend Asynchronous Plugins

Slide 16

Slide 16 text

grunt-phpunit npm install --save-dev

Slide 17

Slide 17 text

Gruntfile.js module.exports = function(grunt) { grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), phpunit: { test: { dir: '', options: { bin: 'bin/phpunit', configuration: 'app/phpunit.xml' } }, }, }); ! grunt.loadNpmTasks('grunt-phpunit'); ! grunt.registerTask('test', ['phpunit:test']); };

Slide 18

Slide 18 text

What else?

Slide 19

Slide 19 text

grunt-phpcs grunt-phplint grunt-php-cs-fixer grunt-phpmd grunt-phpspec …

Slide 20

Slide 20 text

grunt-symfony2 npm install --save-dev

Slide 21

Slide 21 text

Gruntfile.js module.exports = function(grunt) { grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), 'sf2-cache-clear': { options: {}, dev: {}, prod: {} } }); ! grunt.loadNpmTasks('grunt-symfony2’); };

Slide 22

Slide 22 text

Demo 3

Slide 23

Slide 23 text

What’s next?

Slide 24

Slide 24 text

gruntjs.com

Slide 25

Slide 25 text

gruntjs.com/plugins

Slide 26

Slide 26 text

grunt-contrib-watch grunt-concurrent grunt-load-config

Slide 27

Slide 27 text

Questions?

Slide 28

Slide 28 text

Florian Eckerstorfer [email protected] http://florian.ec @Florian_