Ticket #480 (new enhancement)

Opened 21 months ago

Last modified 5 weeks ago

Implement Console Request, Routing, Response etc

Reported by: mailing_lists@… Owned by: david
Priority: normal Milestone: 1.0
Component: _OTHER_ Version:
Severity: major Keywords: console commandline
Cc: Patch attached: no

Description

This is my stab at implementing a console request/routing/response. With routing, the command gets called like this:

cli.php <command> -param1 paramvalue1 -param2 -param3 paramvalue3

Without routing, the call is like this:

cli.php <module.action> -param1 paramvalue1 -param2 -param3 paramvalue3

All arguments that start with a dash(-) or double dash (--) will be regarded as paramname and the following argument as param value if it does not start with a dash or double dash. Parameters that have no following argument will be set to "true" to indicate that they have been passed.

Attachments

AgaviConsole.patch.txt (11.4 KB) - added by mailing_lists@… 21 months ago.
a patch to enable console apps
Console.patch.txt (13.8 KB) - added by ross 9 months ago.
Updated Console patch
autoload.xml (0.8 KB) - added by ross 9 months ago.
app/config/autoload.xml
factories.xml (1.4 KB) - added by ross 9 months ago.
app/config/factories.xml
ConsoleRequest.class.php (2.6 KB) - added by ross 9 months ago.
app/lib/console/ConsoleRequest.class.php
ConsoleResponse.class.php (2.7 KB) - added by ross 9 months ago.
app/lib/console/ConsoleResponse.class.php
ProjectBaseAction.class.php (0.9 KB) - added by ross 9 months ago.
app/lib/action/ProjectBaseAction.class.php
cli.php (1.8 KB) - added by ross 9 months ago.
pub/cli.php
ConsoleRouting.class.php (2.5 KB) - added by ross 9 months ago.

Change History

Changed 21 months ago by mailing_lists@…

a patch to enable console apps

Changed 21 months ago by mailing_lists@…

forgot to mention: the patch introduces a new execution type, executeConsole() which falls back to execute() if not declared in the action.

Changed 21 months ago by mailing_lists@…

You must add this to the factories.xml to make the console env work

	<configuration context="console">
		<request class="AgaviConsoleRequest" />
		<routing class="AgaviConsoleRouting" />
		<response class="AgaviConsoleResponse" />
	</configuration>

Changed 21 months ago by david

  • keywords commandline added
  • version HEAD deleted
  • milestone changed from 0.11 to 1.0

Changed 11 months ago by david

  • severity changed from normal to major

Changed 9 months ago by ross

  • has_patch unset

I've adding a new patch - Console.patch.txt. (You might want to split it up into parts before applying to your code base) If needs be I can add the files separately - just ask!

OK - the console files live in app/lib/console and have to be added to autoload.xml There are some changes and by default it calls the console method - I have extended the ProjectBaseAction? to have a handler for executeConsole - so you override that an your away.

The factories.xml has a bit more information in it, like turning off sessions, other than that its much the same as the original - just some extra methods in the core Console classes that were missing.

I've also added an example route in routes.xml which is called from the commandline like so:

   /pub/cli.php /cron/tag_cloud/

Changed 9 months ago by ross

Updated Console patch

Changed 9 months ago by ross

Ok adding all the files separately!

Changed 9 months ago by ross

app/config/autoload.xml

Changed 9 months ago by ross

app/config/factories.xml

Changed 9 months ago by ross

app/lib/console/ConsoleRequest.class.php

Changed 9 months ago by ross

app/lib/console/ConsoleResponse.class.php

Changed 9 months ago by ross

app/lib/action/ProjectBaseAction.class.php

Changed 9 months ago by ross

pub/cli.php

Changed 9 months ago by ross

Changed 9 months ago by ross

Updated ConsoleRouting? so can generate web routes - I needed to generate links in emails sent via a cron job.

Its very basic - but can easily be extended - use AgaviWebRouting? as an example.

I also added a console.xml file to store the basic path information i.e.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configurations>
  <configuration>
    <path>http://www.agavi.org/</path>
   </configuration>
</configurations>

Again this can easily be extended!

Changed 9 months ago by david

  • milestone changed from 1.0 to 1.1

Changed 3 months ago by david

  • milestone changed from 1.1 to 1.0

Changed 8 weeks ago by jake

I am using this configuration successfully with a few slight modifications. I had to update the config_handlers.xml as follows:

<?xml version="1.0" encoding="UTF-8"?>
<configurations xmlns="http://agavi.org/agavi/1.0/config" parent="%core.system_config_dir%/config_handlers.xml">
        <configuration>
                <handlers>
                        <handler pattern="console.xml" class="AgaviReturnArrayConfigHandler" />
                </handlers>
        </configuration>
</configurations>

I also updated the ConsoleRouting? class to fix some broken usages of the AgaviWebRouting? class that my models were making.

This works great for allowing unit tests to successfully run.

Changed 5 weeks ago by david

not strictly necessary for 1.0

Add/Change #480 (Implement Console Request, Routing, Response etc)

Author



Action
as new
 
Note: See TracTickets for help on using tickets.