Migrating from Moajvi 2

0 comments

Posted on 12th April 2014 by Jeff Rogers in Mojavi Project

,

By Tyler Tompkins

Note: This document will be changing frequently as I add more information, and rearrange to create a more logical order and progression of the said information.

* Prerequisites
* First Things First
* The Context
* Translating your Renderer
* View
* Actions
* Configuration
* References

Prerequisites

You should have a decent grasp of Mojavi2 and PHP5 before trying to upgrade to Mojavi3.

If you want a quick crash course of Mojavi 3, see Creating Your First Module 2.
First Things First

Before you begin transferring your applications over from Mojavi2, make sure whatever host you’re using supports PHP5. You can figure out if your host supports PHP5 by running

phpinfo();

Furthermore, you need to download and install the Mojavi3 package, which can be attained by going to this location.
The Context

Probably the most important new and powerful aspect of Mojavi3 is the Context object. Once I figured out what this thing did, I fell in love with it. Basically, it is a sort of catalyst/storage object that allows you to access:

* The $request object via getRequest()
* The $controller object via getController()
* The $user object via getUser()
* The Current Action/Module names via getModuleName() and getActionName()
* And finally the Current module’s directory

More or less, most classes that are exposed to the user/developer (you) are going to have a getContext() function, which will allow you to access this object. And with the recent addition of cascading calls, you can perform operations that you were unable to in php4, for example:

The Old Way:

$obj =& $request->getAttribute(‘myobj’);
$anotherobj =& $obj->doSomethingSpecial();
$anotherobj -> execute();

The New Way:

$this->getContext()->getRequest()->getAttribute(‘myobj’)->doSomethingSpecial()->execute();

Okay, so maybe that wasn’t the best example, as it is rather lengthy, but you get my point, 1 line vs 3 lines, and no possible mistakes when dealing with large objects like copying them over without references, etc.

This subsection is to be continued….
Translating your Renderer

Mojavi2 used ‘renderers’ to translate the API of one templating system into a generic API that would easily allow a developer to switch out one templating system for another. For example, the Smarty templating engine uses $smarty->assign() to allow you to set a variable, while patTemplate, another templating system, uses $pat->addVar(). In Mojavi 2, you would then write or use an existing renderer, which you would then invoke to display your output.

Note: This was done typically through a filter, which would create the renderer object, then assign it to your $request via

$request->setAttribute(‘MyRenderer’,$rendererObj))

Mojavi3 uses largely the same methodology, but instead of getting the renderer directly from the $request object within each of your views, it simply extends the View class.

For example:

abstract class SmartyView extends View
{
…..

function __construct()
{
$this->engine = $this->getContext()->getRequest()->getAttribute(‘MySmartyObj’);
}

public function setAttribute($name, $value)
{
$this->engine->assign($name, $value);
}

…..
}

Note: the use of

$this->engine = $this->getContext()->getRequest()->getAttribute(‘MySmartyObj’);

was simply the best solution I could come up with for getting any object from within the view, you could also have done the following just as easily:

$this->engine = new Smarty();

View

The Mojavi3 View is mostly an abstract class, which provides a skeleton of functions to work with, thus providing the unified API as was achieved in Mojavi2 (It’s unified because you are forced to comply with the naming conventions implemented by the abstract class View.)

Now, instead of intitializing your Renderer object (as you would in Mojavi2) you simply extend View, and initialize that. Like shown above:

abstract class SmartyView extends View
{

is what our new View would look like. To put this new View type into action, we extend it when declaring views for our modules. For example:

class DoSomeActionSuccessView extends SmartyView
{

}

As you can see, this is much more fluid than pulling the renderer out of $request with every new View, it’s also a lot less code that you have to copy and paste, and thus less code to maintain. You may also have noticed that the naming scheme is different for the Views, instead of naming the file DoSomeActionView_success.class.php you would now name it DoSomeActionSuccessView.class.php, and name the class likewise(In Mojavi2 we just named our view classes DoSomeActionView, in Mojavi3 it’s DoSomeActionSuccessView replacing ‘Success’ with your application’s state).

This subsection is to be continued….
Actions

Actions in Mojavi3 are fairly similiar to those of Mojavi2, with a few enhancement and semantic tweaks here and there. Listed Below:

* When returning a VIEW_SUCCESS in Mojavi2, now return the View class constant corresponding to your application state, ie: View::Success, or View::Error
* When checking for view types supporting execution (getRequestMethods) instead of returning REQ_POST etc, return Request::Post etc.
* There is a new return type for getRequestMethods(), Request::All, which serves all request methods.
* The root Action class which all your actions extend now has a getContext() method, which allows you access to the context object.

Configuration

Mojavi3 configurations are done, by default, using .ini files. This simple and straightforward configuration makes configuring mojavi very easy. The base syntax of these ini files is as follows:

[SECTION]

; a comment…..
ConfigKey = “%MO_APP_DIR%/my/config/value”

Because some people might not like ini files, Mojavi3 was created in such a way that you could write your own configuration handlers. For example, if you wanted to use xml files to configure your mojavi, you could write a configuration handler, plug it in, and start using your custom configuration styles.

This subsection is to be continued….
References

To find out more about PHP5 in general go here: Where can I go to learn more?

Incoming search terms:

Migration for Mojavi

0 comments

Posted on 11th April 2014 by Jeff Rogers in Mojavi Project

You should have a decent grasp of Mojavi2 and PHP5 before trying to upgrade to Mojavi3.

If you want a quick crash course of Mojavi 3, see Creating Your First Module 2.
First Things First

Before you begin transferring your applications over from Mojavi2, make sure whatever host you’re using supports PHP5. You can figure out if your host supports PHP5 by running

phpinfo();

Furthermore, you need to download and install the Mojavi3 package, which can be attained by going to this location.
The Context

Probably the most important new and powerful aspect of Mojavi3 is the Context object. Once I figured out what this thing did, I fell in love with it. Basically, it is a sort of catalyst/storage object that allows you to access:

* The $request object via getRequest()
* The $controller object via getController()
* The $user object via getUser()
* The Current Action/Module names via getModuleName() and getActionName()
* And finally the Current module’s directory

More or less, most classes that are exposed to the user/developer (you) are going to have a getContext() function, which will allow you to access quality management software. And with the recent addition of cascading calls, you can perform operations that you were unable to in php4, for example:

The Old Way:

$obj =& $request->getAttribute(’myobj’);
$anotherobj =& $obj->doSomethingSpecial();
$anotherobj -> execute();

Incoming search terms:

What is Mojavi

0 comments

Posted on 9th April 2014 by Jeff Rogers in Mojavi Project

, , , ,

Mojavi is an open-source MVC (model-view-controller) php framework, licensed under the LGPL. Developing with Mojavi php framework enables you to easily divide your web application into tiers, allowing for independent custom web application development. These applications have been tested on various servers and firewall applications. There are numerous solutions that are available in the market like the Cisco ASA 5505 and the HP Proliant Servers that have set the standards in reliability and security within their field. The solutions and programming field has even grown into the telecommunications field with routers like the Cisco 7910 where small and medium size businesses can have a truw communication architecture that runs over an IP protocol enabling you to locate offices and employees anywhere.

serversFeatures

