March 31st, 2011

Creating Micro Web Applications with Limonade and La Distribution

In our previous blog post, we explained why La Distribution was a perfect platform to code simple web applications. Now, we’ll explain you how to start coding and distributing your first application with the Limonade framework.

Given that you are a seasoned web developer, it should not be difficult. And if you’re not, hey, are you sure you want to do this? :)

Setup La Distribution development environment

If you want to start hacking around La Distribution, we first recommend to setup a local copy from SVN and configure our command line utility. This what we’ll call from now “La Distribution development environment”.

First checkout La Distribution SVN repository:

svn checkout http://ladistribution.net/svn/trunk/ ld-dev

Alternatively, you can also use our brand new Git repository:

git clone git@github.com:ladistribution/ladistribution.git ld-dev

Then update permissions:

As a web developer, I believe you know that working around user permissions and web server permissions can be a bit messy. In this tutorial, for the sake of simplicity and because we’re not working on real web server, we’ll fire chmod 777. If you know better, well, do it :)

chmod -R 777 ld-dev

Now, execute the web installer, say you’re on localhost:

http://localhost/ld-dev/installer.php

Follow on screen instructions, create the first user, eventually register a MySQL database connection, and you’re done.

Now, we’ll make the ladis command line utility available from the terminal.

To do that, you can add La Distribution /bin/ directory to your PATH. Be careful, the following code is just an example, modify it to match your system. And, it’s an absolute path.

export PATH=$PATH:/var/www/ld-dev/bin

Type ladis in the terminal to check that it works. It should output something like that:

# config: /var/www/ld-dev/dist/site.php
# site: /var/www/ld-dev/
La Distribution 'edge'
Copyright (c) 2009-2011 h6e.net / François Hodierne (http://h6e.net/)
Licensed under the GPL and MIT licences.

Create a web application using Limonade

Internally, we decided to write our first Micro Web Applications using the Limonade framework. If you want to find documentation on this framework, check their website.

You can start from our Hello World application, it will be a good basis. You can download it from our Github repository.

In this tutorial, we’ll grab it directly from the command line.

git clone git@github.com:ladistribution/hello-world.git my-application

We’ll delete the .git folder because we just wanted to export this project, not actually track it. We’ll later version control again if needed.

rm -rf my-application/.git

Now, to make it your own, edit the dist/manifest.xml file and change the “id” and “name” of the application.

  <package>
    <id>my-application</id>
    <name>My Application!</name>
    ...

If you try http://localhost/ld-dev/my-application/ immediately it will not work. You have to register the application:

ladis register my-application

As seen before, in case you encounter permission issues. Fire:

sudo chmod -R 777

Build the package, share it with the world!

We’ll now build the package to distribute our web application:

cd my-application
ladis package build

my-application.zip is now created.

To make it available to other users, you should push it to a public La Distribution repository. This repository should be hosted on a public server, accessible to others.

It’s easy, go on any public La Distribution installation under your control (ie: not localhost). Sign in, go in Settings, then Repositories. There, create a new local repository, name it “apps” for instance.

Click on Manage, and upload the .zip.

It’s online! Now you can pass your repository Public URL to your friends so that they can install your application.

Of course, you can also automatize the publication from the command line. In the web panel, copy the repository “Push URL”. Then register it locally:

ladis package add-remote

Paste the Push URL, enter your credentials. And from now, pushing the package to the remote repository is that easy:

ladis package push

Conclusion

It was a bit technical but not that difficult, uh?

We’re now waiting for your apps!

Don’t hesitate to start simple apps, make it available to others and share them with a Git repository. People may be interested and help you bring your application to the next level. Speaking for me, I’m pretty sure I’ll do :)

No Comments

Leave a comment