Skip to content
MVC web framework for Euphoria (https://openeuphoria.org/)
Eiffel E HTML
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs
examples
include * Imported creole parser from https://github.com/OpenEuphoria/creole Sep 8, 2019
templates
.gitignore
CONDUCT.md
CONTRIBUTING.md Create contributing document Jun 3, 2019
LICENSE.md Create license document Jun 3, 2019
README.md
eu.cfg * Initial commit. Sep 23, 2018

README.md

Euphoria MVC

Euphoria MVC is a model-view-controller framework for Euphoria.

Project status

This project is in the very early stages of development. Things can and will break or change until we reach a stable release.

Features

Templates

Build your views in HTML and then render your data to the page.

Routing

Automatically route static or dynamic paths to handler functions.

Database

Execute queries on any (well, most) database systems from one codebase.

Models

(Coming soon!)
Easily store and fetch Euphoria data via object-relation mapping (ORM).

Configuration

Load and store data in configuration files.

Cookies

Store snippits of data with your end users.

Sessions

Store more data locally with minimal cookies.

Getting Started

This example assumes you are running Apache 2.4 on Linux and that you've already got a basic working web server.

Download Euphoria

wget "http://sourceforge.net/projects/rapideuphoria/files/Euphoria/4.1.0-beta2/euphoria-4.1.0-Linux-x64-57179171dbed.tar.gz/download" -O euphoria-4.1.0-Linux-x64-57179171dbed.tar.gz
sudo tar xzf euphoria-4.1.0-Linux-x64-57179171dbed.tar.gz -C /usr/local/

Install Euphoria

cd /usr/local/bin/
sudo find /usr/local/euphoria-4.1.0-Linux-x64/bin/ -type f -executable -exec ln -s {} \;

Get Euphoria MVC

Check out euphoria-mvc into your project directory

git clone https://github.com/openeuphoria/euphoria-mvc

Or if you're already using git, check out as a submodule.

git add submodule https://github.com/openeuphoria/euphoria-mvc

Configure Euphoria

Update your eu.cfg to use euphoria-mvc/include.

[all]
-i euphoria-mvc/include

Update .htaccess

Tell Apache you want it to execute Euphoria scripts and use index.esp as the index.

AddHandler cgi-script .esp
Options +ExecCGI
DirectoryIndex index.esp

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.esp/$1 [L,NS]

You can also add a block like this to keep snoopers out of certain files:

<Files ~ ".cfg$|.err$|.edb$">
    Deny from all
</Files>

Although the ideal solution would be to store sensitive data outside of your web root.

Write your template.

Save this as templates/index.html.

<!DOCTYPE html>
<html>
<head>
  <title>{{ title }}</title>
</head>
<body>
  <h1>{{ title }}</h1>
  <p>{{ message }}</p>
</body>
</html>

Write your application.

Save this as index.esp.

#!/usr/local/bin/eui

include mvc/app.e
include mvc/template.e
include std/map.e

function index( object request )

    map response = map:new()
    map:put( response, "title", "My First App" )
    map:put( response, "message", "Hello, world!" )

    return render_template( "index.html", response )
end function
app:route( "/", "index" )

-- "/" is the URL path, "index" is the name of the route
-- route() will find the matching routine automatically

app:run()

Run your application

Open your web browser to your application URL.

You can’t perform that action at this time.