Purpose
- Introduction
- Compare a full Mojolicious app to a lite app with the same functionality.
- See an example of DBIx::Class usage with Mojolicious
- See an example of tests for a Mojolicious app
Notes
- Both apps make use of the DBIx::Class schema.
- The schema is in lib/Schema.pm, lib/Schema/*
- The DBIx::Class schema connects to a provided sqlite3 database, test.db
- The controller tests create a new test.db, populated using fixtures from t/fixtures/*
- The schema tests use an in-memory sqlite3 database, populated using fixtures from t/fixtures/*
- Test::Database is a utility for populating the sqlite3 databases with fixtures from t/fixtures/*
Usage
Live
Heroku is running Hypnotoad, the full featured UNIX optimized preforking non-blocking I/O HTTP 1.1 and WebSocket server built around the very well tested and reliable Mojo::Server::Daemon with IPv6, TLS, Bonjour, libev and hot deployment support that just works.
To easily deploy your own Mojolicious app to Heroku, check out Deploy Perl Mojolicious web apps to Heroku.
Locally
A minimum of Perl 5.10 is required. If your Perl is too old, Perlbrew is ΓΌber easy to install!
If you must run on Perl 5.8, you can try a back-ported version of Mojolicious, but you're on your own :)
Install
git clone [email protected]:tempire/MojoExample.git
cd MojoExample
Install the Carton package manager. Carton will install all dependencies to the local/ sub-directory.
curl -L cpanmin.us | perl - Carton
carton install
Run
Full app
carton exec morbo script/mojo_full
Light app
carton exec morbo mojolite
Index
- lib/
- MojoFull.pm - Mojolicious Application
- MojoFull/ - Mojolicious Controllers
- Schema.pm - DBIx::Class model
- Schema/
- Result/ - DBIx::Class Result classes
- ResultSet/ - DBIx::Class ResultSet classes
- Test/
- Database.pm - Utility class for populating test fixtures
- public/ - Static files
- css/
- images/
- script/ - Utilities
- generate_schema - Generates DBIx::Class schema from database file
- mojo_full*
- new_db - Generates database file from DBIx::Class and fixtures
- t/ - Tests
- templates/
- blogs/ - Blogs.pm templates
- index.html.ep - Tag Helpers
- show.html.ep
- home/ - Home.pm templates
- photos/ - Photos.pm templates
- layouts/
- blogs/ - Blogs.pm templates
- mojolite - Mojolicious::Lite app, with all the application files listed above embedded
- README.md - This file
Copyright License
Copyright (C) 2008-2014, Glen Hinkle.
MojoExample is free software, you can redistribute it and/or modify it under the same terms as Perl5 (http://dev.perl.org/licenses/).