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

Akelos

What is Akelos?

Akelos is an MVC (Model-View-Controller) platform similar to Ruby on Rails. It aims at helping programmers build multilingual database-backed web applications and write less code, which allows for the creation of uniform, simple to understand scripts. The Akelos PHP framework allows programmers to write views using Ajax, to control requests and responses through a controller, and to create and maintain internationalized applications. By using the conventions integrated in Akelos, developers can establish communication between the framework's models and databases. In order to distribute standalone web applications Akelos demands only that PHP be installed on the server.

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

Akelos framework's feature list

Akelos is a modern PHP framework. It features:

  • multilingual models and views
  • locale alias integrated on URLs
  • database migrations using DB designer files
  • pure PHP support for Unicode
  • unit tested source code
  • code generators
  • a built-in XHTML validator
  • automated locale management
  • clean separation from HTML and Javascript using CSS event selectors
  • Ajax file uploads
  • AFLAX integration
  • Dojo Rich Text Editor
  • format converters
  • file handling using SFTP for shared host running Apache as user nobody (as most cPanel servers do)
  • distributed sessions using databases

The Model-View-Controller pattern in the Akelos PHP framework

Akelos applications are run on the same server where the Akelos software itself is located, communicating with it as it runs. An Akelos application consists of many small files instead of one single piece of code or a few larger files. The code itself goes into specific directories making it easier for programmers to debug.

Akelos can be used for accessing a MySQL or PgSQL database (through the model), processing the data (by the controller), and presenting it to the user (through the view). Then the user's input is accepted and processed. Here's a small introduction to writing MVC code:

Model

That's the data model. The code is stored in the app/models folder. The class name is singular, camel cased e.g. PhoneBook. The file names are also singular but they are underscored e.g. phone_book.php.

As an example we will create a simple phonebook that submits data to a MySQL database. Your database details have to be filled in the framework's wizard which starts once it is installed.

Akelos offers a really simple to use command-line interface (CLI), which we can use to create our database tables. We just need to add the following code to "app/installers/tables_installer.php":

<?php
class TablesInstaller extends AkInstaller
{
// Define a function that creates a table “phones” with columns id, name and phone
function up_1(){
$this->createTable('phones',
'id,'.
'name,'.
'phone'
);
}
// Define a drop function
function down_1(){
$this->dropTables('phones');
}
}
?>

and then execute the command:

./script/migrate tables install

so that the tables can be actually created in the database. Now we can use the integrated scaffolding function to build our phonebook application. Just need to run:

./script/generate scaffold Phone

Now we have a fully featured phonebook at http://domain.com/framework_base/phone/ which consists of a model, a controller and a view. The model consists only of a class definition for our phonebook application.

./app/models/phone.php

<?php
class Phone extends ActiveRecord
{
}
?>

The Controller

The controllers determine how the data is to be processed. Their number depends on the logic of the program. The code for it is located in the app/controllers directory. The controller's class name can be singular or plural, camel cased and ends with Controller e.g. AccountController, BookController, etc. The names of the controllers' files can be singular or plural, underscored, ending with _controller, e.g. account_controller.php, book_controller.php. The controller's class has several functions, one function corresponding to each web page. There can be certain functions that do not access web pages or some code that has to be executed before the page is viewed. The function may also process the results when the user enters data on the page.

Our listing() and add() functions of the phonebook controller:

./app/controller/phone_controller.php

<?php

class PhoneController extends ApplicationController
{
# Redirect our index page to the phonebook listing
function index()
{
$this->redirectToAction('listing');
}
# Use the PaginationHelper class to set the number of results and use the model to get all the phones from our database
function listing()
{
$this->phone_pages = $this->pagination_helper->getPaginator($this->Phone, array('items_per_page' => 10));
$options = $this->pagination_helper->getFindOptions($this->Phone);
$this->phones =& $this->Phone->find('all', $options);
}
# If a new entry is posted, insert (save) it into the database
function add()
{
if(!empty($this->params['phone'])){
$this->Phone->setAttributes($this->params['phone']);
if ($this->Request->isPost() && $this->Phone->save()){
$this->flash['notice'] = $this->t('Phone was successfully created.');
$this->redirectTo(array('action' => 'show', 'id' => $this->Phone->getId()));
}
}
}
?>

View (Action View)

The views, which are located in the app/views directory, have a subdirectory corresponding to each controller, e.g. app/views/account/. Within that subdirectory is located one template file for each page that is to be generated, e.g. app/views/account/show.tpl. So as not to make programmers write HTML or PHP code for the entire page, each page accesses a layout file containing code common to all of them. Akelos uses template files that have helpers for adding forms, fields and data loops, to generate PHP files that in fact render web page - the building unit of a website.

Our add.tpl example that corresponds to the add() function of the controller

./app/views/add.tpl

<div id="sidebar">
<h1>_{Tasks}:</h1>
<ul>
<li><?php  echo  $url_helper->link_to($text_helper->translate('Back to overview'), array('action' => 'listing'))?></li>
</ul>
</div>

<div id="content">
<h1>_{Phones}</h1>

  <?php  echo  $form_tag_helper->start_form_tag(array('action'=>'add')) ?>

  <div class="form">
<h2>_{Creating Phone}</h2>
<?php  echo   $controller->renderPartial('form') ?>
</div>

  <div id="operations">
<?php  echo $phone_helper->save() ?> <?php  echo  $phone_helper->cancel()?>
</div>

  <?php  echo  $form_tag_helper->end_form_tag() ?>
</div>

Resources: