# Robo as a Framework There are multiple ways to use and package Robo scripts; a few of the alternatives are presented below. ## Creating a Standalone Phar with Robo It is possible to create a standalone phar that is implemented with Robo; doing this does not require the RoboFile to be located in the current working directory, or any particular location within your project. To achieve this, first set up your project as shown in the section [Implementing Composer Scripts with Robo](getting-started.md#implementing-composer-scripts-with-robo). Use of the "scripts" section is optional. Next, add an "autoload" section to your composer.json to provide a namespace for your Robo commands: ``` { "name": "myorg/myproject", "require": { "consolidation/Robo": "~1" }, "autoload":{ "psr-4":{ "MyProject\\":"src" } } } ``` Create a new file for your Robo commands, e.g. `class RoboFile` in `namespace MyProject\Commands;` in the file `src\Commands\RoboFile.php`. Optionally, add more task libraries as described in the [extending](extending.md) document. Create a startup script similar to the one below, and add it to the root of your project, or some other location of your choosing: ``` php #!/usr/bin/env php setSearchPattern('*Command.php'); $commandClasses = $discovery->discover('php/MyProject/Commands', '\MyProject\Commands'); ``` Pass the resulting `$commandClasses` to the `Runner()` constructor as shown above. See the annotated-commands project for more information about the different options that the discovery command takes. ## Using Your Own Dependency Injection Container with Robo (Advanced) It is also possible to completely replace the Robo application with your own. To do this, set up your project as described in the sections above, but replace the Robo runner with your own main event loop. Create the Robo dependency injection container: ``` use League\Container\Container; $input = new \Symfony\Component\Console\Input\ArgvInput($argv); $output = new \Symfony\Component\Console\Output\ConsoleOutput(); $conf = new \Robo\Config(); \\ or use your own subclass $app = new \My\Application(); $container = \Robo\Robo::createDefaultContainer($input, $output, $app, $conf); ``` If you are using League\Container (recommended), then you may simply add and share your own classes to the same container. If you are using some other DI container, then you should use [delegate lookup](https://github.com/container-interop/fig-standards/blob/master/proposed/container.md#14-additional-feature-delegate-lookup) to combine them.