a pragmatic look at symfony (the php5 framework) by darren beale

16
Skillswap Bristol - 26 th July 2007

Upload: nicholas-kirkland

Post on 02-Jan-2016

47 views

Category:

Documents


1 download

DESCRIPTION

A Pragmatic Look At Symfony (The PHP5 framework) by Darren Beale. Skillswap Bristol - 26 th July 2007. Who am I?. Front-end & PHP Developer since 1998 Owner/Manager of Siftware Ltd in Upton-upon-Severn - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: A Pragmatic Look At Symfony (The PHP5 framework) by Darren Beale

Skillswap Bristol - 26th July 2007

Page 2: A Pragmatic Look At Symfony (The PHP5 framework) by Darren Beale

Who am I?

Front-end & PHP Developer since 1998 Owner/Manager of Siftware Ltd in Upton-upon-Severn

Siftware is 1 yr old & provides outsourced web dev services to design and development agencies

The business thing is starting to interest me more than the tech

Previous to Siftware I spent 8 years in London 4 years as contractor/employee

Front-end (inc Flash), PHP, Coldfusion and 1 year as *nix sysadmin 4 years as owner/manager of Exponetic Ltd in Bethnal Green

Grew it up to 8 staff then exited It is still going strong

Underscore member all that time, although I left Bristol within months of subscribing I don’t post as much as I used to This is my first meeting, hello!

A Pragmatic Look At Symfony (The PHP5 framework) for Skillswap Bristol by Darren Beale ([email protected])

Page 3: A Pragmatic Look At Symfony (The PHP5 framework) by Darren Beale

What about you?

A Pragmatic Look At Symfony (The PHP5 framework) for Skillswap Bristol by Darren Beale ([email protected])

…wave them like you just don’t care How many of you are techies? How many do mostly PHP dev? Do any of you use frameworks? Symfony?

Page 4: A Pragmatic Look At Symfony (The PHP5 framework) by Darren Beale

What’s I’ll be covering

A Pragmatic Look At Symfony (The PHP5 framework) for Skillswap Bristol by Darren Beale ([email protected])

Why use a framework? Intro to Symfony Symfony’s MVC implementation Coding a simple web application from

scratch Areas for Improvement Summary What next?

Page 5: A Pragmatic Look At Symfony (The PHP5 framework) by Darren Beale

Why use a framework?

A Pragmatic Look At Symfony (The PHP5 framework) for Skillswap Bristol by Darren Beale ([email protected])

Factors out common patterns Code layout Config URL routing Authentication and Security Form validation Internationalisation/Localisation

Encourages good design and allows one to easily utilise best practices

Page 6: A Pragmatic Look At Symfony (The PHP5 framework) by Darren Beale

Intro to Symfony

A Pragmatic Look At Symfony (The PHP5 framework) for Skillswap Bristol by Darren Beale ([email protected])

symfony-project.com Written in PHP5 Superb documentation

including a couple of sample applications The book is open source and available online Forums, wiki, mailing list as one would expect

Lots of plugins including CMS Forum Blog

Page 7: A Pragmatic Look At Symfony (The PHP5 framework) by Darren Beale

Intro to Symfony cont…

A Pragmatic Look At Symfony (The PHP5 framework) for Skillswap Bristol by Darren Beale ([email protected])

Recommended configuration Apache with mod_rewrite PHP5.2.x

Simple to install Pear

#> pear channel-discover pear.symfony-project.com

#> pear install symfony/symfony Apache, add alias in your VirtualHost, e.g.

Alias /sf /usr/share/php/data/symfony/web/sf

Page 8: A Pragmatic Look At Symfony (The PHP5 framework) by Darren Beale

Intro to Symfony cont…

A Pragmatic Look At Symfony (The PHP5 framework) for Skillswap Bristol by Darren Beale ([email protected])

Minimal dependencies, all included Creole