  • Modular Design
  • Filter Chains
  • Action Chains
  • Customizable User Containers
  • Parameter Validation
  • Validator Library
  • Built-in Authentication and Authorization
  • Logging System

What is Mojavi?

Mojavi is a framework developed in PHP and strongly based on the MVC (model-view-controller) application design paradigm. It can be run a variety of network servers that employ security features that will work with the curent MVC model.

What is MVC?

Model-View-Controller is a design pattern for application development. MVC organizes an application into three separate tiers: one for the model, which represents data and handles business logic, the second for presentation and user input, and the third as a controller, which handles incoming requests and controls application flow.

What are the benefits of MVC?

An application designed around MVC is easier to manage because the application is split into tiers, which allow for independent development. This promotes code reusability by building models, which are reusable throughout the application.

Why create an MVC framework for PHP?

Development of PHP scripts without a preconceived plan to manage them is asking for a headache. Before I started developing Mojavi, there weren’t any frameworks that were designed the way I thought a PHP MVC implementation should be designed.

How is Mojavi licensed?

Mojavi is licensed under the LGPL.

Where can I get a copy of Mojavi?

Stable and development releases are available on our downloads page.

User Authentication for Mojavi

0 comments

Posted on 1st April 2014 by Jeff Rogers in Mojavi Project

Mojavi provides two levels of security to control access to actions: the first requires the user to be logged in, the seconds checks for a specific privilege. There are various drivers that you may need on your PC if your are planning working in offline PHP mode in order to have the translations from the source code to the operational values to work.

Basic Authentication

For basic authentication, the following three methods are of importance:

User::setAuthenticated()
User::isAuthenticated()
Action::isSecure()

To implement an action that only logged in users can access, simply overwrite the Action::isSecure() method in your action:

function isSecure()
{
    return true;
}

This will instruct the controller to check $user->isAuthenticated(). If this method returns false, the request will be redirected to the AUTH_MODULE/AUTH_ACTION defined in the configuration file (default is Default/Login/drivers).

You can implement the Default/Login Action to call $user->setAuthenticated(TRUE) if a valid username and password was entered.

Privileges

Privileges are used to differentiate between logged in users. The following methods are important:

User::hasPrivilege()
User::addPrivilege()
Action::getPrivilege()

In addition to Action:isSecure() also overwrite the Action::getPrivilege() method in your action:

function isSecure()
{
    return true;
}

function getPrivilege()
{
    return array('ADMIN');
}

The controller will check if the user has the specified privilege and redirect to the login module/action if this is not the case.

The User::addPrivilege() method can be used to grant a user a certain privilege.

Please have a look at the PrivilegeUser class for more information. You will also want to make sure that any Windows Vista Drivers are up to date on your PC side to help rule out any coding errors due to Java or PHP errors. This tutorial includes a good example of user authentication in action.

Using naming conventions

1 comment

Posted on 29th March 2014 by Jeff Rogers in Mojavi Project

Files

Overall

Mojavi’s file naming conventions are very simple, and overall easy to follow. The drivers that are required should be already included withing the PHP 4.0 structure.All files containing classes (including the framework libraries) are suffixed with .class.php

ex: A file containing the Controller class, would be named Controller.class.php

Actions

All actions in Mojavi are of the form [ActionName]Action.class.php

ex: An update action: UpdateAction.class.php

Views

Views are equally as simple as actions. A view is named after it’s action and driver, and suffixed with View_[viewtype]. Actions have the ability to return different views, under different circumstances. There are three standard view types “input”, “success”, and “error”. You may use any other type of your choosing, but these are likely to be the three you will encounter the most.

ex: The success view for the update action: UpdateView_success.class.php

Templates

Template naming is left up to the developer. There are not restrictions on what these can be named, but it is often useful to name them after the view that called them. You also want to make sure that any drivers software that you have on your servers is updated with the latest patches in order to prevent any security loopholes

Classes

Methods

Migration and file extensions

0 comments

Posted on 6th March 2014 by Jeff Rogers in Mojavi Project

,

The New Way:
Remember that there are certain file extension like the File Extension OGG that you may need to have proper calling attributes around in order to make certain parameters work.

$this->getContext()->getRequest()->getAttribute(’myobj’)->doSomethingSpecial()->execute();

Okay, so maybe that wasn’t the best example, as it is rather lengthy, but you get my point, 1 line vs 3 lines, and no possible mistakes when dealing with large objects like copying them over without references, etc.

This subsection is to be continued….
Translating your Renderer

Mojavi2 used ‘renderers’ to translate the API of one templating system into a generic API that would easily allow a developer to switch out one templating system for another. For example, the Smarty templating engine uses $smarty->assign() to allow you to set a variable, while patTemplate, another templating system, uses $pat->addVar(). In Mojavi 2, you would then write or use an existing renderer, which you would then invoke to display your output and be output in the correct file formats.

Note: This was done typically through a filter, which would create the renderer object, then assign it to your $request via

$request->setAttribute(’MyRenderer’,$rendererObj))

Mojavi3 uses largely the same methodology, but instead of getting the renderer directly from the $request object within each of your views, it simply extends the View class. You may need to udate your file extension parameters and if you get any unknown like File Extension OGG then do a quick search as there are quick fixes and .dll updates that may needed.

For example:

abstract class SmartyView extends View
{
…..

function __construct()
{
$this->engine = $this->getContext()->getRequest()->getAttribute(’MySmartyObj’);
}

public function setAttribute($name, $value)
{
$this->engine->assign($name, $value);
}

…..
}

Note: the use of

$this->engine = $this->getContext()->getRequest()->getAttribute(’MySmartyObj’);

was simply the best solution I could come up with for getting any object from within the view, you could also have done the following just as easily:

$this->engine = new Smarty();

View

The Mojavi3 View is mostly an abstract class, which provides a skeleton of functions to work with, thus providing the unified API as was achieved in Mojavi2 (It’s unified because you are forced to comply with the naming conventions implemented by the abstract class View.)

