King23: Getting started

Introduction

this Article is meant to give a quick how-to-start with King23,
it will lead through the basic installation, and the creation of a first project

Requirements

Software

King23 might run with other setups aswell, but this is the setup it was written for,
so i assume that you are using something like this.

  • PHP 5.2+
  • Apache + mod_rewrite
  • Linux with access to the shell(!)
  • a GIT client

Knowledge

To actually use King23 you will need to know about a few things,
most of them are not exactly rocket science, and there are alot of good
tutorials about them available on the internet, its not covered in this article,
so use google :)

  • PHP
  • Using the Linux shell
  • Configure Apache
  • Using your favorite text editor

Installing King23

First of all we are going to clone the King23 git, then we will setup the commandline
script of King23 to be in the path. Lets assume you want to install it in a subfolder of
your home directory called “www”, and then add it to your path for the current running shell.

first we move ourselves to our home, and create the www directory:

cd
mkdir www
cd www

Now we clone the git from github:

git clone git://github.com/ppetermann/king23.git

This will create a folder named “king23” containing the complete King23 distribution.

Now the next part is to get the king23 command line script residing in ~/www/king23/bin/
in our path. offcourse you can omit that step and allways call it from there, but it is
much more compfortable to be able to run it directly.

In this example we simply add it to our current PATH variable:

export PATH=$PATH:/home/USERNAME/www/king23/bin/

other ways would be putting it in our bashrc / profile either by extending
the PATH variable there or by writing an alias, another way is to make a symlink
to the script from a folder that is allready in the path

if you have setup the binary to your path (and i assume you did so),
then putting [b]king23[/b] to your shell should output something like this:

[2010-05-29 10:04:23] King23 CLI (Version: 0.0.2)
[2010-05-29 10:04:23] Syntax: king23 <taskmodule>:<task>
[2010-05-29 10:04:23]
[2010-05-29 10:04:23] Available Modules:
[2010-05-29 10:04:23] King23

Congratulations, you have now installed the framework itself.

Creating an King23 Project

With having the cli script running creating the actual project
is quite simple. As you might have seen the king23 script provides by default
a module called King23. If you run the script stating the module and omiting
a task OR using info as task you will get a bit more information on
what the King23 Module can do for you:

king23 King23

output:

[2010-05-29 10:15:12] King23 called without task, assuming 'info'
[2010-05-29 10:15:12] King23 Version:
[2010-05-29 10:15:12] 0.0.2
[2010-05-29 10:15:12] Description:
[2010-05-29 10:15:12] King23 is lightweight MVC Framework
[2010-05-29 10:15:12] Authors:
[2010-05-29 10:15:12] Peter Petermann <ppeterman80@googlemail.com>
[2010-05-29 10:15:12]
[2010-05-29 10:15:12] Module King23
[2010-05-29 10:15:12] -----------------------
[2010-05-29 10:15:12] Task: info
[2010-05-29 10:15:12] Description:
[2010-05-29 10:15:12] General Informative Task
[2010-05-29 10:15:12]
[2010-05-29 10:15:12] Task: list_modules
[2010-05-29 10:15:12] Description:
[2010-05-29 10:15:12] show a list of all currently available modules
[2010-05-29 10:15:12]
[2010-05-29 10:15:12] Task: create_project
[2010-05-29 10:15:12] Description:
[2010-05-29 10:15:12] create a new project, requires project name as parameter

As you can see the King23 module does not provide much atm, but it provides
us with the task that we are looking for: create_project, and as you can see
in the description create_project takes one parameter (the project name).

Lets assume we want to call our project “myapp”, the our command line call would be:

king23 King23:create_project myapp

output:

[2010-05-29 10:19:21] King23 (Version: 0.0.2) project creation
[2010-05-29 10:19:21] copying project template to myapp
[2010-05-29 10:19:21] creating symlink myapp/lib/King23 to point to /home/USERNAME/www/king23
[2010-05-29 10:19:21] Setting rights in myapp/template_c/
[2010-05-29 10:19:21] Project: myapp created

this should leave you with a working king23 application template
having the directories:

  • conf/ the projects configuration files
  • public/ the projects web root, this should be the documentroot for your apache vhost(!)
  • lib/
    • lib/King23 a symlink to your King23 installation
    • lib/SithTemplate a copy of Piotr Legnicas awesome template system
  • tasks/ a folder in which project specific tasks extending the commandline script can be added
  • templates the templates used by the application
  • templates_c a place where SithTemplate can store compiled templates (for more information on that check SithTemplates docs)
  • views a folder where the view scripts are stored.

If you now configure your apache to use /home/USERNAME/www/myapp/public/ as the DocumentRoot,
and then post your browser to the application (example: http://localhost/) you should see the
welcome screen of your first King23 application.

Next steps

Web

you probably now want to have a look at conf/routes.php, the scripts in the views/ folder, and the templates.

Docs

If you check in the lib/SithTemplate folder you can find documentation about the template system there,
running phpdocumentor or doxygen should create an api documentation for King23 too (might be available online
in future)

Tasks

if you want to run stuff from the command line, make sure to check tasks/ for the example
that provides you with

king23 EXAMPLE:example

in the myapp folder

the end

i hope this gives you a quick start with King23, a more comprehensive tutorial on how to actually use it will come – soon.

Advertisements

One thought on “King23: Getting started

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s