Hi all,
I've started working on the 3.x version of the Jaxon library, and there's already a few beta releases. It's still an ongoing work, and I would like to share the main features that are expected in the next releases.
All comments and suggestions are welcome.
- Lightweight class registration
Until now, registering a user callable object with jaxon actually means creating an instance of both the class and the CallableObject
, which is the wrapper class Jaxon internally uses to generate Javascript code and handle Ajax requests.
$jaxon->register(Jaxon::CALLABLE_OBJECT, new FirstClass());
$jaxon->register(Jaxon::CALLABLE_OBJECT, new SecondClass());
$jaxon->register(Jaxon::CALLABLE_OBJECT, new ThirdClass());
When using the jaxon-armada
or any framework integration package, we had to avoid registering the classes when processing a request, since only the requested class actually needs to be instanciated.
if($armada->canProcessRequest())
{
// Process the request
$armada->processRequest();
}
else
{
// Register all the classes. Then they are all instanciated.
$armada->register();
}
In the 3.x version, the user registers classes instead of objects, and Jaxon will instanciate them when needed.
$jaxon->register(Jaxon::CALLABLE_CLASS, 'FirstClass');
$jaxon->register(Jaxon::CALLABLE_CLASS, 'SecondClass');
$jaxon->register(Jaxon::CALLABLE_CLASS, 'ThirdClass');
Directories will also be registered the same way, with no object created until it is actually needed.
$jaxon->register(Jaxon::CALLABLE_DIR, '/path/to/the/first/dir/');
// With namespace
$jaxon->register(Jaxon::CALLABLE_DIR, '/path/to/the/second/dir/', ['namespace' => 'Ns\Jaxon\Second']);
The same will apply to jaxon-armada
or any framework integration package.
// Register the classes. No object is created.
$armada->register();
if($armada->canProcessRequest())
{
// Process the request. Only the requested object is created.
$armada->processRequest();
}
- Dependency injection
This feature is already implemented in the latest release https://www.jaxon-php.org/docs/advanced/dependency-injection.html.
The next releases will take the feature a step further by allowing the use of third party dependencies. For example when using the Laravel framework, the user will be able to inject Laravel dependencies in Jaxon classes with no extra cost.
- Config based registration
This feature will let the user specify the functions, classes and namespaces to register in a config file, instead on manually listing them in the code.
Until now, only the jaxon-sentry
-based packages could benefit from this feature.
- Packages
This may be the most important feature planned in the next releases, and also the most hard to implement.
A Jaxon package bundles a set of classes and templates, and implements all the features needed to provide a service, including the required user interfaces.
After installing a Composer package, setting some config options and adding a couple of lines in a template, the user will be able to gain access to a service from a new or an existing application.
I need your comments
Please let me know if there's any feature you would like to see in the next releases, if you foresee any issue with the planned features, or if you have any questions.
Thank you.