Aug 19
Permalink

Get me a standard agavi project, the fast way

More often than not I want to create a new agavi project the “standard” way, that is:

  • Change the projects name
  • Change the projects prefix
  • Use the defaults for all other options

Calling agavi project-wizard makes me answer all questions, one by one. Sure, pressing enter at every prompt works, but I value my time too much to press enter at every prompt. I’d rather go write a blog post about how not to press enter at every prompt.

Enter “yes”

“yes” is a small commandline utility that answers “yes” or any given string to any prompt given to it:

yes '' | agavi project-wizard

will create a project with all default values. Now the only thing that needs fixing is the project name and the project prefix - we can do that on the commandline[1]:

yes '' | agavi -D project.name "My little test project" -D project.prefix "MyLTP" project-wizard

This is not faster in any way than running through the wizard, but I can do other things during that time.

[1] Please note this bug that prevents passing parameters with spaces to the build system: http://trac.agavi.org/ticket/1137

Aug 12
Permalink

Third Agavi Article on IBM developerWorks

The third article in the series on Agavi over at IBM developerWorks has just been published.

This part focuses on creating an administration interface and on securing it. Go read it, rate it, blog about it and once again spread the word!

Permalink

Finally, nightly documentation builds

Finally a nightly pdf build of the agavi guide is available. It’s based on trunk and can be downloaded from http://www.agavi.org/documentation-nightly-pdf.tar.gz. The tarball contains the pdf version of the guide and all stage tarballs.

The current build scheme is very simple and the file is replaced every night. The location may change if and when we decide to keep older versions of the guide around. Until then: Enjoy.

Aug 04
Permalink

Using your own build templates from second zero

Some tasks are nice to have around in each and every project, such as the JSLint task I wrote about earlier today. However, we still don’t want that in each and every project - where’s the point in having a js-lint in a project that does not use any javascript at all like a pure service oriented project without any html output? So we don’t want that task in the core agavi build file but still in our standard project. However, using agavi project-wizard copies the standard agavi buildfile, so we have to manually copy our changes over and over again. Tedious work. We might also have a customized set of templates to use with the latest output type generation feature and we’d like to use that from the start so that all views generated in the project wizard benefit from that as well. But hmm, agavi project-wizard uses the standard templates. So let’s go change that.

A custom template set

We start off by copying the standard template set - there’s a task for it:

Zodiacal-Light:Sites fgilcher$ mkdir agavi-build-templates
Zodiacal-Light:Sites fgilcher$ cd agavi-build-templates/
Zodiacal-Light:agavi-build-templates fgilcher$ agavi system-template-copy-all 
Agavi > system-template-copy-all:

Output directory [/Users/fgilcher/Sites/agavi-build-templates]: 
     [copy] Copying 55 files to /Users/fgilcher/Sites/agavi-build-templates

Zodiacal-Light:agavi-build-templates fgilcher$ 

Now we modify the build.xml.tmpl to contain our JSL-Task:

<?xml version="1.0" encoding="utf-8"?>
<project name="%%PROJECT_NAME%%" basedir="." default="status">

    <!--
      Define project-specific or custom build targets.
      -->

    <target name="lint-javascripts" description="check all javascripts for validity">
        <property name="javascript.lint.showWarnings" value="true" />
        <jsllint showWarnings="${javascript.lint.showWarnings}" haltOnFailure="true">
            <fileset dir="${project.directory}/pub/">
                <include name="**/*.js" />
            </fileset>
        </jsllint>
    </target>

</project>

We can also change or add any other template we might like at this point. From here on it’s a matter of passing the template directory to use to the agavi script:

Zodiacal-Light:Sites fgilcher$ agavi -D templates.directory /Users/fgilcher/Sites/agavi-build-templates project-wizard
...
Zodiacal-Light:Sites fgilcher$ 

Done. This project will use the modified set of build templates from now on.

Permalink

Extending the build system - integrating JSLLint

Javascript errors are annoying and notoriously hard to track down due to limited IDE support and misleading error messages in browsers, but often it’s only a missing comma or a bracket in the wrong place. A linter helps by checking that your javascript is a least structurally sound. It’s the first check I run on any javascript that does not work, so having it right at my fingertips is important. I’ll show how to integrate that into any agavi project.

There’s a number of JS-Linters out there, I use http://www.javascriptlint.com/, primarily because there’s an existing phing task for it (1). As the agavi build system is based on phing integrating that task is a breeze. Each agavi project has a build.xml in the root directory that can be used to define project-specific targets. By default it’s empty and looks like this:

<?xml version="1.0" encoding="utf-8"?>
<project name="Sample" basedir="." default="status">

    <!--
      Define project-specific or custom build targets.
      -->

</project>

Adding a JSL-Task is a matter of seconds:

<?xml version="1.0" encoding="utf-8"?>
<project name="Sample" basedir="." default="status">

    <!--
      Define project-specific or custom build targets.
      -->

    <target name="lint-javascripts" description="check all javascripts for validity">
        <property name="javascript.lint.showWarnings" value="true" />
        <jsllint showWarnings="${javascript.lint.showWarnings}" haltOnFailure="true">
            <fileset dir="${project.directory}/pub/">
                <include name="**/*.js" />
            </fileset>
        </jsllint>
    </target>

</project>

And now it’s just a call to

Zodiacal-Light:~ fgilcher$ agavi lint-javascripts

That’s it. It’s trivial to extend the task-definition to pass some options to the linter - I’ll leave that to you.

(1) There’s a minor bug in the JSL-Lint Task that’s fixed on trunk. See http://phing.info/trac/ticket/349

Jul 30
Permalink

New SSL Certificates on agavi.org

https://svn.agavi.org/ and https://trac.agavi.org/ now use SSL Certificates signed by CACert. CACert’s root certificate is not installed by default on most operating systems, browsers and so forth, which means you might get trust warnings.

You can either trust the individual certificates, or, for more convenience, you can download their root certificate from their website and import it into your system/browser/whatever; after you’ve done this, everything should work without warnings. Make sure you compare fingerprints and certificate details when doing this.

You will also need to trust the certificate separately for command line SVN, which is explained here. Of course, you can alternatively just trust the svn.agavi.org certificate itself when prompted.

Note to Mac OS users: after importing the root certificate into Keychain, you might still get warnings at least in Safari. If that’s the case, change the policy for “SSL” to “Always Trust” under “Trust”.

Jul 29
Permalink

Icinga praises Agavi

The Icinga team posted an “Ode to Agavi” yesterday. All I can say is “Thanks, I feel flattered.” and I’m speaking on behalf of all team members here. This is exactly why we do this and we’ll do our very best to code up your high expectations.

For those who have never heard the name: Icinga is a fork of the popular Nagios monitoring application.

Jul 28
Permalink

Second Agavi Article on IBM developerWorks

The second article in the series on Agavi over at IBM developerWorks has just been published.

It focuses on handling of forms and the integration with Doctrine. Go read it, rate it, blog about it and spread the word!

Jul 25
Permalink

Agavi 0.11.8 released!

Agavi 0.11.8 is now available for download at www.agavi.org.

This maintenance release fixes three bugs over Agavi 0.11.7:

  • AgaviArraylengthValidator didn’t work with files
  • Arrays that failed validation were not purged from request data
  • Memory leak in AgaviTranslationManager::getLocaleIdentifier()

It also contains minor optimizations in AgaviInarrayValidator and AgaviArraylengthValidator.

The bundled timezone database was also upgraded to version 2009k.

As always, the CHANGELOG has a complete list of changes in this release.

This release marks the end of maintenance for Agavi 0.11.x, as previously announced.

Jul 21
Permalink

News from The Edge - Improved Build System

Since some weeks ago, the agavi build system features a set of new nifty features. The build system has always been a great help to me as a developer saving me the tedious, boring work of writing the action, view and model stubs. And now, the build system gets even better:

The agavi build system now supports

  • Generation of executeRequestMethod() methods for action. That saves another hundred keystrokes when generating an action.
  • Generation of simple actions. Shaves off even more.
  • Generation of executeOutputType() methods for views.
  • Generation of properties and the respective getters and setters for models.

Let’s have a lookt at a short example: Before the change, creation of a view went like this:

> agavi view-create
> Module name: Default
> Action name: Index
> View name: Success

Done. But the view would only support the default executeHtml() method to handle the html output type. It would always contain this method, even if I only wanted to handle text output. Now this changes

> agavi view-create
> Module name: Default
> Action name: Index
> View name: Success
> Space-separated list of output types that should be handled. [html]: text

Done. So now I have one single prompt more, but the view is created with exactly the output type(s) that I want it to have. In this case it only handles text but I could list any number of output types here.

The generated code to handle the various output types can be controlled by supplying a suitable template. The default template generates the standard code, using a setup method that is named like the output type:

public function executeText(AgaviRequestDataHolder $rd)
{
    $this->setupText($rd);

    $this->setAttribute('_title', 'Index');
}

If I want that changed for all text output types, I just create a suitable template that changes the code the way I want. All other output types will still use the default template.

This feature not only saves the developer from writing all that boilerplate code but has other benefits as well. We can now go and integrate the testing system and the build system even further. Now that we generate the methods for you, we have all the information to generate the relevant testcases as well, reminding you that the best way to keep your code bug-free is to automate the testing.

If you’d like to check this out, have a look at changeset 4155 or see the relevant ticket for further information.