Now, instead of intitializing your Renderer object (as you would in Mojavi2) you simply extend View, and initialize that. Like shown above:

abstract class SmartyView extends View
{

is what our new View would look like. To put this new View type into action, we extend it when declaring views for our modules. For example:

class DoSomeActionSuccessView extends SmartyView
{

}

As you can see, this is much more fluid than pulling the renderer out of $request with every new View, it’s also a lot less code that you have to copy and paste, and thus less code to maintain. You may also have noticed that the naming scheme is different for the Views, instead of naming the file format or File Extension OGG DoSomeActionView_success.class.php you would now name it DoSomeActionSuccessView.class.php, and name the class likewise(In Mojavi2 we just named our view classes DoSomeActionView, in Mojavi3 it’s DoSomeActionSuccessView replacing ‘Success’ with your application’s state).

This subsection is to be continued….
Actions

Actions in Mojavi3 are fairly similiar to those of Mojavi2, with a few enhancement and semantic tweaks here and there. Listed Below:

* When returning a VIEW_SUCCESS in Mojavi2, now return the View class constant corresponding to your application state, ie: View::Success, or View::Error
* When checking for view types supporting execution (getRequestMethods) instead of returning REQ_POST etc, return Request::Post etc.
* There is a new return type for getRequestMethods(), Request::All, which serves all request methods.
* The root Action class which all your actions extend now has a getContext() method, which allows you access to the context object.

Configuration

Mojavi3 configurations are done, by default, using .ini files. This simple and straightforward configuration makes configuring mojavi very easy. The base syntax of these ini files is as follows:

[SECTION]

; a comment…..
ConfigKey = “%MO_APP_DIR%/my/config/value”

Because some people might not like ini files, Mojavi3 was created in such a way that you could write your own configuration handlers. For example, if you wanted to use xml files to configure your mojavi, you could write a configuration handler, plug it in, and start using your custom configuration styles.

This subsection is to be continued….
References

To find out more about PHP5 in general go here: Where can I go to learn more?

Creating your first Module

0 comments

Posted on 30th September 2013 by Jeff Rogers in Mojavi Project

Creating Your First Module
A work in progress

This tutorial is a work in progress, so you may find parts that don’t completely fit together.
Module where we will also look at various file extension cache options.

The module is where the Model and View takes place in the MVC model. For this first example, we will create a very simple module that will move data from a Action to a View and display it on the screen, through a template.

The module is contained within a directory that carries the name of the module. This resides in the modules directory of the webapp directory. Inside the module directory are sub-directories holding the classes that make up the module. Here is the directory hierarchy:

webapp
|
|—modules
|
|—moduleName
|
|—actions
|
|— config
|
|— lib
|
|— models
|
|— templates
|
|— validate
|
|— views

Minimally, you need the actions, config, templates and views directories. However, I prefer to have a blank module created and just copy and rename it. You can get a copy of the blank module (link to be added). I have chosen to call this module Test

Each module must have a module.ini file in the config directory. If you are looking to buffer your files then file extension cache extensions may be helpful.Here is the module.ini for Test

; +—————————————————————————-+
; | This file is part of the Mojavi package. |
; | Copyright (c) 2003, 2004 Sean Kerr. |
; | |
; | For the full copyright and license information, please view the LICENSE |
; | file that was distributed with this source code. You can also view the |
; | LICENSE file online at http://www.mojavi.org. |
; | ————————————————————————– |
; | MODULE INFORMATION FILE |
; +—————————————————————————-+

[module]

ENABLED = “On”

TITLE = “Getting Started Test Module”

VERSION = “0.1″

NAME = “TestModule”

AUTHOR = “Richard D Shank”

HOMEPAGE = “http://www.mojavi.org”

DESCRIPTION = “A test module”

The module is pretty self explanitory. You can also search the web for various file extension cache options. It is necessary to have ENABLED property set to “On” for the module to be used by Mojavi. Now that we have the module set up, we can work on the classes.
Action

The Action class handles the request for the module. It can be as simple as handling a static html template or a full blown multi-page wizard style form. Just a note to Mojavi 2 users, a significant change from Mojavi 2 to Mojavi 3 is that it is not longer necessary to pass the controller, request and user classes in on many of the methods. These are now accessed through a context class. More on that later.

This is a list of the methods you can use in an Action and an explanation of what they do
execute ()

Note: This method is required in your Action class.

This will execute any application/business logic for the action. This method is reached only after the request methods have been checked and any of the parameters have been validated.

When leaving, the execute() method should tell the controller what view is to be used. This is done by returning a string containing the view name associated with the action or an array of the parent module for the view to be executed, parent action for the view and the name of the view. I will show an example of return both in a later tutorial.
getCredential ()

This is a new feature in Mojavi 3. Basically, a credentials are a privilege array that describes any level of security. They work hand in hand with the security aspects of the User class. For Mojavi 2 users, note that this replaces the old Privileges. But it is also important to know that it can do more than just handle privileges. I will handle the usage of creditials in a later section. For now, it is sufficient to know that we set the creditial requirements for the action inside this method and that it is set to NULL by default.
getDefaultView ()

This is the view that will be executed when a given request is not served by the action. This could happen when a form being displayed for the first time or if we are displaying a static page.

Again, just as with the execute() methoad, a string with a view name or an array of a module/action/view is passed back to the controller. By default it will pass back View::INPUT
getRequestMethods ()

This method will determine what types of requests will be recognized. There are 4 choices:

* Request::GET – Indicates that this action serves only GET requests.
* Request::POST – Indicates that this action serves only POST requests.
* Request::NONE – Indicates that this action serves no requests.

You can also select both GET and POST requests by using Request::GET | Request::POST
handleError ()

Execute any post-validation error application logic.

It also returns the view through a string of the view name or the array of a module/action/view. By default, it passes View::ERROR.
initialize ($context)

You can set up the Action in the initialize() method. In a later tutorial, I’ll give an example of doing this. NOTE: It is worth to note that you must handle the context in the initialize() method. You should do this by

parent::initialize($context);

You also need to return a TRUE or FALSE based on the success of the initialization. By default it is TRUE.
isSecure ()

Does the action require security? TRUE if you do, FALSE otherwise. It is FALSE by default.
validate ()

This is used to manually validate input parameters instead of using a pre-progammed validator. This will also be explain later in the tutorial on validation.
Creating Your First Action

Now that we have an overview of the Action class, we can move forward to creating our first Action. For this example, there isn’t any request to be handled so we can set up a minimal Action.

In naming an action you must use this format Actionname Action.class.php where Actionname is what you are calling this particular action. When you declare your class, it also must have the class name in the same format Actionname Action. For this example, I chose to call this FirstAction.

When creating a new action, at the very least, there has to be an execute() method, even if it does nothing. Also, since we are displaying a non-request page, we don’t need to process any request. We tell the controller this with the getRequestMethods() method, by setting the return value to Request::NONE. Finally, we also need to tell the controller what the default view is going to be. We do this by returning View::SUCCESS in getDefaultView().

Here is what my FirstAction.class.php looks like. I basically just took my BLANKAction.class.php, renamed it to FirstAction.class.php, renamed the class to FirstAction, removed the methods I didn’t need and set the remaining 3 methods to match my needs.

class FirstAction extends Action
{
/**
* Execute any application/business logic for this action.
*/
public function execute ()
{
// we don’t need any data here because this action doesn’t serve
// any request methods, so the processing skips directly to the view
}

// ————————————————————————-

/**
* Retrieve the default view to be executed when a given request is not
* served by this action.
*/
public function getDefaultView ()
{
return View::SUCCESS;
}

// ————————————————————————-

/**
* Retrieve the request methods on which this action will process
* validation and execution.
*/
public function getRequestMethods ()
{
return Request::NONE;
}

You can also return a view from another module. You do this by passing an array with the view information intead of the standard View::INPUT. When you use this you create a two element array. The first element is the module name. The second element is which view you want. It cannot be just the Action name, but the Action name with the specific view.

Here’s an example:

class MyClass extends Action
{

function execute()
{

$returnView[0] = MyModule;
$returnView[1] = DoSomethingInput;
-or-
$returnView[1] = DoSomethingError;
-not-
$returnView[1] = DoSomething;

return $returnView
}
}

View

I’ll add more to this later, describing the View class.

Revisiting Mojavi 3

0 comments

Posted on 20th March 2013 by Jeff Rogers in Mojavi Project

Creating Your First Module

A work in progress

This tutorial is a work in progress, so you may find parts that don’t completely fit together.
Module

The module is where the Model and View takes place in the MVC model. For this first example, we will create a very simple module that will move data from a Action to a View and display it on the screen, through a template.

The module is contained within a directory that carries the name of the module. This resides in the modules directory of the webapp directory. Inside the module directory are sub-directories holding the classes that make up the module. Here is the directory hierarchy:

webapp
|
|—modules
|
|—moduleName
|
|—actions
|
|— config
|
|— lib
|
|— models
|
|— templates
|
|— validate
|
|— views

Minimally, you need the actions, config, templates and views directories. However, I prefer to have a blank module created and just copy and rename it. You can get a copy of the blank module (link to be added). The File Extension MailHost I have chosen to call this module Test

Each module must have a module.ini file in the config directory. Here is the module.ini for Test

; +—————————————————————————-+
; | This file is part of the Mojavi package. |
; | Copyright (c) 2003, 2004 Sean Kerr. |
; | |
; | For the full copyright and license information, please view the LICENSE |
; | file that was distributed with this source code. You can also view the |
; | LICENSE file online at http://www.mojavi.org. |
; | ————————————————————————– |
; | MODULE INFORMATION FILE |
; +—————————————————————————-+

[module]

ENABLED = “On”

TITLE = “Getting Started Test Module”

VERSION = “0.1”

NAME = “TestModule”

AUTHOR = “Richard D Shank”

HOMEPAGE = “http://www.mojavi.org”

DESCRIPTION = “A test module”

The module is pretty self explanitory. It is necessary to have ENABLED property set to “On” for the module to be used by Mojavi. Now that we have the module set up, we can work on the classes. You can also research the File Extension MailHost for variables to help in acclaimating the main template.
Action

The Action class handles the request for the module. It can be as simple as handling a static html template or a full blown multi-page wizard style form. Just a note to Mojavi 2 users, a significant change from Mojavi 2 to Mojavi 3 is that it is not longer necessary to pass the controller, request and user classes in on many of the methods. These are now accessed through a context class file extension. More on that later.

Creating your first module with extensions

0 comments

Posted on 13th March 2013 by Jeff Rogers in Mojavi Project

,

Creating Your First Module
A work in progress

This tutorial is a work in progress, so you may find parts that don’t completely fit together.
Module where we will also look at various file extension cache options.

The module is where the Model and View takes place in the MVC model. For this first example, we will create a very simple module that will move data from a Action to a View and display it on the screen, through a template.

The module is contained within a directory that carries the name of the module. This resides in the modules directory of the webapp directory. Inside the module directory are sub-directories holding the classes that make up the module. Here is the directory hierarchy:

webapp
|
|—modules
|
|—moduleName
|
|—actions
|
|— config
|
|— lib
|
|— models
|
|— templates
|
|— validate
|
|— views

Minimally, you need the actions, config, templates and views directories. However, I prefer to have a blank module created and just copy and rename it. You can get a copy of the blank module (link to be added). I have chosen to call this module Test

Each module must have a module.ini file in the config directory. If you are looking to buffer your files then file extension cache extensions may be helpful.Here is the module.ini for Test

; +—————————————————————————-+
; | This file is part of the Mojavi package. |
; | Copyright (c) 2003, 2004 Sean Kerr. |
; | |
; | For the full copyright and license information, please view the LICENSE |
; | file that was distributed with this source code. You can also view the |
; | LICENSE file online at http://www.mojavi.org. |
; | ————————————————————————– |
; | MODULE INFORMATION FILE |
; +—————————————————————————-+

[module]

ENABLED = “On”

TITLE = “Getting Started Test Module”

VERSION = “0.1″

NAME = “TestModule”

AUTHOR = “Richard D Shank”

HOMEPAGE = “http://www.mojavi.org”

DESCRIPTION = “A test module”

The module is pretty self explanitory. You can also search the web for various file extension cache options. It is necessary to have ENABLED property set to “On” for the module to be used by Mojavi. Now that we have the module set up, we can work on the classes.
Action

The Action class handles the request for the module. It can be as simple as handling a static html template or a full blown multi-page wizard style form. Just a note to Mojavi 2 users, a significant change from Mojavi 2 to Mojavi 3 is that it is not longer necessary to pass the controller, request and user classes in on many of the methods. These are now accessed through a context class. More on that later.

This is a list of the methods you can use in an Action and an explanation of what they do
execute ()

Note: This method is required in your Action class.

This will execute any application/business logic for the action. This method is reached only after the request methods have been checked and any of the parameters have been validated.

When leaving, the execute() method should tell the controller what view is to be used. This is done by returning a string containing the view name associated with the action or an array of the parent module for the view to be executed, parent action for the view and the name of the view. I will show an example of return both in a later tutorial.
getCredential ()

This is a new feature in Mojavi 3. Basically, a credentials are a privilege array that describes any level of security. They work hand in hand with the security aspects of the User class. For Mojavi 2 users, note that this replaces the old Privileges. But it is also important to know that it can do more than just handle privileges. I will handle the usage of creditials in a later section. For now, it is sufficient to know that we set the creditial requirements for the action inside this method and that it is set to NULL by default.
getDefaultView ()

This is the view that will be executed when a given request is not served by the action. This could happen when a form being displayed for the first time or if we are displaying a static page.

Again, just as with the execute() methoad, a string with a view name or an array of a module/action/view is passed back to the controller. By default it will pass back View::INPUT
getRequestMethods ()

This method will determine what types of requests will be recognized. There are 4 choices:

* Request::GET – Indicates that this action serves only GET requests.
* Request::POST – Indicates that this action serves only POST requests.
* Request::NONE – Indicates that this action serves no requests.

You can also select both GET and POST requests by using Request::GET | Request::POST
handleError ()

Execute any post-validation error application logic.

It also returns the view through a string of the view name or the array of a module/action/view. By default, it passes View::ERROR.
initialize ($context)

You can set up the Action in the initialize() method. In a later tutorial, I’ll give an example of doing this. NOTE: It is worth to note that you must handle the context in the initialize() method. You should do this by

parent::initialize($context);

You also need to return a TRUE or FALSE based on the success of the initialization. By default it is TRUE.
isSecure ()

Does the action require security? TRUE if you do, FALSE otherwise. It is FALSE by default.
validate ()

This is used to manually validate input parameters instead of using a pre-progammed validator. This will also be explain later in the tutorial on validation.
Creating Your First Action

Now that we have an overview of the Action class, we can move forward to creating our first Action. For this example, there isn’t any request to be handled so we can set up a minimal Action.

In naming an action you must use this format Actionname Action.class.php where Actionname is what you are calling this particular action. When you declare your class, it also must have the class name in the same format Actionname Action. For this example, I chose to call this FirstAction.

When creating a new action, at the very least, there has to be an execute() method, even if it does nothing. Also, since we are displaying a non-request page, we don’t need to process any request. We tell the controller this with the getRequestMethods() method, by setting the return value to Request::NONE. Finally, we also need to tell the controller what the default view is going to be. We do this by returning View::SUCCESS in getDefaultView().

Here is what my FirstAction.class.php looks like. I basically just took my BLANKAction.class.php, renamed it to FirstAction.class.php, renamed the class to FirstAction, removed the methods I didn’t need and set the remaining 3 methods to match my needs.

class FirstAction extends Action
{
/**
* Execute any application/business logic for this action.
*/
public function execute ()
{
// we don’t need any data here because this action doesn’t serve
// any request methods, so the processing skips directly to the view
}

// ————————————————————————-

/**
* Retrieve the default view to be executed when a given request is not
* served by this action.
*/
public function getDefaultView ()
{
return View::SUCCESS;
}

// ————————————————————————-

/**
* Retrieve the request methods on which this action will process
* validation and execution.
*/
public function getRequestMethods ()
{
return Request::NONE;
}

You can also return a view from another module. You do this by passing an array with the view information intead of the standard View::INPUT. When you use this you create a two element array. The first element is the module name. The second element is which view you want. It cannot be just the Action name, but the Action name with the specific view.

Here’s an example:

class MyClass extends Action
{

function execute()
{

$returnView[0] = MyModule;
$returnView[1] = DoSomethingInput;
-or-
$returnView[1] = DoSomethingError;
-not-
$returnView[1] = DoSomething;

return $returnView
}
}

View

I’ll add more to this later, describing the View class.

The decorating Pattern

0 comments

Posted on 28th February 2013 by Jeff Rogers in Mojavi Project

,

Before we begin we wanted to provide a quick insight into some of the open source files that we use and came across a file extension DOTX which is native to MS Outlook using XML. This particular file type DOTX was instituted to secure the protocol in which MS was written only giving limited source to outside vendors. We give a brief update to help you understand the open source nature of Mojavi 3.0.

