dracoblue.net

Hello Agavi-World! (Removing the default route)

In the previous step we

created our agavi project. Now we'll add some life!

Like defined in the previous step, the default action is Default.Index. As we just want to make a simple Hello World for that page, we head over to tambo/app/modules/Default/templates/IndexSuccess.php and change it's content to

<?php
    echo 'Hello World!';
?>

But if we visit http://localhost/ws/tambo/pub/ we still see the agavi logo! Open app/config/routing.xml and remove the 5th and 6th line stating:

<!-- this shows the welcome page after creating a project … ->
&lt;route pattern=”” module=”%actions.default_module%” … />

If we head over to http://localhost/ws/tambo/pub/ now, we see the brand new "Hello World!". Not so amazing :(. Don't worry, you just saw the rain drop on top of the tip of the ice berg.

In agavi, open source, php, tambo by DracoBlue @ 05 Feb 2009 | 140 Words

Wizards! Creating the Agavi-Project

After we

set up our agavi + propel libraries for the new project we want to create the project from scratch. Thatswhy we will not use the “agavi project-wizard” command but use “agavi project” instead.

$ agavi project
Agavi > project-wizard
Agavi > project-create
Project base directory [/home/jan/workspacePhp/tambo]:

We'll just hit [return], since that's exactly where the project should be.

Project name: [New Agavi Project]: Tambo

We may choose any name here, it's just for the stats/config. My example assumes Tambo.

Project prefix (used, for example, in the project base action) [Tambo]:

Agavi already created a prefix which fits well, so hit [return].

Default template extension [php]:

Yes, we're fine with .php as extension for templates (hit [return]).

Document-root relative path to the Agavi index.php script [/]:

This is the path, which will be used if you access the project on your webserver. In my case the project will be accessible at http://localhost/ws/tambo/ so I fill /ws/tambo/

pub/ . If you have any other folder, like http://localhost/ tambo you use /tambo/ pub/. As you may see the project itself will have a folder pub, we'll look at that later. Now I hope you got an idea on how that document root is build.

Space-separated list of modules to create for Tambo [Default]:

We'll create the modules later, so we hit [return].

Now, follows the project creation task. As soon as you are skilled with Agavi and already know what Modules/Models/Views/Actions you want to create, you'll get how to fill these fields. For the start: It's not important and not a problem, if you just keep the default!

Space-separated list of actions to create for Default:

Laters! Hit [return].

Module for default system action [Default]:

Fine! Hit [return].

Action for default system action [Index]:

Fine! Hit [return].

Space-separated list of views to create for Index [Success]:

Fine! Hit [return].

Module for error_404 system action [Default]:

Fine! Hit [return].

Module for unavailable system action [Default]:

Fine! Hit [return].

Module for module_disabled system action [Default]:

Fine! Hit [return].

Module for secure system action [Default]:

Fine! Hit [return].

Module for login system action [Default]:

Fine! Hit [return].

Our project is now created. When we had over to our directory with the browser ( http://localhost/ws/tambo/pub/ ) we'll see our new application! Well done!

In agavi, open source, php, tambo by DracoBlue @ 05 Feb 2009 | 455 Words

(non)PEAR installation for Agavi and Propel

There are two ways to create an agavi project using propel.

  1. Pear-Way: 1.1 Install propel:
pear install channel://pear.phpdb.org/phpdb/propel_generator
pear install channel://pear.phpdb.org/phpdb/propel_runtime

1.2 Install agavi:

pear install channel://pear.agavi.org/agavi-1.0.0beta8

1.3. For each project, you create a new folder and run:

agavi project-wizard
  1. The custom way (later for deploying entire application + libs): 2.1 Create a new folder "myproject". 2.2 Create a sub folder myproject/libs and myproject/libs/propel and also myproject/libs/agavi 2.3 Download

agavi's and propel's latest release* and paste the contents of the .zip/.tar.gz files in the corresponding directory. 2.4 Copy either myproject/libs/agavi/bin/agavi-dist to myproject/agavi (on linux/mac) or copy myproject/libs/agavi/bin/agavi.bat-dist to myproject/agavi.bat (on windows) 2.5 Create the project with : a) Windows:

agavi project-wizard

b) Linux/Mac:

./agavi project-wizard

2.6. Open the agavi(.bat) file and change AGAVISOURCEDIRECTORY to libs/agavi/src (or on windows libs\agavi\src)

I suggest you use the project-wizard helper only if you already know all the modules/actions you want to create. You can easily add them later with other helpers!

  • Of course you can checkout also the latest svn from agavi's https://svn.agavi.org/branches/1.0 or propel's http://svn.phpdb.org/propel/trunk

In agavi, open source, php, propel, tambo by DracoBlue @ 05 Feb 2009 | 208 Words

How to validate an array with agavi

If you want to validate an array as parameter for an agavi action, you have to validate each of the array entries on its own.

Assuming we have an array called

options with the value as an array:

array(
  'title'=>'string text',
  'subtitle'=>'string subtext'
)

The following snippet validates it (every element is string - sorry for the laziness):

&lt;validator class="string" required="true">
    &lt;arguments base="options[]">
        &lt;argument>title&lt;/argument>
        &lt;argument>subtitle&lt;/argument>
    &lt;/arguments>
&lt;/validator>

Thanks to

v-dogg and wombert for the hints on how to make that.

In agavi, open source, php, validator by DracoBlue @ 04 Feb 2009 | 93 Words

retrieveByPKs undefined

Today we noticed that on some propel generated models the function retrieveByPKs was missing.

We found out that this was because of the fact that retrieveByPKs is only generated by Propel if there is only a single PrimaryKey!

In php, propel by DracoBlue @ 04 Feb 2009 | 38 Words

Page 29 - Page 30 - Page 31

Give something back

Were my blog posts useful to you? If you want to give back, support one of these charities, too!

Report hate in social media Campact e.V. With our technology and your help, we protect the oceans from plastic waste. Gesellschaft fur Freiheitsrechte e. V. The civil eye in the mediterranean

Recent Dev-Articles

Read recently

Recent Files

About