useallfive/doctrine-web-console

Doctrine Web Console Service Provider

v0.1.1 2014-01-13 22:29 UTC

This package is not auto-updated.

Last update: 2024-04-08 13:31:37 UTC


README

SensioLabsInsight

The doctrine web console allows one to execute doctrine console commands via web browser. This is especially useful when one is required to execute commands in an enviroment which does not allow shell access (e.g. Google App Engine).

Installation

Via composer:

php composer.phar require useallfive/doctrine-web-console dev-master

Mount the controller provider to the /console path.

<?php
$app = new Silex\Application();
// ...
$app->mount(
        '/console',
        new \UseAllFive\DoctrineWebConsole\ConsoleControllerProvider()
    )
;
$app->run();

You're all set! Visit the the /console url of your site to use.

Specifying a command path

If a command path is not specified, commands will be executed in the current working directory of the console controller (the web directory of your project). While this is fine for most commands, it's not ideal for a command which requires a path. You can specify a path in the first argument of the ConsoleControllerProvider constructor.

<?php
$app = new Silex\Application();
// ...
$app->mount(
        '/console',
        new \UseAllFive\DoctrineWebConsole\ConsoleControllerProvider(__DIR__)
    )
;
$app->run();

Adding commands

Adding your own Doctrine commands to the web console is trivial. We'll add the Doctrine DataFixtures Command for this example.

The second argument of the ConsoleControllerProvider constructor takes an array of Symfony\Component\Console\Command\Command instances which is then passed to the Doctrine ConsoleRunner.

<?php
$app = new Silex\Application();
// ...
$app->mount(
        '/console',
        new \UseAllFive\DoctrineWebConsole\ConsoleControllerProvider(
            __DIR__,
            array(
                new \UseAllFive\Command\LoadDataFixturesDoctrineCommand(),
            )
        )
    )
;
$app->run();