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.
redir/includes/kohana/modules/minion/guide/minion/setup.md
2013-04-13 16:36:38 +10:00

1.1 KiB

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.