Spoova 2.5!

2.5 IS HERE

The version 2.5.0 release is out. This version focuses on stablizing the entire framework with improvements made on the window management system and how it resolves urls. The other fixes focuses on improving helper functions and some important core classes within the framework such as Filemanager, Forms and Session classes. With the new release, the framework's documentation is now available online.

Cli improvements

Some command-line commands were detected to have major issues. These commands include project used for creating new project applications, config:all used for configuration of new files and the migrate command which is used for generating migration files. The errors thrown by these methods have been successfuly resolved.


Form validation improvements
The Form class was improved in three different ways. The first improvement is made through the addition of new form methods which are Form::castError(), Form::castedErrors(), Form::dataval() and Form::onpost() methods. The second and third improvement is made through the introduction of formerror() function and @formerror() template directive. These improvements are made to enable the easy handling of form validation errors.
Form::castError()
This function is used to save entire response of Form::error() into a unique storage space where it can be obtained later after a form validation has been initialized. A sample format is shown below:
  Form::model(new SampleModel);

  Form::loadData((new Request)->data());

  Form::isAuthenticated();

  Form::castError('login');
                                            
In the sample above, the castError() method is used to save any error response found into "sample" unique name which can later be accessed by the Form::castedError(), formerror() or @formerror() directives.
Form::castedError()
This method returns the error saved through Form::castError() method by supplying the unique name with which the error is saved along with a unique error key name that is expected to be returned. Internally generated error keys include csrf:title, csrf:info, mod:, index: and any:. Learn more about casted errors from here.
Form::dataval()
This method returns the corresponding value of a key in the form request data.
Form::onpost()
This method is used to perform a callback function only when a post request is forwarded. The sample of usage is shown below:
    Form::onpost(function() {

        echo "This is a post request";

    });
                                        
This function can also be used along with request submission buttons. For example, assuming we have a request button with the name "login", we can ensure that a post callback is called only when that submit button is clicked. The example is shown below:
    Form::onpost('login', function() {

        echo "This is a post request with request key 'login' ";

    });
                                        
In the sample above, the Form::onpost() will look for a request key "login" in the request data. If the key exists, the callback function will be called else, the callback will be ignored.
Form::register()
This is a new method for registering a form. It is used mainly for performing activities such as signup and login of a user session. A usage sample is shown below:
    Form::onpost(function() {

        Form::register('email', function($userinfo){

            User::login($userinfo);

        });

    });
                                        
The example above is a simple way to register a user session through the Form::register() function. The first argument points to a request data key whose corresponding value is assumed to be the expected session's userid that is later used by the User::login() to initialize a new session.

More information about the Form class is provided here.


Session management

In earlier versions of the framework, sessions were managed using the global session storage. This version has included more methods that can be easily used to manage sessions. More information about these new methods are available here.



Windows improvements

Although, like many other frameworks, spoova favors the MVC pattern, yet the entire systems is managed through a windows-approach which determines how routes are resolved based on three major patterns which are root, path and base url patterns. The windows() function is one which provides a great help when working with routes. In ealier versions of the framework, the window() function returns the following responses when supplied with any of url patterns:

Assuming we are currently on a web page whose url address is http://localhost/app/, this url is assumed to be the index page after the project folder name "app", the following responses will be returned when any of the url patterns is supplied into the window function.

  URL: http://localhost/app/

  window('root'); // empty string
  window('base'); // empty string
  window('path'); // empty string
                                    
Assuming we are currently on the same index page but the url address resembles the format: http://localhost/app/index, this url, the following will be responses of the window function.

  URL: http://localhost/app/index
  
  window('root'); // 'index'
  window('base'); // 'index'
  window('path'); // empty string
                                    
In the samples above, although the two url addresses points to the same index page, the responses when the index name is actually supplied is a bit different. This could cause errors especially when working with window shutter methods. The new version of the framework introduces a new way to address this issue by supplying the "@" symbol on the paths which are expected to be resolved. The sample below shows how the first url will respond when the "@" character is prepeded to the argument

  URL: http://localhost/app/
  
  window('@root'); // 'index'
  window('@base'); // 'index'
  window('@path'); // empty string
                                    
It is suggested to learn more on wvm Pattern and Shutter methods to have a good understanding of how the window() function is used within the window system. It is also suggested to visit window inverse to understand how this can be applied with the inverse operator.


For more details on spoova versions, you can track the spoova version updates from here.