Sign In/My Account | View Cart  
advertisement


Listen Print Discuss

Building E-Commerce Sites with Handel
by Christopher H. Laco | Pages: 1, 2, 3, 4, 5

Creating the Database

First, you must create the database. For the sake of this experiment^H^H^H^Harticle, I use Sqlite. In the real world, you would probably want to use MySQL/PostgreSQL instead.

Download the handel.sqlite.sql schema script to your hard drive. Now, in your favorite shell, type the following to create the database:

[claco@cypher ~] $ wget 
    http://handelframework.com/svn/CPAN/Handel/tags/0.26/sql/handel.sqlite.sql
handel.sqlite.sql                             100% of 2300  B  115 kBps
[claco@cypher ~] $
[claco@cypher ~] $ sqlite3 handel.db < handel.sqlite.sql
[claco@cypher ~] $

This should have created an sqlite v3 database in your working directory. Remember this file name and location. You're going to need it to set up the DSN.

Creating the Application

If you haven't used or even heard about Catalyst yet, now is probably a good time to read Jesse Sheidlower's article introducing the Catalyst MVC framework. Because Handel isn't bound to any specific front-end GUI, you need to use other tools to interact with the data. For the purposes of this introduction, Catalyst will provide the front-end web interface for use.

To create the new web application, simply call catalyst.pl, passing it the name of the new application. Make sure to do this in the directory in which you wish to have the new application's directory created.

$ catalyst.pl MyStore

You should end up with output resembling:

[claco@cypher ~] $ catalyst.pl MyStore
created "MyStore"
created "MyStore/script"
created "MyStore/lib"
created "MyStore/root"
created "MyStore/t"
created "MyStore/t/M"
created "MyStore/t/V"
created "MyStore/t/C"
created "MyStore/lib/MyStore"
created "MyStore/lib/MyStore/M"
created "MyStore/lib/MyStore/V"
created "MyStore/lib/MyStore/C"
created "MyStore/lib/MyStore.pm"
created "MyStore/Build.PL"
created "MyStore/Makefile.PL"
created "MyStore/README"
created "MyStore/Changes"
created "MyStore/t/01app.t"
created "MyStore/t/02pod.t"
created "MyStore/t/03podcoverage.t"
created "MyStore/script/mystore_cgi.pl"
created "MyStore/script/mystore_fastcgi.pl"
created "MyStore/script/mystore_server.pl"
created "MyStore/script/mystore_test.pl"
created "MyStore/script/mystore_create.pl"
[claco@cypher ~] $

Now run the newly created application, just to see what you have so far. In your terminal, change directory into the newly created app and start its server:

[claco@cypher ~] $ cd MyStore
[claco@cypher ~/MyStore] $ script/mystore_server.pl

You should see a bunch of debugging information streaming to the console:

[Wed Sep 21 19:19:16 2005] [catalyst] [debug] Debug messages enabled
[Wed Sep 21 19:19:16 2005] [catalyst] [debug] Loaded dispatcher
    "Catalyst::Dispatcher"
[Wed Sep 21 19:19:16 2005] [catalyst] [debug] Loaded engine
    "Catalyst::Engine::HTTP"
[Wed Sep 21 19:19:16 2005] [catalyst] [debug] Found home
    "/usr/home/claco/MyStore"
[Wed Sep 21 19:19:16 2005] [catalyst] [debug] Loaded private actions:
.=-------------------------------------+--------------------------------------=.
| Private                              | Class                                 |
|=-------------------------------------+--------------------------------------=|
| /default                             | MyStore                               |
'=-------------------------------------+--------------------------------------='

[Wed Sep 21 19:19:16 2005] [catalyst] [info] MyStore powered by Catalyst 5.33
You can connect to your server at http://localhost:3000/

Now point your browser to the address listed in the debug output. This is usually http://localhost:3000/. If everything is working properly, you should have a nice new shiny web application looking something like Figure 1.

New MyStore Application Screenshot
Figure 1. A NewStore application

Of course, your new store doesn't do anything yet. :-) It's time to fix that. Stop the application by hitting CTRL-C.

^C
[claco@cypher ~/MyStore] $

Pages: 1, 2, 3, 4, 5

Next Pagearrow