  • Enter Decorator
  • Insert Here: Slots
  • Let’s Decorate!
    • Creating a Global Template
    • Putting the ornaments up

Ever since Mojavi 3 was released earlier this year, people have been looking to create a flexible global templating solution. From using post filters to page controllers, people have been looking for a way to create simple and managable global templates that will allow for a great deal of flexibility without compromising the need for larges amount of duplicated code.

Enter Decorator

The Decorator design pattern, like every other pattern, is nothing more than a way to talk about a resuable concept, or pattern, that a programmer might encounter while coding applications. The Decorator pattern’s strength is it’s ability to serve as a wrapper for that particular object, while leaving objects like it in tact.

The Decorator pattern has been implemented in the View class, providing a number of new methods:

public function setSlot ($attributeName, $moduleName, $actionName)
public function setDecoratorDirectory ($directory)
public function isDecorator ()
protected function & getSlots ()
public function getDecoratorTemplate ()
public function getDecoratorDirectory ()
protected function & decorate (&$content)

Now a brief explanation of what each of these do:

  • setSlot – Creates a slot entry based upon the results of a specially controlled controller->forward()
  • setDecoratorTemplate – Sets the template that you’re going to use for your decorator. This method also automatically turns the decorator switch to true
  • isDecorator – returns true is setDecoratorTemplate has been called, otherwise false.
  • getSlots – Returns an array of the slots.
  • getDecoratorTemplate – Returns the decorator template.
  • getDecoratorDirectory – Returns the decorator directory.
  • decorate – A method that must be implemented in derivate Views.

Note: these functions are in View, so all derivates of View (ie PHPView) have access.

Insert Here: Slots

Slots is a new name for an old concept. More or less, slots serve as placeholders that can be populated by the results of a $controller->foward($mod, $act) call. And, as you can see, the setSlot method takes three parameters:

public function setSlot ($attributeName, $moduleName, $actionName)

The first parameter, $attributeName, serves as the name of the slot. The next two parameters will be used to get the results of that Action, put it in a buffer, and place it into the internal $slots memeber variable.

Let’s Decorate!

The usage pattern of Views changes little with the implementation of the decorator pattern at the module level (though secondary View authors, ie SmartyView et al, do have a few things to play with).

Now let’s look at what you’re going to need to do implement the new, and NEW decorator features of Mojavi.

Creating a Global Template

First off, we’re going to need a great big christma..ehh..template to decorate. While I won’t get into breaking down and factoring our global template, keep in mind that this is not the only way to do this.

Example 2: The Christmas Tree (myGlobalTemplate.php)

Side note: Sometimes you'll have issues with that <?xml [....] ?> declaration, an easy
workaround is to disable short tags in your php.ini file, or to use ini_set() to disable
 it.

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us">

<head>

