Seitenanfang

YAWF finally on CPAN

Dieser Post wurde aus meiner alten WordPress-Installation importiert. Sollte es Darstellungsprobleme, falsche Links oder fehlende Bilder geben, bitte einfach hier einen Kommentar hinterlassen. Danke.


YAWF is "yet another web framework", but do we really need this? Not really, but I wrote it anyway :-)

YAWF is easy to use and isn't as flexible as other frameworks, but this is an advantage: A new YAWF project can be created very quick and you already got sessioning, database connections, object and relation creation from the database structure and some more things.

Quickstart for your first YAWF project

Create a new yawf.yml file (or copy an existing):
---
*:
   domain: localhost   database:        dbi: dbi:Pg:host=localhost;dbname=MyDatabase        username: my_db_user        password: whateveryoulike        database: MyDatabase        class: MyProject::DB   HandlerPrefix: MyProject::Web   template_dir: ./templates   setup_enabled: 1   setup_password: secret_thing
The domain is the internal/primary domain name used within your project, the DBI connection string could contain anything DBI allows (database name is required only for Postgres as it lacks support of "use database"). The database configuration is optional at all, but used by most projects.

Run yawf_httpd.pl (part of YAWF distribution) in the directory where yawf.yml has been created.

Next use a webbrowser to connect to the URL shown at start of yawf_httpd.pl (Usually http://localhost:8000) and you should see the default index page of YAWF.

Go to http://localhost:8000/yawf_setup/ (note the tailing /) to read your database structure and create objects and templates for your tables.

Many more things are shown in the YAWF documentation (and many things are still not written down there).

Using YAWF on Apache and mod_perl

Three lines in your apache (site) configuration enable YAWF:
PerlModule YAWF::Apache
PerlOptions +GlobalRequest +SetupEnv
PerlResponseHandler YAWF::Apache
(I really don't know if GlobalRequest is required, but the CGI module requires SetupEnv).

Next, create a yawf.yml file in your DocumentRoot directory (and protect it from being visible by web users).

---
cpan.org:
   domain: cpan.org   database:        dbi: dbi:Pg:host=localhost;dbname=MyDatabase        username: my_db_user        password: whateveryoulike        database: MyDatabase        class: MyProject::DB   HandlerPrefix: WebCPAN::Handlers   template_dir: /var/www/cpan.org/templates*:   domain: perl.org   database:        dbi: dbi:Pg:host=localhost;dbname=MyDatabase        username: my_db_user        password: whateveryoulike        database: MyDatabase        class: MyProject::DB   HandlerPrefix: MyPerl::Web   template_dir: /var/www/www.perl.org/templates
The main key is the domain name which is being configured. cpan.org is the same as /(.*\.)?cpan.org/ and a single asterisk ( * ) defines the default value if nothing else could be found. Notice that an explicit *.cpan.org does not include cpan.org

I usually don't develop on production servers, so setup_enabled is gone (defaults to 0/false) and /yawf_setup/ isn't visible at all.

A HTTP request to cpan.org/foo.bar.baz will go to WebCPAN::Handlers::Foo::Bar->baz.

 

Noch keine Kommentare. Schreib was dazu

Schreib was dazu

Die folgenden HTML-Tags sind erlaubt:<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>