160 likes | 316 Views
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
E N D
A Pragmatic Look At Symfony(The PHP5 framework)by Darren Beale Skillswap Bristol - 26th July 2007
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 (mail@bealers.com)
What about you? • …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? A Pragmatic Look At Symfony (The PHP5 framework) for Skillswap Bristol by Darren Beale (mail@bealers.com)
What’s I’ll be covering • Why use a framework? • Intro to Symfony • Symfony’s MVC implementation • Coding a simple web application from scratch • Areas for Improvement • Summary • What next? A Pragmatic Look At Symfony (The PHP5 framework) for Skillswap Bristol by Darren Beale (mail@bealers.com)
Why use a framework? • 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 A Pragmatic Look At Symfony (The PHP5 framework) for Skillswap Bristol by Darren Beale (mail@bealers.com)
Intro to Symfony • 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 A Pragmatic Look At Symfony (The PHP5 framework) for Skillswap Bristol by Darren Beale (mail@bealers.com)
Intro to Symfony cont… • 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 A Pragmatic Look At Symfony (The PHP5 framework) for Skillswap Bristol by Darren Beale (mail@bealers.com)
Intro to Symfony cont… • 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 A Pragmatic Look At Symfony (The PHP5 framework) for Skillswap Bristol by Darren Beale (mail@bealers.com)
Symfony’s MVC implementation • 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 A Pragmatic Look At Symfony (The PHP5 framework) for Skillswap Bristol by Darren Beale (mail@bealers.com)
Symfony’s MVC implementation cont… • 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 A Pragmatic Look At Symfony (The PHP5 framework) for Skillswap Bristol by Darren Beale (mail@bealers.com)
Symfony’s MVC implementation cont… • 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 A Pragmatic Look At Symfony (The PHP5 framework) for Skillswap Bristol by Darren Beale (mail@bealers.com)
Lots of coding • 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 A Pragmatic Look At Symfony (The PHP5 framework) for Skillswap Bristol by Darren Beale (mail@bealers.com)
Summary • 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 A Pragmatic Look At Symfony (The PHP5 framework) for Skillswap Bristol by Darren Beale (mail@bealers.com)
Areas for Improvement • 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 A Pragmatic Look At Symfony (The PHP5 framework) for Skillswap Bristol by Darren Beale (mail@bealers.com)
What next? • 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 • darren.beale@siftware.co.uk • I’ll put these slides up on http://bealers.com along with the code A Pragmatic Look At Symfony (The PHP5 framework) for Skillswap Bristol by Darren Beale (mail@bealers.com)
<powerpoint /> A Pragmatic Look At Symfony (The PHP5 framework) for Skillswap Bristol by Darren Beale (mail@bealers.com)