Showing posts with label Zend Framework. Show all posts
Showing posts with label Zend Framework. Show all posts

Friday, 22 June 2012

Zend/Zend tutorial review

Zend

Zend seems to be a pretty good framework, as one would expect. From what I have seen, most of the code seems clean and logical. It has useful built in scripts to call to set up basic files. Seeing as developers are lazy, it's nice to have code to write your code for you.

There are some things that I'm not keen on. It seems to be that forms seem to post the data back to the same page, which means if you try and go back in the browser, or refresh the page you get that annoying 'are you sure you want to submit this data again' pop-up.

Models are set up in a very similar way to how I've been taught to safely set up object with functions to call and set properties rather than setting the variables directly (this avoids accidental assignment).

Zend Tutorial

The tutorial was pretty good at helping me understand the basics of MVC.
That's about all the good I have to say about it.

The tutorial wasn't very well written and basically was just a load of code to cut and paste into your application. The 'Create a Model page' was particularly confusing by getting users to create a script to populate the database with sample data when it could have halved the size of the tutorial by just giving the SQL to create the records.
I know nothing extra about the Front Controller pattern as all the code dealing with that seems to be hidden in the Zend source code. I realise the tutorial makes no promises about this, but I was disappointed nonetheless.

Sunday, 17 June 2012

Part way through the Zend tutorial

The Zend quickstart tutorial is really helping me get to grip with the MVC and front controller way of doing things. Although I'm not yet connived that it is the best way of doing thing, I am beginning to understand it, how it works and the reasons that people think it works well.

I thought I would quickly share a few things at the halfway stage.

Development Environment

Zend makes a lot of fuss about file structure and while at the beginning of the project my plan was to keep things as basic as possible and only use a text editor to edit my files, I caved in. I installed NetBeans in order to see the file structure of the quickstart project. This was actually quite good for understanding where all the files lived.
In order to install NetBeans, you must first install the JavaSDK which you can do by typing sudo apt-get install openjdk-7-jdk in a terminal window.
You can then download NetBeans from http://netbeans.org/
Once you have done that, open NetBeans and choose New Project. Then just navigate to the quickstart folder.

MySQL vs SQLite

The ZEND tutorial on creating models uses SQLite as the database of choice. Whereas this blog only talks about MySQL. The tutorial starts talking about initializing a Db resource. Read this part but don't follow the instructions to do with SQLite or creating scripts (you can if you want as you can revert it afterwards). Instead follow the simple MySQL instructions in this comment. You can then pick the tutorial up again where it starts talking about a Table Data Gateway.

Saturday, 16 June 2012

Learning the MVC principles with Zend

Getting to grips with MVC using Zend

As I mentioned in a previous post, I could neither get to grips with or understand the positive aspects of programming using the MVC principles.

It was recommended to me that I follow the Zend Framework quickstart guide. Apparently it gives a good basic understanding of the MVC principles and will take around a day to work your way through it.

I started setting up the Zend Framework on my computer a few weeks ago, but got stuck and frustrated several time and could not force myself to go back and try again. It is not the simplest thing to set up if you're not used to configuring system files such as PHP's .ini file. But I have finally got there!

The quickstart guide navigation is not all that friendly I found and so I will put some links at the bottom of this post.

There were several places that I got stuck while setting up the framework. The last and most frustrating is when I actually visited my local version of the quickstart site to be greeted with the error 'Warning require_once(Zend/Application.php)[function.require-once]: failed to open stream: No such file or directory in /home/michael/Projects/quickstart/public/index.php on line 18'. I'm still convinced that I must not have followed the setup guide correctly, I followed it through twice after to make sure I had done everything and set up any symbolic links I needed to.Google didn't seem to help. I finally gave up and started messing around the the set_include_path call on the index.php and added under the realpath bit '/home/michael/Zend/ZendFramework-1.11.11/library' it finally worked! So if you get that problem, just put that bodge in.

I am now greeted with the following image. Boring, but satisfying.
I imagine my next post will be when I have completed the guide. (Probably in a few months)


Zend Quickstart links:

Download Zend and then follow install.txt