Promo Offers XMAS Offers:
KVM VPS @ UP TO 50% OFF for 3 mos. Learn More Dedicated @ UP TO 56% OFF for 1 mo. Learn More
  • Your Cart is Empty
  • Cart
  • Log In

ZooP

What is Zoop?

Zoop stands for Zoop Object Oriented PHP Framework. In development since 2001, Zoop is based on the MVC architecture that supports separation of display, logic and data layers. Its integrated handling of errors can be used for logging errors for production environments, which renders bugs easy to discover. Zoop features a Smarty based view layer, which offers form generation and rich UI controls. Using it, even an inexperienced coder can create web applications quickly, whereas the more experienced will appreciate the design, flexibility, and the shortcuts for handling common tasks, which Zoop is offering. The developers get access to a fully-featured front controller, several integrated data model access styles, native libraries, and can benefit from the easy integration with third-party projects.

Latest version: 1.5
PHP4
PHP5
MVC
Multiple DB
ORM
DB Objects
Templates
Caching
Validation
Ajax
Auth Module
Modules
Cost FREE

What makes Zoop a unique PHP framework? Features Overview.

Zoop, which contains components from some existing projects, among them Smarty, the Prototype JS Framework, and various Pear Modules, allows coders to use GuiControls and other form widgets offering integrated client-side validation, and includes support for certain PHP and Javascript projects such as the Zend Framework, PHP Doctrine and jQuery.

A zone is the core structure of a Zoop application. Each given function of the program is located into a zone. Zoop, which is quite organized, has an easy to manage codebase and features higher and lower level functions. The latter can be used regardless of the structure of the application and even in an application, which is not based on Zoop. An example of such a function is append_to_file($file,$content) which opens a file and appends content to it and which can be used outside Zoop as well. Higher level functions, among them guiControls, which basically represent form widgets, benefit from and depend on Zoop’s zone structure. The validation happens even before you see $_POST, which is very useful for the programmers.

Zoop has a clear and easy to understand URL mapping structure, which lets programmers know exactly which function is being run in which file and which parameters are being passed to that function.

Zoop zones vs. plain PHP

A simple PHP program consists of lots of separate PHP files located in a program directory or subdirectory. To run the function in that file, go to http://your-ntc-domain.com/program/file.php. However, this approach has several minuses - it is quite unorganized and confusing; there is a lack of distinction between library files and files generating content; developers have to create a new PHP file for each page in their applications. If you simply write a script to handle the post from a form, then this plain PHP approach will work well, but if used for developing an application, it will not.

A zone consists of pages with a similar function or subject. Often applications have several pages for administration. They can be PHP files organized in an admin directory. As far as the Zoop application is concerned, the logic for the page is included within a method called pageXXXX in the zone_admin class often defined in a file called zone_admin.php.

Inside the zone_admin.php file there is an object, or class, in this case, called zone_admin. There are many functions, called page functions, inside it, one for each separate page.

Going to a page in Zoop differs from the standard PHP. If, in a plain PHP application, there is a page to edit a user, e.g. /application_directory/admin/edituser.php, it will be in the admin directory. Via a web browser you would go to the http://your-ntc-domain.com/application_directory/admin/edituser.php URL.

In Zoop the same function would be located in the file zone_admin.php, in a function called pageEditUser inside the zone_admin class. Via a web browser you would go to http://your-ntc-domain.com/application_directory/index.php/admin/editUser.

In brief, zones provide functionality that cannot be achieved in practice in any other way.

Getting started with Zoop - installation and usage tutorial

Zoop is easy to install and use. If you are creating an application from scratch then download the Zoop Skeleton and uncompress the archive into its own directory. Zoop can be located anywhere on your server provided that the installation path is accessible by PHP. After you uncompress the package, edit the config.php file and tell the application where Zoop is located.

An example of defining the path to Zoop in config.php

Let's say our Zoop installation is located in /usr/local/zoop/

define('zoop_dir','/usr/local/zoop/');

Since version 1.2, Zoop makes the necessary Pear libraries available for download. They should be uncompressed and put into zoop_dir/lib. This package should be made use of only when a standard Pear setup is not available, for example on a shared web hosting platform.

An example for installing Pear dependencies

To establish the necessary Pear dependencies you have to copy and paste the following into a terminal. If you have a shared web hosting account then you need to have an SSH service enabled:

pear install DB
pear install --force VFS
pear install --force Log
pear install --force Validate
pear install --force XML_Util
pear install --force XML_Parser
pear install --force XML_Serializer
pear install --force XML_RPC
pear install --force Mail

If your shared hosting plan does not offer SSH and, as a result, you are unable to run terminal commands, you may ask our support team to do this for you.

Zoop uses caching and other temporary files, which the web server needs a place to store. Generally, that is in your application directory app_dir in a subdirectory tmp, so you have to make certain that this directory is writable by the server.

