2 ---------------------------------------
4 The Akelos Framework is an open-source port of Ruby on Rails to the
5 PHP programming language.
7 The main goal of the Akelos Framework its to help programmers to build
8 multilingual database-backed web applications according to the
9 Model-View-Control pattern. It lets you write less code by favoring
10 conventions over configuration.
12 You can find more information at the Akelos Framework website at
17 ---------------------------------------
18 Perhaps the easiest way to lear about Akelos is to get your hands on the tutorials
19 you can find on the docs folder.
22 Setting up the framework.
23 ---------------------------------------
24 Once you checkout the code you'll need to make available the folder ./public
25 to your webserver with a command like:
27 ln -s /home/bermi/akelos_framework/public /usr/htdocs/akelos
29 Then just point your browser to that url and follow the steps.
31 You will also need to make sure that mod_rewrite is loaded into Apache,
32 and that it can be controlled from .htaccess files, to do this make sure that
33 the Apache configuration directive AllowOverride is set to 'All' (you may allow only the specific directives for mod_rewrite),
34 for the directory your project will be accessed from.
37 If you have problems with the web setup you can copy and edit
38 config/DEFAULT-config.php and config/DEFAULT-routes.php. You might also need
39 to edit the .htaccess files in ./ and ./public/ and un-comment/edit the
40 "# RewriteBase" directive so it matches to your url path.
42 All the configuration params are on /lib/constants.php If you define any of them
43 in your /config/config.php, /config/development.php, /config/production.php
44 or /config/testing.php the default setting will be overwritten.
47 Accessing the Command Line interface
48 ---------------------------------------
49 In order to access the command line interface run
53 Then you can run any PHP code interactively.
59 // Will show a list of available generators
61 >>> test app/models/post.php
63 // Will run the unit tests for the framework the Post model
65 You can also use the commands generate, migrate, setup ... by calling directly
70 Differences from Ruby on Rails.
71 ---------------------------------------
72 I've tried to adhere as much as I could to the original interfaces, but some
73 general changes apply:
75 - PHP doesn't have name spaces so on the controller you must access to
76 $this->params, $this->ModelName, $this->Request, $this->Response
78 - Templates are ended in .tpl (there is only one render on the framework, but
81 - Views work using PHP, but some like file functions, static method calls,
82 object instantiation.... will be disallowed for helping in keeping in the
83 view just presentation logic. If you need extra logic for your views you can
84 always create a helper "./app/helpers" so your views will be easier to
87 - Helpers are made available automatically for your views under the naming
88 convention $name_helper were "name" is the name of the desired helper.
90 $url_helper->url_for(array('action'=>'add'));
92 - All the methods (but helpers) use PEAR like naming conventions so instead of
93 AkActionController::url_for() you need to call AkActionController::urlFor()
95 - Helpers are located at /lib/AkActionView/helpers (it's worth having a look
98 - In order to expose data from your controllers to the views, you'll simply
99 need to assign them as attributes of the controller that is handling the
102 class PostController extends ApplicationController
106 $this->message = 'Hello World';
110 Will expose into ./app/views/post/index.tpl $message variable so you can use
113 <?php echo $message; ?>
115 or the same using SinTags
120 i18n and l10n the Akelos way
121 ---------------------------------------
123 Locale files are located at:
125 ./config/locales/ # Akelos Framework locales
126 ./app/locales/NAMESPACE/ # Your application locales where NAMESPACE is
127 replaced by your model/controller/view name
129 In order to change the language of your application can prefix your request
130 with the locale name so:
132 http://example.com/es/post/add # will load ./config/locales/es.php
134 http://example.com/en/post/add # will load ./config/locales/en.php
137 All the functions for writing multilingual code rely on the Ak::t() method.
138 Based on the Ak::t() function you can find:
140 $PostController->t() # controller
142 $text_helper->translate() # for the view
143 _{ hello world } # for the view (SinTags)
145 All these four will save new locales onto their corresponding namespace in
146 the example above "./app/locales/post/en.php"
148 If you want to use your own namespace for storing locales you can do it like:
150 translate('Hello world', null, 'shared_posts');
152 In this case it will store it at "./app/locales/shared_posts/en.php"
155 Deal with Compound Messages
157 As you can see the Framework has been designed with l10n and i18n in mind. One
158 nice and flexible feature common to all these functions but the sintags one is
159 the ability to add compounded messages, you might already realized this but
160 here is a small example:
162 Ak::t('Hello %title %last_name,',
163 array('%title'=>$title,'%last_name'=>$last_name,'%first_name'=>$first_name));
165 Ak::t('Today is %date', array('%date'=>Ak::getDate()));
166 // You can use Ak::t or any of its derived methods
168 The SinTags way to deal with compounded messages is
171 // which will be converted to
172 // <?=$text_helper->translate('Today is %date', array('%date'=>$date));?>
173 // note that $date is selected by replacing the % from the needle
175 Internationalizing Models.
177 You can have multilingual database columns by adding the locale prefix plus
178 and underscore to the column name. This way when you do
180 $Article->get('title')
182 you'll get the information on the "en_title" column if "en" is your current
185 The same way you can set posted attributes like
187 $_POST = array('title'=>array('en'=>'Tech details',
188 'es'=>'Detalles técnicos'));
189 $Article->setAttributes($_POST);
191 and the attributes will be mapped to their corresponding columns.
193 In order to make this work you need to add to your config/config.php
195 define('AK_ACTIVE_RECORD_DEFAULT_LOCALES', 'en,es');
198 In order to convert between charsets you can use Ak::recode() and
199 Ak::utf8('My ISO Text', 'ISO-8859-1').