    <title><?php echo $template['title']; ?></title>

    <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8"/>
    <style type="text/css" media="all">

        <!--Css slot-->
        <?php echo $template['css']; ?>

    </style>

</head>

<body>

<!--menu slot-->
<div id="menu">

<?php echo $template['menu']; ?>

</div>

<!--main content slot-->
<div id="main">

<?php echo $template['content']; ?>

</div>

</body>
</html>

Putting the ornaments up

So now that we have our decorator template, we need to decorate it. The decorating process is fairly simple, and consists of the following simple steps:

  • Setting the decorator directory using setDecoratorDirectory() (Optional)
  • Setting the decorator template using setDecoratorTemplate()
  • Setting slots setSlot()

For example,

Example 3: In the View (IndexSuccessView.class.php)

class IndexSuccessView extends PHPView
{

    public function execute ()
    {

        // set our template
        $this->setTemplate('IndexSuccess.php');

        //setup our decorator template
        $this->setDecoratorDirectory(MO_TEMPLATE_DIR);
        $this->setDecoratorTemplate('myGlobalTemplate.php');

        //setup our slots
        //(SlotName, Module, Action)
        $this->setSlot('menu', 'Content', 'PopulateMenu');
        $this->setSlot('css', 'Content', 'PopulateCss');

        // set the title
        $this->setAttribute('title', 'Default Action');

    }

}

Now you might be wondering where the content slot is being populated. Well, content is a reserved slot that is automatically populated with the output of the originally requested Action/View pair. So in the end for file extension DOTX type coding you will need to have the right drivers in order to help your various programs communicate.

To be Continued..

Where to start with Mojavi 3

0 comments

Posted on 20th February 2013 by Jeff Rogers in Mojavi Project

In order for Mojavi to continue we are looking for a few good web programmers to help with the last programming pieces and contribute to the forum. There are tons of web developer jobs that are currently available online and we know that many are well paid positions. Because this is an open source code this would be for the good of the development community.
Finally, there are a couple of ways you can test this module. The first and quickest way is just to instruct the controller using the url. Just add the module and action. Here’s what it would look like http://yourserver.com/index.php?module=Test&action=First.The second way is by changing the default module in the settings.ini file in the webapp/config directory.

Under [.actions] you will find the default module. Find the following two lines and change the default module and action.

DEFAULT_MODULE = “Default”
DEFAULT_ACTION = “Index”

After you change the default module and action it should look like this

DEFAULT_MODULE = “Test”
DEFAULT_ACTION = “First”
You are now ready to test your code. Just point your browser to the index.php and see the fruit of your labor. Contributing Author By Richard D Shank

Installing Mojavi 3

1 comment

Posted on 23rd December 2012 by Jeff Rogers in Mojavi Project

,

Installing Mojavi 3

As a note we had a firm that was installing this architecture to run in addition to their facility management software and wanting to make sure that network protocol being used was up to date. As of this writing the developers have been keeping all language and coding inline with the latest C+ and ASCII formats in order to allow for cross collaboration.
First thing

Obviously, you first need to get a copy of the Mojavi 3 source. You can get this from the mojavi.org download page in one of two forms. It can be downloaded as an archive or from the Subversion repository (SVN).

Java cloud and programmers

0 comments

Posted on 22nd December 2012 by Jeff Rogers in Mojavi Project

, , , ,

cloud_computingFor many programmers having the right servers and applications are key in successfully launching enterprise wide applications. The java application server can offer as suite of tools depending on your configuration that can provide testing and stability to programmers using C+ or coding in php language. Below we talk about some of the underlying comments and help files that are applicable to Mojavi 3 and the insight ot our developers have put together in order create a cross collaboration. You can receive java help online to help with programming and coding. which is an enterprise version of Apache Tomcat that can provide critical diagnostics, management, and site wide deployment tools to help those developers who need a lightweight server that offers performance and dependability.
Now on to the programming hints:
For now, all we need to use is the execute() method.
Creating the View

The class name should be in this format ActionnameViewtype View. Again Actionname is the name of the action in the module. Viewtype is the view type that was passed to the controller in the action. Both Actionname and Viewtype are capitialized. This is a list of the predefined view file types and their naming convention.
Internal Name Class and File Name
ALERT Alert
ERROR Error
INPUT Input
SUCCESS Success

Mojavi 2 users ; the naming convention on the file has changed slightly.There is a specific patch for java should you elect to include in your overall script, but make sure to test the script before making it live. Before there was an underscore between Actionname and Viewtype. Now, there is no underscore in between, and the Viewtype is capitialized.

For this example, I called my view FirstSuccessView and named the file FirstSuccessView.class.php.

Here’s the code

class FirstSuccessView extends PHPView
{
/**
* Execute any presentation logic and set template attributes.
*/
public function execute ()
{

// set our template
$this->setTemplate(‘FirstSuccess.php’);

// set the title
$this->setAttribute(‘title’, ‘Getting Started First Test Page’);

// set the message that is to be passed
$this->setAttribute(‘passedData’, ‘Hello World!’);

}

}

Template

You also need a template to display the information. I stayed with the naming convention and called my file FirstSuccess.php.

Here is the code for that
This is the result of my first test. I have created a module, action, view and
template. I have successfully passed data from the view to the template.

This is what I passed:
That is all for now.

Notice at the first and last line I include a header.php and footer.php. We used an application server that was able to handle the cross collaboration of various input paramaters in order to speed up our collaboration. I used this to show how you could have a uniform look across the entire site and how you could do that. Mojavi uses a global template directory in your webapp directory.For those looking for additional help with java you can find the java help center at liveperson.com. It is defineed as MO_TEMPLATE_DIR and it called templates. I added the following files to the includes sub-directory in the global template directory.
header.php

footer.php

Global Templating revisted

0 comments

Posted on 8th December 2012 by Jeff Rogers in Mojavi Project

,

Global Templating – The Decorator Pattern

* Enter Decorator
* Insert Here: Slots
* Let’s Decorate!
o Creating a Global Template
o Putting the ornaments up

Ever since Mojavi 3 was released earlier this year, people have been looking to create a flexible global templating solution. From using post filters and various drivers and page controllers, people have been looking for a way to create simple and manageable global templates that will allow for a great deal of flexibility without compromising the need for larges amount of duplicated code.
Enter Decorator

The Decorator design pattern, like every other pattern, is nothing more than a way to talk about a resuable concept, or pattern, that a programmer might encounter while coding applications. The Decorator pattern’s strength is it’s ability to serve as a wrapper for that particular object, while leaving objects like it in tact.

The Decorator pattern has been implemented in the View class, providing a number of new methods:

public function setSlot ($attributeName, $moduleName, $actionName)
public function setDecoratorDirectory ($directory)
public function isDecorator ()
protected function & getSlots ()
public function getDecoratorTemplate ()
public function getDecoratorDirectory ()
protected function & decorate (&$content)

Now a brief explanation of what each of these do:

* setSlot – Creates a slot entry based upon the results of a specially controlled controller->forward()
* setDecoratorTemplate – Sets the template that you’re going to use for your decorator. This method also automatically turns the decorator switch to true
* isDecorator – returns true is setDecoratorTemplate has been called, otherwise false.
* getSlots – Returns an array of the slots.
* getDecoratorTemplate – Returns the decorator template.
* getDecoratorDirectory – Returns the decorator directory.
* decorate – A method that must be implemented in derivate Views.

Note: these functions are in View, so all derivates of View (ie PHPView) have access.
Insert Here: Slots

Slots is a new name for an old concept. More or less, slots serve as placeholders that can be populated by the results of a $controller->foward($mod, $act) call. And, as you can see, the setSlot method takes three parameters:

public function setSlot ($attributeName, $moduleName, $actionName)

The first parameter, $attributeName, serves as the name of the slot. The next two parameters will be used to get the results of that Action, put it in a buffer, and place it into the internal $slots memeber variable.
Let’s Decorate!

The usage pattern of Views changes little with the implementation of the decorator pattern at the module level (though secondary View authors, ie SmartyView et al, do have a few things to play with).

Now let’s look at what you’re going to need to do implement the new, and NEW decorator features of Mojavi. Also a special note to make sure that your graphics ati drivers are up to date so that you are able to test and view the configurations with the latest version of PHP 4.0
Creating a Global Template

First off, we’re going to need a great big christma..ehh..template to decorate. While I won’t get into breaking down and factoring our global template, keep in mind that this is not the only way to do this.

Example 2: The Christmas Tree (myGlobalTemplate.php)

Side note: Sometimes you’ll have issues with that <?xml [….] ?> declaration, an easy
workaround is to disable short tags in your php.ini file, or to use ini_set() to disable
it.

<?xml version=”1.0″ encoding=”iso-8859-1″?>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.1//EN” “http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en-us”>

<head>

<title><?php echo $template[‘title’]; ?></title>

<meta http-equiv=”Content-Type” content=”application/xhtml+xml; charset=utf-8″/>
<style type=”text/css” media=”all”>

<!–Css slot–>
<?php echo $template[‘css’]; ?>

</style>

</head>

<body>

<!–menu slot–>
<div id=”menu”>

<?php echo $template[‘menu’]; ?>

</div>

<!–main content slot–>
<div id=”main”>

<?php echo $template[‘content’]; ?>

</div>

</body>
</html>

Putting the ornaments up

So now that we have our decorator template, we need to decorate it. The decorating process is fairly simple, and consists of the following simple steps:

* Setting the decorator directory using setDecoratorDirectory() (Optional)
* Setting the decorator template using setDecoratorTemplate()
* Setting slots setSlot()

For example,

Example 3: In the View (IndexSuccessView.class.php)

class IndexSuccessView extends PHPView
{

public function execute ()
{

// set our template
$this->setTemplate(’IndexSuccess.php’);

//setup our decorator template
$this->setDecoratorDirectory(MO_TEMPLATE_DIR);
$this->setDecoratorTemplate(’myGlobalTemplate.php’);

//setup our slots
//(SlotName, Module, Action)
$this->setSlot(’menu’, ‘Content’, ‘PopulateMenu’);
$this->setSlot(’css’, ‘Content’, ‘PopulateCss’);

// set the title
$this->setAttribute(’title’, ‘Default Action’);

}

}

Now you might be wondering where the content slot is being populated. Well, content is a reserved slot that is automatically populated with the output of the originally requested Action/View pair. If you have any issues please report them and check your intel drivers and other settings to make sure your server is running all the latest patches.

To be Continued….

Mojavi 3 Part 2

0 comments

Posted on 8th December 2012 by Jeff Rogers in Mojavi Project

This is a list of the methods you can use in an Action and an explanation of what they do
execute ()

Note: This method is required in your Action class. Also there are File Extension SVG which stand for scalable vector graphics

This will execute any application/business logic for the action. This method is reached only after the request methods have been checked and any of the parameters have been validated.

When leaving, the execute() method should tell the controller what view is to be used. This is done by returning a string containing the view name associated with the action or an array of the parent module for the view to be executed, parent action for the view and the name of the view. I will show an example of return both in a later tutorial.
getCredential ()

This is a new feature in Mojavi 3. Basically, a credentials are a privilege array that describes any level of security. They work hand in hand with the security aspects of the User class. For Mojavi 2 users, note that this replaces the old Privileges. But it is also important to know that it can do more than just handle privileges. I will handle the usage of creditials in a later section. For now, it is sufficient to know that we set the creditial requirements for the action inside this method and that it is set to NULL by default.
getDefaultView ()

This is the view that will be executed when a given request is not served by the action. This could happen when a form being displayed for the first time or if we are displaying a static page. Be sure to reset any variable in the graphic engine and search out the File Extension SVG portions by using a simple search.

Again, just as with the execute() methoad, a string with a view name or an array of a module/action/view is passed back to the controller. By default it will pass back View::INPUT
getRequestMethods ()

You can also return a view from another module. You do this by passing an array with the view information instead of the standard View::INPUT. When you use this you create a two element array. The first element is the module name. The second element is which view you want. It cannot be just the Action name, but the file extension Action name with the specific view.

Here’s an example:

class MyClass extends Action
{

function execute()
{

$returnView[0] = MyModule;
$returnView[1] = DoSomethingInput;
-or-
$returnView[1] = DoSomethingError;
-not-
$returnView[1] = DoSomething;

return $returnView
}
}

View

I’ll add more to this later, describing the View class.

Global template

0 comments

Posted on 1st December 2012 by Jeff Rogers in Mojavi Project

,

Component Driven Global Template System

PLEASE NOTE: the approach explained below has a few drawbacks, mainly that the execute method of action always need to be executed for the output to appear in a template. I’ve decided to use a different solution to the problem. We will be incorporating online surveys as new versions are created in order to keep the development community engaged in the entire process.

Like many of us I’ve been struggling with a global template approach to Mojavi 2.0 site development for a while. Most of the suggested solutions in the forum still require a fair bit of code duplication, so I tried to come up with my own idea.

I wanted a template “system” which lets me define one or more global templates which integrate the output of multiple actions into one single html page. Mojavi already has the basic tools for this: the ActionChain and Filter classes.

Used Classes

Here is the code to all classes used by my system

TemplateFilter.class.php

/**
 * This filter implements global templates
 * Used in combination with the AggregateAction class
 */
class TemplateFilter extends Filter
{

