This may be more like day 4.5, really.

It works! It works!

had a bit of a prob in my databases.yml – gotta put the the dbname at the end of the dsn. Yeah. Leave that off, and it gets very….confused.

So, now if I go to domain.com/frontend_dev.php/id/list, I get a symfony-looking page that lets me put stuff in.

Bad news, it didn’t build the pull-down for type. Rats! Back to docs…

First try, pulled the type off of the link field – Have a pull down! (Yes, I left off the symfony clear-cache and symfony propel-generate-crud frontend type Type Too bad, I’m just seeing the primary key values in the pull down. More searching…..

…eeeee’s back!

So, I’m hanging out tonight, got Food Network in the background, and working on this db problem.

As you may recall from the last episode (more than a day ago, but work with me here), I was having issues getting the symfony config to connect to the database. After a few moments of exhaustive research, it looks like my problem was the user password. I….I…I… Naaah, that can’t be! Changed the password anyway, and my error message changed.

Now, the error looks like:

[propel-sql-exec] Failed to execute:

CREATE TABLE `dvd`
(
`type` VARCHAR,
`id` INTEGER NOT NULL AUTO_INCREMENT,
`starring` VARCHAR,
`id_starring` VARCHAR,
PRIMARY KEY (`id`)
)Type=InnoDB
[propel-sql-exec] Could not execute update [Native Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '
`id` INTEGER NOT NULL AUTO_INCREMENT,
`starring` VARCHAR,
`id_starring` VAR' at line 3] [User Info:

CREATE TABLE `dvd`
(
`type` VARCHAR,
`id` INTEGER NOT NULL AUTO_INCREMENT,
`starring` VARCHAR,
`id_starring` VARCHAR,
PRIMARY KEY (`id`)
)Type=InnoDB]
[propel-sql-exec] 3 of 4 SQL statements executed successfully

So, I’m thinking there’s an error somewhere. Likely suspect is the schema.yml file. Since nothing appeared in the db, I’m thinking the unsuccessful statement was the one that actually *does* something. Ugh!

To the schema.yml, Batman!

Ooh! Alton’s on! (anybody who wants to donate a Shun Santoku, leave a message, I’ll send my address……)

I did note an extraneous tilde (“~”) in the schema.yml, but, alas, it didn’t change the output much. Hmm…we’re trying to create the same table twice – that doesn’t look right.

Talked with Quinn (always helpful to make sure my head’s in the right place). He put me on to a great resource – The cheatsheet

So, the schema.xml has changed, again…

propel:
   type:
     id:
     type_name: varchar(15)
   id:
     id:
     dvdname: varchar(128)
     type: varchar(10)
   starring:
     id:
     actor: longvarchar
   id_starring:
     id:
     id_id:
     starring_id:

Did the symfony cc and symfony propel-build-all, no errors! Looked in the dbAdmin side, and there are tables!

Day 2 – First Symfony App

February 10th, 2008

Well, from yesterday, we have web hosting, PEAR, and symfony installed.

Since data is the whole point of any application, I want to start this project with the Model part of MVC. Symfony uses YAML to define what the data will look like. One of the neat points of this framework is symfony’s ability to build the database from this YAML “sketch”.

For this DVD database, I would like to store the DVD type, title, and the leading actors/actresses. (Yes, I’m being a bit overly optimistic about HD disks making their way into the library anytime soon!) So, in my head, I’m going to need a table for type, another for titles, and another for actors.

In the type table, I want a primary key (just a serial number) and a bit of text describing the type. In SQL-eese, I would do this like this:

create database dvddatabase;
create table type (type_id integer primary key, type varchar(15));
insert into type values ("1", "DVD");
insert into type values ("2", "HD-DVD");
insert into type values ("3", "Blue-Ray");

But, alas, I’m not – this needs to be implemented in YAML. So, off to YAML land…


dvd:
  type:
    type_id: ~
    type: varchar(15)

The tilde (“~”) is used to tell symfony to “figure it out”. (so, does that mean I could make them all ~? (laugh.)

Need a a table for DVD Titles:

    id: ~
      dvdname: varchar(128)
      type: ~

One for who starred in the film:

    starring:
      starring_id: ~
      actor: varchar(50)

Finally, one to link the id and the starring tables together:

    id_starring:
      id_starring_id: ~
      id_id: ~
      starring_id: ~

So, the completed YAML file looks like this:
propel:
  dvd:
    type:
      type_id: ~
      type_name: varchar(15)
    id: ~
      id_id: ~
      dvdname: varchar(128)
      type: ~
      created_date: ~
    starring:
      starring_id: ~
      actor: varchar(50)
    id_starring:
      id_starring_id: ~
      id_id: ~
      starring_id: ~

This setup is quite odd to me. I tend to think of data in terms of one-to-many relationships (like the table above), it seems to me that some sort of declaration is needed.

Just for fun, since the type table will be rather short, I think I’ll try directly inputting the starting data:

propel:
  dvd:
    type:
      type_id: ~
      type_name: varchar(15)
        - DVD
        - HD-DVD
        - Blu-Ray
    id: ~
      id_id: ~
      dvdname: varchar(128)
      type: ~
      created_date: ~
    starring:
      starring_id: ~
      actor: varchar(50)
    id_starring:
      id_starring_id: ~
      id_id: ~
      starring_id: ~

So, save all that to config/schema.yml, then (from the project directory) symfony propel-build-model, and experience our first problem. Symfony says schema.yml can contain only one DB entry. I’m assuming it’s referring to the 3 rows I was trying to add in one table. Ok, I can play this game, and remove the HD entries, then rerun the propel-build-model.

Qapla!

We now have a DB schema, which symfony recognizes and thinks it knows how to handle.

Boldly going… to symfony propel-build-all, looks good, right until the end. Looks like there is a problem connecting to mysql through a socket. It’s late, I’ve got traveling to do tomorrow, so I’m going to sign off for now.


Quick index:
Day 1
Day 2

Day 1 – First symfony app

February 9th, 2008

Quinn has gotten me interested in web development with Symfony. For those who don’t know, Symfony is a PHP framework which implements the Model-View-Controller (MVC) architecture. This system allows breaking development down into a model (data), view (web stuff), and controller (how to get and what to do with data once we get it).

For my first app, I’m going to develop an app that keeps track of DVDs. We have a decent collection, and have gotten to the point where we frequently ask the question “do we have this one?” when shopping. Since we both have PDA Phones, I think this will be a big help to us. (Truthfully, it’ll be a small, quick app for me to learn on, too)

I’ve gotten hosting through (mt) MediaTemple. Specifically, their (gs) Grid Service (hey, I’m not running anything as big as Tech-Recipes!)

For starters, in this service, PEAR needs to be set up. (mt)’s knowledge base tells you how to do this for their service, others may need different procedures. PEAR’s own instructions are here.

With PEAR up and running, it’s time to see what we can do with symfony. (mt)’s KB takes you through installing symfony into a directory, then linking (mt)’s default ~/domains/yourdomain.com/html to the symfony/web directory.

Once all of this is done, you should be able to point your web browser to http://yourdomain.com and get the wonderful “Symfony project created” welcome page. In my case, I got the page, but didn’t get the graphics. I needed to link the ~/domains/yourdomain.com/symfony/sf to the sf directory on the main installation point of symfony. In (mt) (gs), this is /home/users/.home/pear/data/symfony/web/sf

Enough for day 1! Stay tuned for day 2…..