Changeset 112

Show
Ignore:
Timestamp:
03/02/07 12:02:08 (2 years ago)
Author:
bermiferrer
Message:

Edited wiki page through web user interface.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • wiki/Tutorial.wiki

    r110 r112  
    1919== Download and installation == 
    2020 
    21 We highly recommend you to get the trunk version of Akelos until we hit version 1.0. You need to have installed [http://subversion.tigris.org/ subversion] in order to do this and run the this from your command line
     21We highly recommend you to get the trunk version of Akelos until we hit version 1.0. You need to have installed [http://subversion.tigris.org/ subversion]. You can checkout a working copy of the Akelos source code with the command
    2222 
    2323{{{ 
     
    2525}}} 
    2626 
    27 If you cant or don’t want to checkout the code from subversion, you can get the [http://www.akelos.org/akelos_framework-dev_preview.tar.gz latest stable version] generated automatically by the Continuous Integration system, and untar it by typing: 
     27If you cant or don’t want to checkout the code from subversion, you can get the [http://www.akelos.org/akelos_framework-dev_preview.tar.gz latest stable version] generated automatically by the Continuous Integration system, and untar it by typing: 
    2828 
    2929{{{ 
     
    5151}}} 
    5252 
    53 And change the {{{#!/usr/bin/env php}}} at the beginning of these files {{{script/console}}}, {{{script/generate}}}, {{{script/migrate}}}, {{{script/setup}}} and {{{script/test}}} to you php binary path. 
     53And change the `#!/usr/bin/env php` at the beginning of these files `script/console`, `script/generate`, `script/migrate`, `script/setup` and `script/test` to you php binary path. 
    5454 
    5555*Note for Windows users:* You will need to call the scripts from your application directory using the full path to your php.exe file like: 
     
    7070As you might have guessed we go with the first option and will create a linked Akelos application which will only expose the public folder to the world. Changing the Framework paths is really simple in Akelos, all you have to do is define in your configuration file where each component is located, but we will leave this for a future tutorial about designing an application for distributing it. 
    7171 
    72 Assuming you’ve downloaded the framework to {{{HOME_DIR/akelos}}} and that you are inside the {{{akelos}}} directory you will check available options for setting up your new application by running 
     72Assuming you’ve downloaded the framework to `HOME_DIR/akelos` and that you are inside the `akelos` directory you will check available options for setting up your new application by running 
    7373 
    7474./script/setup -h 
     
    8989}}} 
    9090 
    91 So running this command: (replace {{{/www/htdocs}}} with your web server public path. On some shared server it’s {{{/home/USERNAME/public_html}}}
     91So running this command: (replace `/www/htdocs` with your web server public path. On some shared server it’s `/home/USERNAME/public_html`
    9292 
    9393{{{ 
     
    105105}}} 
    106106 
    107 *Note for Windows users:* A soft link to booklink/public is created only on *NIX systems, so you’ll need to tell your web server where to find the public path for the *booklink* application on your {{{httpd.conf}}} file by adding something like this: 
     107*Note for Windows users:* A soft link to booklink/public is created only on *NIX systems, so you’ll need to tell your web server where to find the public path for the *booklink* application on your `httpd.conf` file by adding something like this: 
    108108 
    109109{{{ 
     
    149149==== Manual configuration editing ==== 
    150150 
    151 Save the files {{{config/DEFAULT-config.php}}} and {{{config/DEFAULT-routes.php}}} as {{{config/config.php}}} and {{{config/routes.php}}} and edit them following them as needed. 
    152  
    153 You might also need to set the base rewrite path manually is you want to be able to use nice URLs by editing the file {{{public/.htaccess}}} and setting RewriteBase like: 
     151Save the files `config/DEFAULT-config.php` and `config/DEFAULT-routes.php` as `config/config.php` and `config/routes.php` and edit them following them as needed. 
     152 
     153You might also need to set the base rewrite path manually if you want to be able to use nice URLs by editing the file `public/.htaccess` and setting RewriteBase like: 
    154154 
    155155{{{ 
     
    157157}}} 
    158158 
    159 After your application has been installed correctly you’ll see a welcome message at http://localhost/booklink. Now you can safely remove the framework setup files (it won’t be available is you have a {{{/configconfig.php}}} file
     159After your application has been installed correctly you’ll see a welcome message at http://localhost/booklink. Now you can safely remove the framework setup files (they won’t be accessible if a `/config/config.php` file exists
    160160 
    161161== The booklink database structure == 
     
    167167So you will create the database using an installer in order to distribute the changes you make to the booklink database scheme from time to time. Using _installers_ will also allow you to define your database tables and columns independently from the database vendor. 
    168168 
    169 Now you will create a file named {{{app/installers/booklink_installer.php}}} with the following Installer code 
     169Now you will create a file named `app/installers/booklink_installer.php` with the following Installer code 
    170170 
    171171{{{ 
     
    204204 
    205205*BOOKS TABLE* 
    206  
    207206{{{ 
    208207+--------------+--------------+------+-----+----------------+ 
     
    218217 
    219218*AUTHORS TABLE* 
    220  
    221219{{{ 
    222220+-------+--------------+------+-----+----------------+ 
     
    248246 
    249247  * *Path:* _/app/controllers/_ 
    250   * *Class Name:* singular or pural, camel cased, ends in {{{Controller}}} _(AccountController, PersonController)_ 
    251   * *File Name:* singular or pural, underscored, ends in {{{_controller}}} _(account_controller.php, person_controller.php)_ 
     248  * *Class Name:* singular or pural, camel cased, ends in `Controller` _(AccountController, PersonController)_ 
     249  * *File Name:* singular or pural, underscored, ends in `_controller` _(account_controller.php, person_controller.php)_ 
    252250 
    253251==== Views ==== 
     
    274272}}} 
    275273 
    276 This will generate a brunch of files and folder with code that really works!, don’t trust me? try it yourself. Point your browser to http://localhost/booklink/author and http://localhost/booklink/books to start adding authors and books. Create some records and come back for an explanation of what is going under the hood. 
     274This will generate a brunch of files and folder with code that really works!. Don’t trust me? Try it yourself. Point your browser to http://localhost/booklink/author and http://localhost/booklink/books to start adding authors and books. Create some records and come back for an explanation of what is going under the hood. 
    277275 
    278276== The Akelos Workflow == 
    279277 
    280 This is a small description of the workflow for a call to the following URL {{{http://localhost/booklink/book/show/2}}} 
    281  
    282   1. Akelos will break up your request into three parameters according to your {{{/config/routes.php}}} file (more on this later) 
     278This is a small description of the workflow for a call to the following URL `http://localhost/booklink/book/show/2` 
     279 
     280  1. Akelos will break up your request into three parameters according to your `/config/routes.php` file (more on this later) 
    283281    * controller: _book_ 
    284282    * action: _show_ 
    285283    * id: 2 
    286   1. Once Akelos knows about this request it will look for the file {{{/app/controllers/book_controller.php}}} and if found it will instantiate the class {{{BookController}}} 
    287   1. The controller will look for a model that matches the parameter {{{controller}}} from the request. In this case it will look for {{{/app/models/book.php}}}. If found, it will create an instance of the model on the controller {{{$this->Book}}} attribute. If an {{{id}}} is on the request, it will search into the database for the Book with the id 2 and that will remain on {{{$this->Book}}} 
    288   1. Now it will call the action {{{show}}} from the {{{BookController}}} class if it’s available. 
    289   1. Once the show action has been executed, the controller will look for the view file at {{{/app/views/book/show.tpl}}} and will render the results into the {{{$content_for_layout}}} variable. 
    290   1. Now Akelos will look for a layout named like the controller at {{{/app/views/layouts/book.tpl}}}. If found it will render the layout inserting {{{$content_for_layout}}} content and sending the output to the browser. 
     284  1. Once Akelos knows about this request it will look for the file `/app/controllers/book_controller.php` and if found it will instantiate the class `BookController` 
     285  1. The controller will look for a model that matches the parameter `controller` from the request. In this case it will look for `/app/models/book.php`. If found, it will create an instance of the model on the controller `$this->Book` attribute. If an `id` is on the request, it will search into the database for the Book with the id 2 and that will remain on `$this->Book` 
     286  1. Now it will call the action `show` from the `BookController` class if it’s available. 
     287  1. Once the show action has been executed, the controller will look for the view file at `/app/views/book/show.tpl` and will render the results into the `$content_for_layout` variable. 
     288  1. Now Akelos will look for a layout named like the controller at `/app/views/layouts/book.tpl`. If found it will render the layout inserting `$content_for_layout` content and sending the output to the browser. 
    291289 
    292290This might help you understanding the way Akelos handles your requests, so we are ready to modify the base application. 
     
    294292== Relating Books and Authors == 
    295293 
    296 Now you are going to link *boolink* authors and books (complex associations in upcoming tutorials). In order to achieve this you will use the {{{author_id}}} column you added to your database. 
     294Now you are going to link authors and books (complex associations in upcoming tutorials). In order to achieve this you will use the `author_id` column you added to your database. 
    297295 
    298296So you will need to tell your models how they relate to each other like 
     
    320318}}} 
    321319 
    322 Now that you made the models aware of each other you will need to modify the book controller so it loads the {{{author}}} and the {{{book}}} model instances 
     320Now that you made the models aware of each other you will need to modify the book controller so it loads the `author` and the `book` model instances 
    323321 
    324322_/app/models/author.php_ 
     
    332330}}} 
    333331 
    334 Next step is to show available authors when creating or editing a book. This can be achieved using the {{{$form_options_helper}}} by inserting the following code right after {{{<?=$active_record_helper->error_messages_for('book');?>}}} on the _/app/views/book/_form.tpl_ file 
     332Next step is to show available authors when creating or editing a book. This can be achieved using the `$form_options_helper` by inserting the following code right after `<?=$active_record_helper->error_messages_for('book');?>` on the _/app/views/book/_form.tpl_ file 
    335333 
    336334{{{ 
     
    343341If you have not added authors yet, go and created some right now and then visit http://locahost/boolink/book/add to check out the brand new authors select list. Go ahead and create a new book selecting an author from the list. 
    344342 
    345 Seems like the author has been saved but it its not included on the {{{app/views/book/show.tpl}}} view. You’ll add it this code right after {{{<? $content_columns = array_keys($Book->getContentColumns()); ?>}}} 
     343Seems like the author has been saved but it its not included on the `app/views/book/show.tpl` view. You’ll add it this code right after `<? $content_columns = array_keys($Book->getContentColumns()); ?>` 
    346344 
    347345{{{ 
     
    349347}}} 
    350348 
    351 You must be screaming now about the rare {{{_{Author}}}} and {{{{book.author.name?}}}} syntax. Thats actually [http://www.bermi.org/projects/sintags Sintags] a small set of rules that helps on writing cleaner views and that will be compiled to standard PHP. 
     349You must be screaming now about the rare `_{Author}` and `{book.author.name?}` syntax. Thats actually [http://www.bermi.org/projects/sintags Sintags] a small set of rules that helps on writing cleaner views and that will be compiled to standard PHP. 
    352350 
    353351== Colophon == 
    354352 
    355 This is all for know, I’ll be improving this tutorial from time to time to add some missing features to this and other documents like: 
     353This is all for now, I’ll be improving this tutorial from time to time to add some missing features to this and other documents like: 
    356354 
    357355  * validations 
     
    369367 
    370368My apologies for any typo or grammatical error you might find. English is not my mother tongue and I would really like you to help me fixing errors in this document. 
    371  
    372