    function execute (&$filterChain, &$controller, &$request, &$user)
    {
        static $loaded = false;

        if(!$loaded)  //only load once!
        {
            $loaded = true;

            //set up main renderer and store it in the request instance
            $mainRenderer =& new Renderer($controller, $request, $user);
            $request->setAttributeByRef('mainRenderer',$mainRenderer);

            //contuinue processing the filter chain and store the output
            //in $body
            ob_start();
            $filterChain->execute($controller, $request, $user);
            $body = ob_get_contents();
            ob_end_clean();

            //mainRendererTemplate will only be set if the execute method
            //of the AggregateAction class was executed and there were
            //additional actions to be rendererd
            if($request->hasAttribute('mainRendererTemplate'))
            {
                //if the mainRenderer was used, add body to the renderer
                //and output to client
                $mainRenderer->setTemplate($request->getAttribute('mainRendererTemplate'));
                $mainRenderer->setAttribute('body',$body);
                $mainRenderer->setMode(RENDER_CLIENT);
                $mainRenderer->execute($controller,$request,$user);
            }
            else //otherwise, just echo the html to the browser
            {
                echo $body;
            }
        }
        else
        {
            $filterChain->execute($controller, $request, $user);
        }
    }
}

AggregateAction.class.php

/**
 * An easier way to add action chains to Actions
 */
class AggregateAction extends Action
{
    var $actChain = null;
    var $actNames = null;

