Making sense of
the front-end
for PHP developers
About me
web developer consultant
PHP + JavaScript
@LuizBrandaoJr
Topics
● Front-end in general
● Tools of the trade
● Key technologies
● Development workflow
● Integration with PHP
Why is front-end hard?
● Browsers!
● Cross-browser issues
● Different technologies
● Complex applications
● User experience
● Non-developers
The holy trinity
● HTML : structure
● CSS : presentation
● JavaScript : behavior
HTML5
& Friends
Web APIs
● Semantics
● Connectivity
● Offline and storage
● Multimedia
● 2D/3D graphics and effects
● Performance and integration
● Device access
● Styling
JavaScript
it’s everywhere
● Client side scripting language
● Also runs on the server
● Impossible to keep up with
ECMAScript
the standard
ES is simply short for ECMAScript
● ES2015
● ES6
● They are the same!
● ES2016 (ES7)
● ES2017 (ES8)
● ES.Next
European Computer Manufacturers Association
Babel
ES.Next, today
● JavaScript compiler
● Transform syntax
● Polyfills
● Plugins / Presets
TypeScript
because we all want types
● Superset of JavaScript
● Optional strong-typing
● Compiles to plain JavaScript
● Integrates with Babel
● Popular
CSS
Preprocessors
styles on steroids
● Sass (SCSS)
● Less
● Stylus
● Use logic in CSS
● Nesting
● Inheritance
● Functions
● Different syntax
PostCSS
transforming styles with JS
● Kinda like Babel for CSS
● Use modern CSS
● Lots of plugins:
○ auto-prefixing
○ dead css removal
Frameworks
I’m down for it
● Pure JavaScript frameworks
● UI / CSS frameworks
UI / CSS
Frameworks
now make it pretty
Provide collection of components
ready to use:
● Bootstrap
● Semantic-UI
● Foundation
● Bulma
● Vuetify
JavaScript
Frameworks
somebody help me
Most popular:
● React
● Vue.js
● Angular
Why:
● Help create interactive UIs
● Organize the application
What about
jQuery?
it was fun while it lasted
Node.js
-_-
● JavaScript runtime
● V8 JavaScript engine (Chrome)
● Required by most tools
Package
Managers
it’s like Composer
● npm
● yarn
package.json
PHP: composer.json
package-lock.json
yarn.lock
PHP: composer.lock
node_modules
PHP: vendor
Build Tools
put all the shiny things together
● Task Runners
● Bundle/Module Managers
Task Runners
it’s time to automate
● Grunt
● Gulp
Bundle
Managers
are we there yet?
● Webpack
● Parcel
● Rollup
● Browserify
Webpack
the almighty
Most popular static module bundler
Core concepts:
● Entry
● Output
● Loaders
● Plugins
● Mode
● Browser compatibility
Most popular static module bundler
Core concepts:
● Entry
● Output
● Loaders
● Plugins
● Mode
● Browser compatibility
Configuration
Wrappers
ok, go on...
● Webpack Encore by Symfony
● Laravel Mix
Laravel
Mix
finally some PHP?
● JavaScript package
● Easy Webpack integration
● Asset compilation
● Includes PHP helper functions
● Bundled with Laravel
Symfony
Webpack Encore
gimme some of that
● Same concept as Laravel Mix
● Integrates with Symfony
composer require webpack-encore-bundle
Asset Versioning
burst that cache
app.js
mix.version()
app.js?id=8e5c48eadbfdd5458ec6
{{ mix(‘js/app.js’) }}
Encore.enableVersioning()
app.123abc.js
{{ asset('build/images/logo.png') }}
{{ encore_entry_script_tags('app') }}
Questions?
be nice
Making sense of the front-end, for PHP developers

Making sense of the front-end, for PHP developers