Database Abstraction Support for MySQL, PostgreSQL, SQLite, MSSQL

Propel Object Relationship Mapping About to officially support Doctrine too but can already use via

plugin PAKE

Library for easy command line tasks LIME

Library for easy unit and functional testing Plus…

Prototype Script.aculo.us TinyMCE (WYSIWYG) DynArch.com Rich Calendar

Page 9: A Pragmatic Look At Symfony (The PHP5 framework) by Darren Beale

Symfony’s MVC implementation

A Pragmatic Look At Symfony (The PHP5 framework) for Skillswap Bristol by Darren Beale ([email protected])

Model Data access and manipulation Based on Propel (by default) Built in tools for pagination, sorting and filters Model can be configured using XML or YAML Symfony builds your model for you!

#> symfony propel-build-model Symfony provides classes ready for you to

extend your model

Page 10: A Pragmatic Look At Symfony (The PHP5 framework) by Darren Beale

Symfony’s MVC implementation cont…

A Pragmatic Look At Symfony (The PHP5 framework) for Skillswap Bristol by Darren Beale ([email protected])

View Presentation layer Global layout and configuration

Each action can have its own sub template View config can go down as low as actions

Symfony uses PHP as its templating language There’s a Smarty plugin

Partials and Slots Template fragments without business logic

Components Template fragments with business logic

Page 11: A Pragmatic Look At Symfony (The PHP5 framework) by Darren Beale

Symfony’s MVC implementation cont…

A Pragmatic Look At Symfony (The PHP5 framework) for Skillswap Bristol by Darren Beale ([email protected])

Controller Routes the business logic Each ‘module’ has a controller class with a

number of ‘action’ methods Automatic conversion of the URL into the

appropriate module/action Pre and post execute methods

Page 12: A Pragmatic Look At Symfony (The PHP5 framework) by Darren Beale

Lots of coding

A Pragmatic Look At Symfony (The PHP5 framework) for Skillswap Bristol by Darren Beale ([email protected])

Lets get our hands dirty Dev environment is Windows XP (sorry)

with Debian server running under VMWare with Apache, PHP, MySQL and Samba

Apache document root is a Samba share mapped as a drive

The app I’m going to build is very simple. I had bigger plans but I de-scoped as I went along

Page 13: A Pragmatic Look At Symfony (The PHP5 framework) by Darren Beale

Summary

A Pragmatic Look At Symfony (The PHP5 framework) for Skillswap Bristol by Darren Beale ([email protected])

We talked about Why frameworks are A Good Thing Intro to Symfony Symfony’s MVC implementation Coding a simple web application from

scratch Areas for Improvement

Page 14: A Pragmatic Look At Symfony (The PHP5 framework) by Darren Beale

Areas for Improvement

A Pragmatic Look At Symfony (The PHP5 framework) for Skillswap Bristol by Darren Beale ([email protected])

I think Symfony is superb and has got a huge amount going for it

That said, there are a few area that niggle me Some of the build process is a bit flakey

Well it is for me anyway Especially around refactoring

Seems a bit magic sometimes But one could argue that’s the point

Forums and mailing lists are not always particularly helpful They seem to be more helpful when you know what

you’re talking about (e.g. the documentation is already superb, go read that)

Some would argue this as a positive as it leaves the mailing lists free of noise

Page 15: A Pragmatic Look At Symfony (The PHP5 framework) by Darren Beale

What next?

A Pragmatic Look At Symfony (The PHP5 framework) for Skillswap Bristol by Darren Beale ([email protected])

For more information Symfony-project.com

Try the sample application there or Askeet! the 24 day sample project

Feel free to email me with questions [email protected]

I’ll put these slides up on http://bealers.com along with the code

Page 16: A Pragmatic Look At Symfony (The PHP5 framework) by Darren Beale

A Pragmatic Look At Symfony (The PHP5 framework) for Skillswap Bristol by Darren Beale ([email protected])

<powerpoint />