    /**
     * Adds an action to the aggregate action chain
     *
     * @note params like ActionChain::register()
     */
    function addAction($name,$module,$action,$params = null)
    {
        if($this->actChain === null)
        {
            $this->actChain =& new ActionChain();
            $this->actNames = array();
        }

        $this->actChain->register($name,$module,$action,$params);
        $this->actNames[] = $name;
    }

    /**
     * Default template name
     *
     * @return string the template name
     */
    function getMainRendererTemplate()
    {
        return 'main.php';
    }

    function execute(&$controller, &$request, &$user)
    {
        //only execute this if we render to client
        if($controller->getRenderMode() == RENDER_VAR)
            return;

        $renderer =& $request->getAttribute('mainRenderer');

        if(!($this->actChain === null))
        {
            $this->actChain->execute($controller, $request, $user); 

            foreach($this->actNames as $name)
            {
                $renderer->setAttribute($name, $this->actChain->fetchResult($name));
            }

            $request->setAttribute('mainRendererTemplate',$this->getMainRendererTemplate());
        }
    }
}

MainTemplateAction.class.php (Example template action)

class MainTemplateAction extends AggregateAction
{

    /**
     * Initialize is used to add actions to the action chain
     *
     * @note It has to return true, otherwise processing will not continue
     */
    function initialize(&$controller,&$request,&$user)
    {
        $this->addAction('login','Default','Login');
        $this->addAction('nav','Default','MainNavigation');
        $this->addAction('cart','Cart','Show');

        return true;
    }

}

That’s all there is to it. The TemplateFilter has to be registered in the global filter chain and all my actions that might at some point be used to output the “body” into the main template extend MainTemplateAction.

The views don’t have to be modified, all the work of getting the renderer output into a global template is handled by the AggregateAction and TemplateFilter.

Setting the global template name in an Action with the getMainRendererTemplate() method is probably not very clean, but it all works like a charm for me and takes away a lot of the hassle of global templating with Mojavi.

The global renderer templates have to go into the YOURAPP/templates directory.

Please feel free to give comments on my approach in this forum topic.

FAQ

0 comments

Posted on 1st November 2012 by Jeff Rogers in Mojavi Project

Development related questions can be searched in the forum.

