[Solar-talk] Sungrazr
Clay Loveless
clay at killersoft.com
Tue Jan 16 15:18:19 PST 2007
Hey folks,
Since we're on the subject of Solar-friendly libraries, I thought I'd
mention Sungrazr.
It's been kind of under the radar, I suppose ... I don't think I've
promoted it anywhere ... but it's the home of several libraries that
I'm working on grooming for possible Solar core acceptance.
A couple of them are now stable enough to be ready for some community
feedback.
The source can be browsed here:
http://sungrazr.com/browser/trunk/Sungrazr
... and may be checked out here:
http://sungrazr.com/svn/trunk/Sungrazr
*******************************
Ready for review & unit-tested:
Sungrazr_Xml_Simple
Adds Solar-like loading to SimpleXML functionality, including a
SimpleXMLElement-derived class
that adds a toArray() method to SimpleXML.
*******************************
Ready for review, not yet unit-tested:
Sungrazr_Console
Sungrazr_ConsoleApp
Brings an MVC type structure to command line applications. The
goal is being able to write
command line tools the same way you'd write a Solar web apps.
I've created a (VERY!) simple "Hello World" console app, which can be
called two ways:
Put this in a file called 'hello'
-----
#!/usr/bin/env php -q
<?php
require 'Solar.php';
Solar::start(false);
$app = Solar::factory('Sungrazr_ConsoleApp_Hello');
$app->run();
-------
- make it executable, and then:
$ hello
(Runs the Hello application ONLY)
OR, using a controller front-end, you can install the 'sungrazr'
console app, which would be this:
In your bin path, as 'sungrazr':
------------------
#!/usr/bin/env php
<?php
require 'Solar.php';
Solar::start(array());
$app = Solar::factory('Sungrazr_Controller_Console');
$app->run();
-------------------
... and set to executable, allows:
$ sungrazr hello
OR
$ sungrazr hi
You can also set locale ... currently 'sungrazr hi -l pt_BR' will say
hi to you in Portuguese.
Documentation and unit tests coming soon, as well as a "generator"
app based on this library.
If you want to create similar command-line tool, you'd just need to
copy the 'sungrazr' file above, and rename to 'tipos' (for example),
and then 'tipos [cmd]' will map to 'Tipos_ConsoleApp_[cmd]'.
Feedback welcome.
*******************************
Just getting started:
Sungrazr_Stream
Sungrazr_Socket_Client
Sungrazr_Http_Request
Sungrazr_Http_Response
Sungrazr_Http_Message
Sungrazr_Http_QueryString
Stream and Socket_Client are in pretty good shape already. They're
far enough along that I've begun work on the Http_* classes, which
are modeled after the PECL HTTP extension. Like my Solar_Json class,
the Http classes will leverage native extensions as much as possible
if they exist, and will do their thing without them in a transparent
way if they aren't installed. It won't be ready for prime-time until
all of pecl_http's unit test cases pass with identical results when
enabled/disabled through Sungrazr_Http*.
Comments welcome on all this stuff. Some of it, like
Sungrazr_ConsoleApp*, is already in use in a production
environment ... we're running some cronjob-based tools at Mashery
through it, and we have a list of more apps that need this sort of
app to be written.
Enjoy!
-Clay
--
Killersoft.com
More information about the solar-talk
mailing list