This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
khosb/includes/kohana/modules/minion/guide/minion/setup.md
2012-12-21 12:59:09 +11:00

32 lines
1.1 KiB
Markdown

# Minion Setup
To use minion, you'll need to make a small change to your index.php file:
-/**
- * Execute the main request. A source of the URI can be passed, eg: $_SERVER['PATH_INFO'].
- * If no source is specified, the URI will be automatically detected.
- */
-echo Request::factory()
- ->execute()
- ->send_headers(TRUE)
- ->body();
+if (PHP_SAPI == 'cli') // Try and load minion
+{
+ class_exists('Minion_Task') OR die('minion required!');
+ set_exception_handler(array('Kohana_Minion_Exception_Handler', 'handler'));
+
+ Minion_Task::factory(Minion_CLI::options())->execute();
+}
+else
+{
+ /**
+ * Execute the main request. A source of the URI can be passed, eg: $_SERVER['PATH_INFO'].
+ * If no source is specified, the URI will be automatically detected.
+ */
+ echo Request::factory()
+ ->execute()
+ ->send_headers(TRUE)
+ ->body();
+}
This will short-circuit your index file to intercept any cli calls, and route them to the minion module.