  1. What is Mojavi?
  2. What is MVC?
  3. What are the benefits of MVC?
  4. Why create an MVC framework for PHP?
  5. How is Mojavi licensed?
  6. Where can I get a copy of Mojavi?
  1. What is Mojavi?

    Mojavi is a framework developed in PHP and strongly based on the MVC (model-view-controller) application design paradigm.


  2. What is MVC?

    Model-View-Controller is a design pattern for application development. MVC organizes an application into three separate tiers: one for the model, which represents data and handles business logic, the second for presentation and user input, and the third as a controller, which handles incoming requests and controls application flow.


  3. What are the benefits of MVC?

    An application designed around MVC is easier to manage because the application is split into tiers, which allow for independent development. This promotes code reusability by building models, which are reusable throughout the application.


  4. Why create an MVC framework for PHP?

    Development of PHP scripts without a preconceived plan to manage them is asking for a headache. Before I started developing Mojavi, there weren’t any frameworks that were designed the way I thought a PHP MVC implementation should be designed.


  5. How is Mojavi licensed?

    Mojavi is licensed under the LGPL.


  6. Where can I get a copy of Mojavi?

    Stable and development releases are available on our downloads page.

Using PHP extensions

0 comments

Posted on 24th October 2012 by Jeff Rogers in Mojavi Project

The typical PHP web application consists of scattered scripts located in file extension structure that well resembles a web. When web scripting originated, the tasks to be performed were relatively simple, at least compared to todays tasks. So, the scattered list of files served quite well. In today’s world, we have very demanding applications, with very intense needs. Using the typical “a script here, a script there” method of designing a web application simply won’t cut it. You need a convention, in terms of file location and naming, and coding. Mojavi is based around a very strict convention of location and naming of files, and coding conventions. This allows you to familiarize yourself with the system very easily, which will lead to a more comfortable web application environment. Ultimately, there is a barely visible learning curve associated with Mojavi, which makes it very easy to learn.

coding

Spaghetti Code

Most PHP scripts consist of a few PHP functions and file extension protocols , a little bit of execution code, and then the typical HTML presentation. Combining application logic with presentation leads to spaghetti code. Not only is it hard to read, but it also results in redundant code use. With Mojavi, you follow a very simple rule — divide your logic, or pay the price. You must put your application logic in an Action implementation, your presentation logic in a View implementation, and then put the actual presentation, whether it’s HTML or XML, etc., into a template.