Session 1: eZ components
eZ components are re-useable, clean IP, Open Source friendly, building blocks that you can use in your PHP applications. Similar to PEAR, it requires a base class for common exceptions and other common elements and provides components for:
- Command line*
- Logging and Debugging
- System Information
as well as a output Templating and Translation component. Components are generally independent and do not rely on other components unless absolutely necessary and each class in prefixed with ecz to eliminate the possibility of conflicting with your existing classes. Installation is as simple as downloading the latest source and adding the appropriate ini include path. the only trick is that component framework relies on the
\__autoload() function so if you’re using it in your framework, you’ll need to check for the components using
ezcBase::autoload($classname); (assuming you’ve already included the base using
require ezc/base/Base.php). For installation of new components, you can also use the PEAR installer using the channel://components.ez.no, so for example to install the base automagically, just run PEAR install channel://components.ez.no/Base For usage examples see the docs or Derricks slides from the seminar. Neat things include:
- Console table formatting and progress bars!
- Really nice logging components for creating and managing your own custom log files.
- Database query abstraction, looked a little messy to me, but I’ll have to check it out a bit more before I judge.
- Creating and sending MIME mail (similar to PEAR)
- Feed readers
- SignalObserver: IPC for PHP
Session 2: Explaining EXPLAIN
|EXPLAIN is an SQL keyword implemented by most databases that outputs what the query is going to do (execution plan) and ‘explains’ how it’s going to do it and the estimated “execution cost”. If your queries are running slowly, using EXPLAIN could reveal some interesting information about the performance of your query and where you can improve things. Remember however that EXPLAIN isn’t actually part of the SQL standard, it’s just a nice developer feature added after the fact. When looking at the output of EXPLAIN: EXPLAIN ANALYZE SELECT * FROM customer JOIN contact USING (last_name); QUERY PLAN -–||-–||-–||-–||-–||-–||-–||-–||-–||-–||-–||-–||-–||-–||-–||-–||-–||-–||-–||-–||-–||-–||-–||-–||-–||-–||-–||-–||-–||-–||-–||-–||-–||-–||-–||-–||Hash Join (cost=1.02..92.23 rows=2048 width=351) (actual time=1.366..58.684 rows=4096 loops=1) Hash Cond: ((“outer”.last_name)::text = (“inner”.last_name)::text) -> Seq Scan on customer (cost=0.00..60.48 rows=2048 width=107) (actual time=0.079..21.658 rows=2048 loops=1) -> Hash (cost=1.02..1.02 rows=2 width=287) (actual time=0.146..0.146 rows=2 loops=1) -> Seq Scan on contact (cost=0.00..1.02 rows=2 width=287) (actual time=0.074..0.088 rows=2 loops=1) Total runtime: 62.233 ms the order of the table is important. Form the presentation, in general for complicated queries, PostgreSQL is better at picking a good execution order over MySQL (ya!). When using indexing, the formate of your query is important. for example in you have a table where c1 and c2 columns are indexded, “c1=c2 AND c1=12” would be better written as “c1=12 AND c2=12” as the index may not be used on the c1=c2 comparison. PostgreSQL allows you to specify the storage order of the records in your table so you can further optimize based on what you’ll be sorting on (he didn’t say HOW to do this, I’ll have to look into it more). Lukas has a tendency to run out of time on his presentations so he was flying through this presentation to fit it in. I stopped typing everything to pay attention so definitely check out the slides.|
Session 3: Apps Made Easy on Zend Framework
I’ve poked about in the Zend Framework (even submitting a proposal which was ultimately rejected due to the scope of the framework) and have been following it closely. Were at a point at work where we need to reevaluate some of our platform and decide if there are better alternatives out there. ZF combined with PEAR and eZ components, offer a lot of compelling reasons to start integrating more ‘off the self’ components rather than trying to re-invent the wheel. The Zend Framework is just a small part of the PHP collaboration project that offers a “clean IP”, modular collection of PHP classes based on PHP 5 / E_STRICT. It provides a starting point for all your applications and demonstrates the PHP 5 best practices. It’s modular design allows only pieces to be used within your applications and achieves it’s goals with a minimal object hierarchy. One of the ideals I like the best is that the frameworks strives to be simple and easy to use. “Simple things should be simple, complex things should be possible”. the architecture is distributed as a package, not as individual modules, which provides a “use at will” setup so everything is accessible if you want it. The framework is namespaces to Zend:: and all constants are class based so it will lay nicely with any other components (ez, Pear). Other than setting up the proper include path in your php.ini file, all you need to do is download it (or check it out from the subversion as I do). ### ZFApp ZFApp is a framework based of ZF that sets up the initial structure of an application using the Zend Framework. It’s in the Lab project of Zend’s framework, where non-core idea prosper. ZFApp is working towards, for example, being able to write a blog in 30 minutes with all the bells and whistles including authentication, searching, syndication and more. Taking a lot from Ruby on Rails, ZFApp provides a rudimentary installer that sets up an initial app framework where you can then begin to play. Taking the “Convention over Configuration” approach, you can then add controllers and views in the specified format and -tada-, your app will be up and running is seconds. The demo app for the seminar was a fully functioning blog app, which appeared well rounded on minimal code. If you’re looking to build new apps based on the Zend Framework, this is definitely worth a look. From the brief introduction, the only hesitation I have is the views reliance on Smarty. I’ll have to explore more but allowing alternate template engines would be a nice add-on. ## Roundup Overall the conference was worthwhile, much better than last years. The speakers seemed well prepared and knowledgeable but I was more selective about what sessions I attended based not only on the topic but also the speaker. A few speakers could have presented themselves in a little more professional manner (no ripped shorts and flip-flops please) but the content of their presentations was still good. I didn’t get a chance to attend the after hours events but I heard they went well so I’ll have to attend next year. Aside form the conference, I do have a few gripes with Wordpress now that I’ve been using it consistently for tree days (code formatting and headers anyone?). As for ideas, I have a ton. I mentioned in a previous post that we’re in the rocess of migrating to PHP5 at work and I’m responsible for upgrading and improving the overall framework and system. Zend Framework, XML, convention over configuration, namespaces and a bunch of other PHP5 goodies will be at the front of my brain as we wade further into v5. It’ll be exciting! And as a followup to my
Apple post, they’ll be replacing my MacBook keyboard, but I have to leave it with them for a week once they get the part in. I’ll have to argue that a bit more as I live an hour from the store and my wife and I are expecting our first child next week so I’m not going to have time to be diving there at their leisure, let alone be without my MacBook for a week when the baby’s coming and I have to unload my cameras! Oh, and here’s the solution they came up with for the lack of plugs…