summaryrefslogtreecommitdiffstats
path: root/config/bootstrap
diff options
context:
space:
mode:
authorMichael Francis <edude03@gmail.com>2011-05-28 13:28:16 -0400
committerMichael Francis <edude03@gmail.com>2011-05-28 13:28:16 -0400
commit2389d66da849798f8d4ec5f10e3b07c11da49185 (patch)
treee22556d12982395b469a23420c662662e3e064cc /config/bootstrap
downloadotakuhub-2389d66da849798f8d4ec5f10e3b07c11da49185.tar.xz
Initial Commit
Diffstat (limited to 'config/bootstrap')
-rw-r--r--config/bootstrap/.DS_Storebin0 -> 6148 bytes
-rw-r--r--config/bootstrap/action.php55
-rw-r--r--config/bootstrap/auth.php135
-rw-r--r--config/bootstrap/cache.php62
-rw-r--r--config/bootstrap/connections.php72
-rw-r--r--config/bootstrap/console.php19
-rw-r--r--config/bootstrap/error.php37
-rw-r--r--config/bootstrap/errors.php28
-rw-r--r--config/bootstrap/g11n.php149
-rw-r--r--config/bootstrap/libraries.php127
-rw-r--r--config/bootstrap/media.php63
-rw-r--r--config/bootstrap/session.php49
12 files changed, 796 insertions, 0 deletions
diff --git a/config/bootstrap/.DS_Store b/config/bootstrap/.DS_Store
new file mode 100644
index 0000000..5008ddf
--- /dev/null
+++ b/config/bootstrap/.DS_Store
Binary files differ
diff --git a/config/bootstrap/action.php b/config/bootstrap/action.php
new file mode 100644
index 0000000..41b4d5e
--- /dev/null
+++ b/config/bootstrap/action.php
@@ -0,0 +1,55 @@
+<?php
+/**
+ * Lithium: the most rad php framework
+ *
+ * @copyright Copyright 2010, Union of RAD (http://union-of-rad.org)
+ * @license http://opensource.org/licenses/bsd-license.php The BSD License
+ */
+
+/**
+ * This file contains a series of method filters that allow you to intercept different parts of
+ * Lithium's dispatch cycle. The filters below are used for on-demand loading of routing
+ * configuration, and automatically configuring the correct environment in which the application
+ * runs.
+ *
+ * For more information on in the filters system, see `lithium\util\collection\Filters`.
+ *
+ * @see lithium\util\collection\Filters
+ */
+
+use lithium\core\Libraries;
+use lithium\net\http\Router;
+use lithium\core\Environment;
+use lithium\action\Dispatcher;
+
+/**
+ * This filter intercepts the `run()` method of the `Dispatcher`, and first passes the `'request'`
+ * parameter (an instance of the `Request` object) to the `Environment` class to detect which
+ * environment the application is running in. Then, loads all application routes in all plugins,
+ * loading the default application routes last.
+ *
+ * Change this code if plugin routes must be loaded in a specific order (i.e. not the same order as
+ * the plugins are added in your bootstrap configuration), or if application routes must be loaded
+ * first (in which case the default catch-all routes should be removed).
+ *
+ * If `Dispatcher::run()` is called multiple times in the course of a single request, change the
+ * `include`s to `include_once`.
+ *
+ * @see lithium\action\Request
+ * @see lithium\core\Environment
+ * @see lithium\net\http\Router
+ */
+Dispatcher::applyFilter('run', function($self, $params, $chain) {
+ Environment::set($params['request']);
+
+ foreach (array_reverse(Libraries::get()) as $name => $config) {
+ if ($name === 'lithium') {
+ continue;
+ }
+ $file = "{$config['path']}/config/routes.php";
+ file_exists($file) ? include $file : null;
+ }
+ return $chain->next($self, $params, $chain);
+});
+
+?> \ No newline at end of file
diff --git a/config/bootstrap/auth.php b/config/bootstrap/auth.php
new file mode 100644
index 0000000..11c963f
--- /dev/null
+++ b/config/bootstrap/auth.php
@@ -0,0 +1,135 @@
+<?php
+use lithium\storage\Session;
+use lithium\security\Auth;
+use lithium\util\String;
+use app\models\User;
+use lithium\core\Libraries;
+use lithium\action\Dispatcher;
+use lithium\net\http\Router;
+use lithium\action\Response;
+
+
+Session::config(array(
+ 'cookie' => array('adapter' => 'Cookie'),
+ 'default' => array('adapter' => 'Php'),
+ 'flash_message' => array('adapter' => 'Php')
+));
+
+Auth::config(array(
+ 'default' => array(
+ 'adapter' => 'Form',
+ 'model' => 'User',
+ 'cookie' => '',
+ 'fields' => array('username', 'password'),
+ //'scope' => array('active' => 'true'), //The active field must be true otherwise they can't auth, though we need
+ //to eventually send them to a page that explains they are banned.
+ 'session' => array('options' => array('name' => 'default')),
+ 'filters' => array(
+ 'password' => function($password) {
+ return $password; //prevents li3 from hashing the password before hand.
+ },
+
+ function($data) {
+ if (!empty($data['username'])) {
+
+ //Find the first element record that matches the username in the request and get the salt field
+ $salt = User::find('first', array('conditions' => array('username' => $data['username'])));
+
+ //The password to query is the password from the request
+ //hashed with the users stored salt
+ $data['password'] = String::hashPassword($data['password'], $salt->salt);
+ }
+ return $data;
+ })
+ )
+));
+
+$secret = "cake";
+
+// Adds remember feature for form-based authentications.
+Auth::applyFilter('check', function($self, $params, $chain) use ($secret) {
+ $query = 'first';
+ $scope = array();
+ extract($self::invokeMethod('_config', array($params['name'])));
+ if ($result = $chain->next($self, $params, $chain)) {
+ $request = $params['credentials'];
+ if ($request && $adapter == 'Form' && !empty($request->data['remember'])) {
+ $data = array_intersect_key($result, array_combine($fields, $fields));
+ $data = serialize($data);
+ Session::write(
+ "Auth.{$params['name']}",
+ base64_encode($data),
+ array('name' => 'cookie')
+ );
+ }
+ return $result;
+ }
+ if ($adapter == 'Form') {
+ $data = Session::read("Auth.{$params['name']}", array('name' => 'cookie'));
+ if ($data) {
+ $data = base64_decode($data);
+ $data = unserialize($data);
+ if (array_keys($data) == $fields) {
+ $model = Libraries::locate('models', $model);
+ $data = array_map('strval', $data);
+ $user = $model::$query($scope + $data);
+ if ($user) {
+ return $self::set($params['name'], $user->data());
+ }
+ }
+ }
+ }
+ return $result;
+});
+
+// Removes remember cookie after sign out.
+Auth::applyFilter('clear', function($self, $params, $chain) {
+ $config = $self::invokeMethod('_config', array($params['name']));
+ if ($config['adapter'] == 'Form') {
+ if (Session::read("Auth.{$params['name']}", array('name' => 'cookie'))) {
+ Session::delete("Auth.{$params['name']}", array('name' => 'cookie'));
+ }
+ }
+ return $chain->next($self, $params, $chain);
+});
+
+//So that we can filter a bunch of methods in one
+Dispatcher::applyFilter('_callable', function($self, $params, $chain) {
+
+ //Invoke the _callable method, then execute the logic below
+ $ctrl = $chain->next($self, $params, $chain);
+
+ //if the user is logged in
+ $user = Auth::check('default');
+ if($user)
+ {
+ //check if they are accessing an admin function
+ if ($ctrl->request->controller == 'admin' && !($user['level'] == 'root' || $user['level'] == 'admin'))
+ {
+ return function() use ($request) {
+
+ //Users / index isn't public derp.
+ return new Response(compact('request') + array('location' => '/'));
+ };
+ }
+
+ //If they aren't trying to access admin, return
+ return $ctrl;
+ }
+ //If they are performing a public action continue,
+ if (isset($ctrl->publicActions) && in_array($params['request']->action, $ctrl->publicActions)) {
+ return $ctrl;
+ }
+
+ //Otherwise, send them to the login page
+ return function() use ($request) {
+ return new Response(compact('request') + array('location' => '/login'));
+ };
+
+
+});
+
+
+
+
+?> \ No newline at end of file
diff --git a/config/bootstrap/cache.php b/config/bootstrap/cache.php
new file mode 100644
index 0000000..68f11e0
--- /dev/null
+++ b/config/bootstrap/cache.php
@@ -0,0 +1,62 @@
+<?php
+/**
+ * Lithium: the most rad php framework
+ *
+ * @copyright Copyright 2010, Union of RAD (http://union-of-rad.org)
+ * @license http://opensource.org/licenses/bsd-license.php The BSD License
+ */
+
+/**
+ * This file creates a default cache configuration using the most optimized adapter available, and
+ * uses it to provide default caching for high-overhead operations.
+ */
+use lithium\storage\Cache;
+use lithium\core\Libraries;
+use lithium\action\Dispatcher;
+use lithium\storage\cache\adapter\Apc;
+
+if (PHP_SAPI === 'cli') {
+ return;
+}
+
+/**
+ * If APC is not available and the cache directory is not writeable, bail out. This block should be
+ * removed post-install, and the cache should be configured with the adapter you plan to use.
+ */
+$cachePath = Libraries::get(true, 'resources') . '/tmp/cache';
+
+if (!($apcEnabled = Apc::enabled()) && !is_writable($cachePath)) {
+ return;
+}
+
+/**
+ * This configures the default cache, based on whether ot not APC user caching is enabled. If it is
+ * not, file caching will be used. Most of this code is for getting you up and running only, and
+ * should be replaced with a hard-coded configuration, based on the cache(s) you plan to use.
+ */
+$default = array('adapter' => 'File', 'strategies' => array('Serializer'));
+
+if ($apcEnabled) {
+ $default = array('adapter' => 'Apc');
+}
+Cache::config(compact('default'));
+
+/**
+ * Caches paths for auto-loaded and service-located classes.
+ */
+Dispatcher::applyFilter('run', function($self, $params, $chain) {
+ $key = md5(LITHIUM_APP_PATH) . '.core.libraries';
+
+ if ($cache = Cache::read('default', $key)) {
+ $cache = (array) $cache + Libraries::cache();
+ Libraries::cache($cache);
+ }
+ $result = $chain->next($self, $params, $chain);
+
+ if ($cache != Libraries::cache()) {
+ Cache::write('default', $key, Libraries::cache(), '+1 day');
+ }
+ return $result;
+});
+
+?> \ No newline at end of file
diff --git a/config/bootstrap/connections.php b/config/bootstrap/connections.php
new file mode 100644
index 0000000..a9355e6
--- /dev/null
+++ b/config/bootstrap/connections.php
@@ -0,0 +1,72 @@
+<?php
+/**
+ * Lithium: the most rad php framework
+ *
+ * @copyright Copyright 2010, Union of RAD (http://union-of-rad.org)
+ * @license http://opensource.org/licenses/bsd-license.php The BSD License
+ */
+
+/**
+ * ### Configuring backend database connections
+ *
+ * Lithium supports a wide variety relational and non-relational databases, and is designed to allow
+ * and encourage you to take advantage of multiple database technologies, choosing the most optimal
+ * one for each task.
+ *
+ * As with other `Adaptable`-based configurations, each database configuration is defined by a name,
+ * and an array of information detailing what database adapter to use, and how to connect to the
+ * database server. Unlike when configuring other classes, `Connections` uses two keys to determine
+ * which class to select. First is the `'type'` key, which specifies the type of backend to
+ * connect to. For relational databases, the type is set to `'database'`. For HTTP-based backends,
+ * like CouchDB, the type is `'http'`. Some backends have no type grouping, like MongoDB, which is
+ * unique and connects via a custom PECL extension. In this case, the type is set to `'MongoDb'`,
+ * and no `'adapter'` key is specified. In other cases, the `'adapter'` key identifies the unique
+ * adapter of the given type, i.e. `'MySql'` for the `'database'` type, or `'CouchDb'` for the
+ * `'http'` type. Note that while adapters are always specified in CamelCase form, types are
+ * specified either in CamelCase form, or in underscored form, depending on whether an `'adapter'`
+ * key is specified. See the examples below for more details.
+ *
+ * ### Multiple environments
+ *
+ * As with other `Adaptable` classes, `Connections` supports optionally specifying different
+ * configurations per named connection, depending on the current environment. For information on
+ * specifying environment-based configurations, see the `Environment` class.
+ *
+ * @see lithium\core\Adaptable
+ * @see lithium\core\Environment
+ */
+use lithium\data\Connections;
+
+/**
+ * Uncomment this configuration to use MongoDB as your default database.
+ */
+ Connections::add('default', array(
+ 'type' => 'MongoDb',
+ 'host' => 'localhost',
+ 'database' => 'otakuhub',
+ 'persistent' => 'foo'
+ ));
+
+/**
+ * Uncomment this configuration to use CouchDB as your default database.
+ */
+// Connections::add('default', array(
+// 'type' => 'http',
+// 'adapter' => 'CouchDb',
+// 'host' => 'localhost',
+// 'database' => 'my_app'
+// ));
+
+/**
+ * Uncomment this configuration to use MySQL as your default database.
+ */
+// Connections::add('default', array(
+// 'type' => 'database',
+// 'adapter' => 'MySql',
+// 'host' => 'localhost',
+// 'login' => 'root',
+// 'password' => '',
+// 'database' => 'my_app'
+// ));
+
+?> \ No newline at end of file
diff --git a/config/bootstrap/console.php b/config/bootstrap/console.php
new file mode 100644
index 0000000..e47e2c0
--- /dev/null
+++ b/config/bootstrap/console.php
@@ -0,0 +1,19 @@
+<?php
+/**
+ * Lithium: the most rad php framework
+ *
+ * @copyright Copyright 2010, Union of RAD (http://union-of-rad.org)
+ * @license http://opensource.org/licenses/bsd-license.php The BSD License
+ */
+
+use lithium\console\Dispatcher;
+
+Dispatcher::applyFilter('_call', function($self, $params, $chain) {
+ $params['callable']->response->styles(array(
+ 'heading' => '\033[1;30;46m'
+ ));
+ return $chain->next($self, $params, $chain);
+});
+
+
+?> \ No newline at end of file
diff --git a/config/bootstrap/error.php b/config/bootstrap/error.php
new file mode 100644
index 0000000..dc33bf5
--- /dev/null
+++ b/config/bootstrap/error.php
@@ -0,0 +1,37 @@
+<?php
+/**
+ * First, import the relevant Lithium core classes.
+ */
+use \lithium\core\ErrorHandler;
+use \lithium\analysis\Logger;
+use lithium\action\Response;
+use lithium\net\http\Media;
+
+/**
+ * Then, set up a basic logging configuration that will write to a file.
+ */
+Logger::config(array(
+ 'error' => array('adapter' => 'File')
+));
+
+
+ErrorHandler::apply('lithium\action\Dispatcher::run', array(), function($info, $params) {
+ $response = new Response(array('request' => $params['request']));
+
+ $message = "/(^Template not found|^Controller '\w+' not found|^Action '\w+' not found)/";
+ $template = (preg_match($message, $info['message'])) ? '404' : '500';
+
+ Logger::write('error', "{$info['file']} : {$info['line']} : {$info['message']}");
+ switch($template){
+ case '500':
+ debug($info);die;
+ break;
+ }
+ Media::render($response, compact('info', 'params'), array(
+ 'controller' => 'errors',
+ 'template' => $template,
+ 'layout' => 'default',
+ 'request' => $params['request']
+ ));
+ return $response;
+}); \ No newline at end of file
diff --git a/config/bootstrap/errors.php b/config/bootstrap/errors.php
new file mode 100644
index 0000000..8354478
--- /dev/null
+++ b/config/bootstrap/errors.php
@@ -0,0 +1,28 @@
+<?php
+/**
+ * Lithium: the most rad php framework
+ *
+ * @copyright Copyright 2011, Union of RAD (http://union-of-rad.org)
+ * @license http://opensource.org/licenses/bsd-license.php The BSD License
+ */
+
+use lithium\core\ErrorHandler;
+use lithium\action\Response;
+use lithium\net\http\Media;
+
+ErrorHandler::apply('lithium\action\Dispatcher::run', array(), function($info, $params) {
+ $response = new Response(array(
+ 'request' => $params['request'],
+ 'status' => $info['exception']->getCode()
+ ));
+
+ Media::render($response, compact('info', 'params'), array(
+ 'controller' => '_errors',
+ 'template' => 'development',
+ 'layout' => 'error',
+ 'request' => $params['request']
+ ));
+ return $response;
+});
+
+?> \ No newline at end of file
diff --git a/config/bootstrap/g11n.php b/config/bootstrap/g11n.php
new file mode 100644
index 0000000..e96241f
--- /dev/null
+++ b/config/bootstrap/g11n.php
@@ -0,0 +1,149 @@
+<?php
+/**
+ * Lithium: the most rad php framework
+ *
+ * @copyright Copyright 2010, Union of RAD (http://union-of-rad.org)
+ * @license http://opensource.org/licenses/bsd-license.php The BSD License
+ */
+
+/**
+ * This bootstrap file contains class configuration for all aspects of globalizing your application,
+ * including localization of text, validation rules, setting timezones and character inflections,
+ * and identifying a user's locale.
+ */
+use lithium\core\Libraries;
+use lithium\core\Environment;
+use lithium\g11n\Locale;
+use lithium\g11n\Catalog;
+use lithium\g11n\Message;
+use lithium\util\Inflector;
+use lithium\util\Validator;
+use lithium\net\http\Media;
+use lithium\action\Dispatcher as ActionDispatcher;
+use lithium\console\Dispatcher as ConsoleDispatcher;
+
+/**
+ * Sets the default timezone used by all date/time functions.
+ */
+date_default_timezone_set('UTC');
+
+/**
+ * Adds globalization specific settings to the environment.
+ *
+ * The settings for the current locale, time zone and currency are kept as environment
+ * settings. This allows for _centrally_ switching, _transparently_ setting and retrieving
+ * globalization related settings.
+ *
+ * The environment settings are:
+ *
+ * - `'locale'` The effective locale.
+ * - `'locales'` Application locales available mapped to names. The available locales are used
+ * to negotiate he effective locale, the names can be used i.e. when displaying
+ * a menu for choosing the locale to users.
+ */
+$locale = 'en';
+$locales = array('en' => 'English');
+
+Environment::set('production', compact('locale', 'locales'));
+Environment::set('development', compact('locale', 'locales'));
+Environment::set('test', array('locale' => 'en', 'locales' => array('en' => 'English')));
+
+/**
+ * Globalization (g11n) catalog configuration. The catalog allows for obtaining and
+ * writing globalized data. Each configuration can be adjusted through the following settings:
+ *
+ * - `'adapter'` _string_: The name of a supported adapter. The builtin adapters are `Memory` (a
+ * simple adapter good for runtime data and testing), `Php`, `Gettext`, `Cldr` (for
+ * interfacing with Unicode's common locale data repository) and `Code` (used mainly for
+ * extracting message templates from source code).
+ *
+ * - `'path'` All adapters with the exception of the `Memory` adapter require a directory
+ * which holds the data.
+ *
+ * - `'scope'` If you plan on using scoping i.e. for accessing plugin data separately you
+ * need to specify a scope for each configuration, except for those using the `Memory`,
+ * `Php` or `Gettext` adapter which handle this internally.
+ */
+Catalog::config(array(
+ 'runtime' => array(
+ 'adapter' => 'Memory'
+ ),
+ // 'app' => array(
+ // 'adapter' => 'Gettext',
+ // 'path' => Libraries::get(true, 'resources') . '/g11n'
+ // ),
+ 'lithium' => array(
+ 'adapter' => 'Php',
+ 'path' => LITHIUM_LIBRARY_PATH . '/lithium/g11n/resources/php'
+ )
+) + Catalog::config());
+
+/**
+ * Integration with `Inflector`.
+ */
+// Inflector::rules('transliteration', Catalog::read(true, 'inflection.transliteration', 'en'));
+
+/**
+ * Inflector configuration examples. If your application has custom singular or plural rules, or
+ * extra non-ASCII characters to transliterate, you can configure that by uncommenting the lines
+ * below.
+ */
+// Inflector::rules('singular', array('rules' => array('/rata/' => '\1ratus')));
+// Inflector::rules('singular', array('irregular' => array('foo' => 'bar')));
+//
+// Inflector::rules('plural', array('rules' => array('/rata/' => '\1ratum')));
+// Inflector::rules('plural', array('irregular' => array('bar' => 'foo')));
+//
+// Inflector::rules('transliteration', array('/É|Ê/' => 'E'));
+//
+// Inflector::rules('uninflected', 'bord');
+// Inflector::rules('uninflected', array('bord', 'baird'));
+
+
+/**
+ * Integration with `View`. Embeds message translation aliases into the `View`
+ * class (or other content handler, if specified) when content is rendered. This
+ * enables translation functions, i.e. `<?=$t("Translated content"); ?>`.
+ */
+Media::applyFilter('_handle', function($self, $params, $chain) {
+ $params['handler'] += array('outputFilters' => array());
+ $params['handler']['outputFilters'] += Message::aliases();
+ return $chain->next($self, $params, $chain);
+});
+
+/**
+ * Integration with `Validator`. You can load locale dependent rules into the `Validator`
+ * by specifying them manually or retrieving them with the `Catalog` class.
+ */
+foreach (array('phone', 'postalCode', 'ssn') as $name) {
+ Validator::add($name, Catalog::read(true, "validation.{$name}", 'en_US'));
+}
+
+/**
+ * Intercepts dispatching processes in order to set the effective locale by using
+ * the locale of the request or if that is not available retrieving a locale preferred
+ * by the client.
+ */
+ActionDispatcher::applyFilter('_callable', function($self, $params, $chain) {
+ $request = $params['request'];
+ $controller = $chain->next($self, $params, $chain);
+
+ if (!$request->locale) {
+ $request->params['locale'] = Locale::preferred($request);
+ }
+ Environment::set(Environment::get(), array('locale' => $request->locale));
+ return $controller;
+});
+
+ConsoleDispatcher::applyFilter('_callable', function($self, $params, $chain) {
+ $request = $params['request'];
+ $command = $chain->next($self, $params, $chain);
+
+ if (!$request->locale) {
+ $request->params['locale'] = Locale::preferred($request);
+ }
+ Environment::set(Environment::get(), array('locale' => $request->locale));
+ return $command;
+});
+
+?> \ No newline at end of file
diff --git a/config/bootstrap/libraries.php b/config/bootstrap/libraries.php
new file mode 100644
index 0000000..4bffbdd
--- /dev/null
+++ b/config/bootstrap/libraries.php
@@ -0,0 +1,127 @@
+<?php
+/**
+ * Lithium: the most rad php framework
+ *
+ * @copyright Copyright 2010, Union of RAD (http://union-of-rad.org)
+ * @license http://opensource.org/licenses/bsd-license.php The BSD License
+ */
+
+/**
+ * The libraries file is where you configure the various plugins, frameworks, and other libraries
+ * to be used by your application, including your application itself. This file also defines some
+ * global constants used to tell Lithium where to find your application and support libraries
+ * (including Lithium itself). It uses the `Libraries` class to add configurations for the groups of
+ * classes used in your app.
+ *
+ * In Lithium, a _library_ is any collection of classes located in a single base directory, which
+ * all share the same class-to-file naming convention, and usually a common class or namespace
+ * prefix. While all collections of classes are considered libraries, there are two special types of
+ * libraries:
+ *
+ * - **Applications**: Applications are libraries which follow the organizational conventions that
+ * Lithium defines for applications (see `Libraries::locate()` and `Libraries::paths()`), and
+ * which also include a web-accessible document root (i.e. the `webroot/` folder), and can
+ * dispatch HTTP requests (i.e. through `webroot/index.php`).
+ *
+ * - **Plugins**: Plugins are libraries which generally follow the same organizational conventions
+ * as applications, but are designed to be used within the context of another application. They
+ * _may_ include a public document root for supporting assets, but this requires a symlink from
+ * `libraries/<plugin-name>/webroot` to `<app-name>/webroot/<plugin-name>` (recommended for
+ * production), or a media filter to load plugin resources (see `/config/bootstrap/media.php`).
+ *
+ * Note that a library can be designed as both an application and a plugin, but this requires some
+ * special considerations in the bootstrap process, such as removing any `require` statements, and
+ * conditionally defining the constants below.
+ *
+ * By default, libraries are stored in the base `/libraries` directory, or in the
+ * application-specific `<app-name>/libraries` directory. Libraries can be loaded from either place
+ * without additional configuration, but note that if the same library is in both directories, the
+ * application-specific `libraries` directory will override the global one.
+ *
+ * The one exception to this is the _primary_ library, which is an application configured with
+ * `'default' => true` (see below); this library uses the `LITHIUM_APP_PATH` constant (also defined
+ * below) as its path. Note, however, that any library can be overridden with an arbitrary path by
+ * passing the `'path'` key to its configuration. See `Libraries::add()` for more options.
+ *
+ * @see lithium\core\Libraries
+ */
+
+/**
+ * This is the path to your application's directory. It contains all the sub-folders for your
+ * application's classes and files. You don't need to change this unless your webroot folder is
+ * stored outside of your app folder.
+ */
+define('LITHIUM_APP_PATH', dirname(dirname(__DIR__)));
+
+/**
+ * This is the path to the class libraries used by your application, and must contain a copy of the
+ * Lithium core. By default, this directory is named `libraries`, and resides in the same
+ * directory as your application. If you use the same libraries in multiple applications, you can
+ * set this to a shared path on your server.
+ */
+define('LITHIUM_LIBRARY_PATH', dirname(LITHIUM_APP_PATH) . '/libraries');
+
+/**
+ * Locate and load Lithium core library files. Throws a fatal error if the core can't be found.
+ * If your Lithium core directory is named something other than `lithium`, change the string below.
+ */
+if (!include LITHIUM_LIBRARY_PATH . '/lithium/core/Libraries.php') {
+ $message = "Lithium core could not be found. Check the value of LITHIUM_LIBRARY_PATH in ";
+ $message .= __FILE__ . ". It should point to the directory containing your ";
+ $message .= "/libraries directory.";
+ throw new ErrorException($message);
+}
+
+use lithium\core\Libraries;
+
+/**
+ * Optimize default request cycle by loading common classes. If you're implementing custom
+ * request/response or dispatch classes, you can safely remove these. Actually, you can safely
+ * remove them anyway, they're just there to give slightly you better out-of-the-box performance.
+ */
+require LITHIUM_LIBRARY_PATH . '/lithium/core/Object.php';
+require LITHIUM_LIBRARY_PATH . '/lithium/core/StaticObject.php';
+require LITHIUM_LIBRARY_PATH . '/lithium/util/Collection.php';
+require LITHIUM_LIBRARY_PATH . '/lithium/util/collection/Filters.php';
+require LITHIUM_LIBRARY_PATH . '/lithium/util/Inflector.php';
+require LITHIUM_LIBRARY_PATH . '/lithium/util/String.php';
+require LITHIUM_LIBRARY_PATH . '/lithium/core/Adaptable.php';
+require LITHIUM_LIBRARY_PATH . '/lithium/core/Environment.php';
+require LITHIUM_LIBRARY_PATH . '/lithium/net/Message.php';
+require LITHIUM_LIBRARY_PATH . '/lithium/net/http/Message.php';
+require LITHIUM_LIBRARY_PATH . '/lithium/net/http/Media.php';
+require LITHIUM_LIBRARY_PATH . '/lithium/net/http/Request.php';
+require LITHIUM_LIBRARY_PATH . '/lithium/net/http/Response.php';
+require LITHIUM_LIBRARY_PATH . '/lithium/net/http/Route.php';
+require LITHIUM_LIBRARY_PATH . '/lithium/net/http/Router.php';
+require LITHIUM_LIBRARY_PATH . '/lithium/action/Controller.php';
+require LITHIUM_LIBRARY_PATH . '/lithium/action/Dispatcher.php';
+require LITHIUM_LIBRARY_PATH . '/lithium/action/Request.php';
+require LITHIUM_LIBRARY_PATH . '/lithium/action/Response.php';
+require LITHIUM_LIBRARY_PATH . '/lithium/template/View.php';
+require LITHIUM_LIBRARY_PATH . '/lithium/template/view/Renderer.php';
+require LITHIUM_LIBRARY_PATH . '/lithium/template/view/Compiler.php';
+require LITHIUM_LIBRARY_PATH . '/lithium/template/view/adapter/File.php';
+require LITHIUM_LIBRARY_PATH . '/lithium/storage/Cache.php';
+require LITHIUM_LIBRARY_PATH . '/lithium/storage/cache/adapter/Apc.php';
+
+
+/**
+ * Add the Lithium core library. This sets default paths and initializes the autoloader. You
+ * generally should not need to override any settings.
+ */
+Libraries::add('lithium');
+
+/**
+ * Add the application. You can pass a `'path'` key here if this bootstrap file is outside of
+ * your main application, but generally you should not need to change any settings.
+ */
+Libraries::add('app', array('default' => true));
+
+/**
+ * Add some plugins:
+ */
+// Libraries::add('li3_docs');
+Libraries::add('li3_flash_message');
+Libraries::add('li3_paginate');
+?> \ No newline at end of file
diff --git a/config/bootstrap/media.php b/config/bootstrap/media.php
new file mode 100644
index 0000000..66e002d
--- /dev/null
+++ b/config/bootstrap/media.php
@@ -0,0 +1,63 @@
+<?php
+/**
+ * Lithium: the most rad php framework
+ *
+ * @copyright Copyright 2010, Union of RAD (http://union-of-rad.org)
+ * @license http://opensource.org/licenses/bsd-license.php The BSD License
+ */
+
+/**
+ * The `Collection` class, which serves as the base class for some of Lithium's data objects
+ * (`RecordSet` and `Document`) provides a way to manage data collections in a very flexible and
+ * intuitive way, using closures and SPL interfaces. The `to()` method allows a `Collection` (or
+ * subclass) to be converted to another format, such as an array. The `Collection` class also allows
+ * other classes to be connected as handlers to convert `Collection` objects to other formats.
+ *
+ * The following connects the `Media` class as a format handler, which allows `Collection`s to be
+ * exported to any format with a handler provided by `Media`, i.e. JSON. This enables things like
+ * the following:
+ * {{{
+ * $posts = Post::find('all');
+ * return $posts->to('json');
+ * }}}
+ */
+use lithium\util\Collection;
+
+Collection::formats('lithium\net\http\Media');
+
+/**
+ * This filter is a convenience method which allows you to automatically route requests for static
+ * assets stored within active plugins. For example, given a JavaScript file `bar.js` inside the
+ * `li3_foo` plugin installed in an application, requests to `http://app/path/li3_foo/js/bar.js`
+ * will be routed to `/path/to/app/libraries/plugins/li3_foo/webroot/js/bar.js` on the filesystem.
+ * In production, it is recommended that you disable this filter in favor of symlinking each
+ * plugin's `webroot` directory into your main application's `webroot` directory, or adding routing
+ * rules in your web server's configuration.
+ */
+use lithium\action\Dispatcher;
+use lithium\action\Response;
+use lithium\net\http\Media;
+
+Dispatcher::applyFilter('_callable', function($self, $params, $chain) {
+ list($library, $asset) = explode('/', $params['request']->url, 2) + array("", "");
+
+ if ($asset && ($path = Media::webroot($library)) && file_exists($file = "{$path}/{$asset}")) {
+ return function() use ($file) {
+ $info = pathinfo($file);
+ $media = Media::type($info['extension']);
+ $content = (array) $media['content'];
+
+ return new Response(array(
+ 'headers' => array('Content-type' => reset($content)),
+ 'body' => file_get_contents($file)
+ ));
+ };
+ }
+ return $chain->next($self, $params, $chain);
+});
+
+Media::type('jpg', 'image/jpeg', array('cast' => false, 'encode' => function($data) {
+ return $data['photo']->file->getBytes();
+ }));
+
+?> \ No newline at end of file
diff --git a/config/bootstrap/session.php b/config/bootstrap/session.php
new file mode 100644
index 0000000..c664be4
--- /dev/null
+++ b/config/bootstrap/session.php
@@ -0,0 +1,49 @@
+<?php
+/**
+ * Lithium: the most rad php framework
+ *
+ * @copyright Copyright 2010, Union of RAD (http://union-of-rad.org)
+ * @license http://opensource.org/licenses/bsd-license.php The BSD License
+ */
+
+/**
+ * This configures your session storage. The Cookie storage adapter must be connected first, since
+ * it intercepts any writes where the `'expires'` key is set in the options array.
+ */
+use lithium\storage\Session;
+
+/*
+Session::config(array(
+ 'cookie' => array('adapter' => 'Cookie'),
+ 'default' => array('adapter' => 'Php')
+));
+*/
+/**
+ * Uncomment the lines below to enable forms-based authentication. This configuration will attempt
+ * to authenticate users against a `Users` model. In a controller, run
+ * `Auth::check('default', $this->request)` to authenticate a user. This will check the POST data of
+ * the request (`lithium\action\Request::$data`) to see if the fields match the `'fields'` key of
+ * the configuration below. If successful, it will write the data returned from `Users::first()` to
+ * the session using the default session configuration.
+ *
+ * Once the session data is written, you can call `Auth::check('default')` to check authentication
+ * status or retrieve the user's data from the session. Call `Auth::clear('default')` to remove the
+ * user's authentication details from the session. This effectively logs a user out of the system.
+ * To modify the form input that the adapter accepts, or how the configured model is queried, or how
+ * the data is stored in the session, see the `Form` adapter API or the `Auth` API, respectively.
+ *
+ * @see lithium\security\auth\adapter\Form
+ * @see lithium\action\Request::$data
+ * @see lithium\security\Auth
+ */
+// use lithium\security\Auth;
+
+// Auth::config(array(
+// 'default' => array(
+// 'adapter' => 'Form',
+// 'model' => 'Users',
+// 'fields' => array('username', 'password')
+// )
+// ));
+
+?> \ No newline at end of file