An example of setting write permissions to a /tmp directory

If you have access to a terminal you would do something like this:

# cd /path/to/app_dir
# sudo chgrp -R apache tmp
# sudo chmod -R g+w tmp

Otherwise you may use your account’s inbuilt permission management tools. With NTC Hosting's web hosting Control Panel you need just to navigate to the 'tmp' folder using the inbuilt FTP Manager, and to set the permissions settings to 755.

Once Zoop is installed you can also download and install Zoop Skeleton, an application using which programmers could have a starting point when beginning a new application.

An example of a basic Zoop Skeleton structure

config.php
includes.php
templates/default
config/

The configuration file - config.php

Your primary configuration file for your application is config.php, which contains many defines to set up the options Zoop will use for the application. The defaults will work just fine until you learn how to change them.

As we mentioned above, there is a certain setting that will ban your entire application from working until it is properly set, namely the location of Zoop on your system. Let's check the example again:

define('zoop_dir','/usr/local/zoop/');

Another important definition is app_status, which can be dev, test or live. Zoop handles stuff like errors and caching depending on the app_status.

Setting up includes.php

Things might not work if the includes.php file is not properly used. It has five sections: configuration, zones, objects, misc, and pear.

The 'Configuration' section includes files such as config.php and zoop.php and sets up the Zoop object which will be used for the rest of the file. Then we have to include the different components of Zoop that our application will use.

An example of including a GUI component in includes.php

$zoop->addComponent('gui');

The 'Zone' section of the file includes all the zones that the coders will be using in their applications. When creating a new zone be sure to include it here.

An example of adding a zone in includes.php

$zoop->addZone('zonename');

The 'Objects' section is used to include objects, which represent libraries that developers use for their applications. They could be objects, or classes, or static functions. If you have to write a webmail application, for example, you may create an object containing certain IMAP or POP email functions that could be used by your web page functions. Located in app_dir/objects, these objects can exist in subdirectories as well. They are also included with the function call:

An example of inserting an Object in includes.php

$zoop->addObject('objectname');

In the 'Misc' section developers can put anything else. It is mostly used for organizational purposes. Here you can simply use standard PHP include or include_once.

The 'Pear' section contains the settings for all pear libraries that are needed for the Zoop application. Each component includes its necessary pear libraries. When including pear libraries, use include_once since you are not sure which pear libraries Zoop will include in the future using include_once as well.

When a web browser visits http://your-ntc-domain.com/app_dir/ Zoop always executes the same page function pageDefault inside zones/default.php. The Skeleton has a welcome page set up and so, if you try to open your projects folder in a web browser you will see a welcome screen of some kind. If an error message appears, trace your steps back and make certain that the web server can write to the app_dir/tmp directory where the template caching files are located. If Zoop cannot create them, it will display an error message.

As an example of Zoop’s capabilities, we will build a simple form that sends emails.

For this purpose, first we need to edit the includes.php file and make sure that we have added the following component:

$zoop->addComponent('mail');

and the default zone is available too:

$zoop->addZone('default');

Now we need to set up our default page, which in fact is the pageDefault() function of the default.php file.

An example of pageDefault in zones/default.php

Function pageDefault($inPath)
{
global $sGlobals;
global $gui;

       // here we set our default page to be default.tpl
$gui->display("default.tpl");
}

The default page will actually be what is opened when we type http://your-ntc-domain.com/app_dir/.

We will create a simple form with fields for email/subject/message.

An example of templates/default/default.tpl

{include file="head.tpl"}
<body>

<h1>Mail Form</h1>
<!—We will not define action, since by default the form is being submitted to the page it is located on(which is what we need) à
<form method="POST">
Email: <br />
<input name="emailFrom" id="emailFrom" type="text" /><br />
Subject: <br />
<input name="subject" id="subject" type="text" /><br />
Message: <br />
<input name="message" id="message" type="text" /><br />
<input type="submit" name="submit" value="Send Message" /><br />
</form>

Now we need to have something that sends the email and that will process what we have posted. This would be the defaultPost function of the default.php file. It caches all the post information.

An example of pageDefault in zones/default.php

function postDefault($inPath)
{              
global $sGlobals, $gui;
// getPost() gives us a sanitized version of the $_POST .      
$post = getPost();
// Assign the variables that we would need for the sendTextEmail function
$from = $post['emailFrom'];
$to = ‘youremail@your-ntc-domain.com';
$cc = null;
$subject = $post['subject'];
$body = $post['message'];
// Send the message
$msg = new message();
$msg->sendTextEmail($from, $to, $cc, $subject, $body);
// Use the message.tpl , that displays variable ‘message’ , for a confirmation message
$gui->assign('message', 'The form was successfully submitted');
$gui->display('message.tpl');
}

Now we have a fully operational email form at http://your-ntc-domain.com/app_dir/