Git Product home page Git Product logo

eregansu's Introduction

Introduction

Eregansu is an application framework written in PHP. It requires PHP 5, probably PHP 5.2. It shouldn’t require PHP 5.3 just yet.

Rather than try to build yet another PHP framework designed to hide the gory details of how a modern application works from the poor developer who doesn’t really know what’s going on, Eregansu has quite a specific target audience: developers who could write this themselves, but have better things to be doing with their time.

As such, Eregansu doesn’t go out of its way to be the easiest or most modular framework in the world. It provides enough to make life easier, and aims to be well-structured enough that it can be extended easily as required. Extensions to some parts (such as authentication or session-handling) will require changing the code, but this is one of those age-old trade-offs.

Eregansu does not seek to be as comprehensive as, say, the Zend Framework, which currently weighs in at several tens of megabytes. Eregansu is lightweight and fast.

This is not an abstract work, either. Eregansu (in its current incarnation) was created for a specific application and open sourced. There wasn’t a meeting one day where somebody exclaimed “I know, let’s write an open source PHP application framework!”

To many developers, the structure will be immediately recognisable as an Model-View-Controller (MVC) framework. Within Eregansu, models are just that, descendants of Routable (technically, any instance of IRequestProcessor will do) are the controllers, and instances of Template are the views. The template engine itself is as simple as it can possibly be: templates are PHP, though by convention have a “.phtml” extension to indicate the fact that they’re primarily mark-up (with code sprinkled over them), rather than the other way around.

If you’re just getting started with Eregansu, you could do worse than clone the Eregansu-Examples project.

One caveat: it is assumed, just about everywhere, that you know how to configure your web server. Although the code doesn’t, the default .htaccess file makes the assumption that each Eregansu application runs on its own virtual host (see the RewriteBase statement). It’s also assumed that you know what a symbolic link is and how to use them.

If you want to learn how Eregansu works, start by reading the default index.php and follow the code.

Eregansu Hello World

Change to your web server root (or wherever you want your application to be served from).

Check out Eregansu into a directory called 'platform':

$ git clone git://github.com/nexgenta/eregansu.git platform

Set everything up:

$ ./platform/eregansu install

Alternatively, if you want to do it by hand, this is what happens:

$ mkdir config app templates
$ cd templates
$ ln -s ../platform/login/templates login
$ cd ..
$ cp platform/index.dist.php index.php
$ cp platform/htaccess.dist .htaccess
$ cp platform/config.default.php config/config.myhostname.php
$ ( cd config && ln -s config.myhostname.php config.php )
$ cp platform/appconfig.default.php config
$ ( cd config && ln -s appconfig.default.php appconfig.php )
$ mkdir templates/default
$ cp platform/examples/templates/* templates/default/	

(Replace “myhostname” with the name of your host — e.g., johndev)

Next, If you’re going to use the provided login applet, you’ll want Chroma-Hash:

$ git clone git://github.com/mattt/Chroma-Hash.git

Using Silk

Silk is a toy web server, written in PHP to run on top of Eregansu itself. It’s no real use as a “proper” web server, but it’s sometimes useful for testing.

To launch silk, simply run the following from your application root:

$ ./eregansu silk

You will probably see output similar to the following:

silk: Warning: Session directory /var/php/5.2/sessions is not writeable, using /var/tmp/
silk: Listening on port 8998

Now, you can point your web browser at localhost:8998 (or someotherhost:8998 if you’re working on a remote host), and you’re away.

Using Apache

Eregansu will by default create a .htaccess file in your application root for use with Apache. All you should need to do is create a virtual host with the appropriate DocumentRoot setting. You’ll need to enable mod_php5, and mod_rewrite, and ensure the directory-level access rules are configured properly.

Something like the below will do (adjust to suit your configuration):

<VirtualHost *:80>
	ServerName eregansu.localhost
	DocumentRoot /home/developer/eregansu
	DirectoryIndex index.html index.php
</VirtualHost>

<Directory /home/developer/eregansu>
	Order allow,deny
	Allow from all
	Options ExecCGI FollowSymLinks
	AllowOverride all
</Directory>

Using lighttpd

Add something like the below to your lighttpd configuration:

$HTTP["host"] =~ "^eregansu\.localhost$"
        server.document-root = "/home/developer/eregansu"
        url.rewrite-once = (
                "^(?!/((app|templates|media|content)/.*|favicon.ico))" => "/index.php"
        )
}

This assumes you already have the necessary configuration for PHP in place. See the lighttpd documentation for more information on this. A simple setup using fastcgi would be:

static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )
fastcgi.server = ( ".php" => ((
    "socket" => "/tmp/php-fastcgi.socket",
    "bin-path" => "/usr/php/5.2/bin/php-cgi",
    "max-procs" => 4,
    "idle-timeout" => 30,
    "broken-scriptfilename" => "enable",
    "allow-x-send-file" => "enable",
    ))
)
index-file.names = ( "index.html", "index.php" )

(This configuration snippet was taken directly from an OpenSolaris host running the Sun-provided PHP 5.2 and lighttpd 1.4 packages — you would need to adjust your paths to suit).

eregansu's People

Contributors

nevali avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

giastfader

eregansu's Issues

RDFDocument::offsetSet() should permit explicit keys

The specified key should be either a URI or expandable to a URI, or a numeric key (below). If the URI is already a subject of the specified instance, it should be re-ordered to appear as the first value in the $inst['rdf:about'] array. If the URI doesn't already exist as a subject of the instance, it should be unshifted into the array.

If the key is numeric, the subject should be added (if not previously added to the document) or moved to appear in the specified position. e.g., $doc[0] = $doc['primaryTopic'] would move the primary topic of the document to appear first in the subject list.

Refactor Xapian handler to avoid leakage

The Xapian search handler leaks (to the point of termination if a memory limit is in effect) if a single process attempts to both read and write to the same on-disk database.

The handler should be refactored to ensure that there's only ever one database open at a time, re-opening for writing when required.

Add RDF::documentFromCurl()

The network-related guts of RDF::documentFromURL() should be refactored to allow a specific Curl instance to be supplied in lieu (or as well as?) as URL, permitting additional headers and rules to be supplied by the API's user.

Allow processRequest, getObject, et al, to return IRequestProcessor instances

Rather than solely relying on forwarding, getObject() (and by extension, processRequest()) should be able to return an IRequestProcessor instance to cause the active Request object to be processed with that instance instead. This would not be a valid return for anything intended to be a top-level App instance, as that would obviously alter the basic request-processing flow in platform.php and index.php

Default JSON handler should support JSONP

If the "jsonp" parameter is present, then its value the name of the function which would be invoked by executing the output. Thus, given ?jsonp=receivedData, the output would be:

receivedData({ … })

Instead of

{ … }

RDFDocument should implement ArrayAccess

RDFDocument should allow offsetGet() to be an alias for subject() and offsetSet() to be an alias for replace(); additionally, offsetGet('primaryTopic') should be the equivalent of primaryTopic().

deploy/post-receive should handle shared/public subdir

Where there is a 'shared' directory which contains a 'public' subdirectory, the content of this subdirectory should be symlinked into the working copy's own public directory (which should be created if it does not exist). Similarly, a file named 'public' should be skipped when generating working copy-rooted symbolic links from 'shared'.

RDFSet should be iterable

The RDFSet class should support the Iterator interface to allow easy enumeration of objects attached to a predicate.

Add some basic variable substitution to templates

While plain PHP for conditionals, loops, and helper functions is fine, it's a pain for variable substitution. A lightweight substitution pass on the templates would simplify many templates and make them easier to read.

Suggest borrowing ASP’s <%=var%> syntax, with the values passed through _e().

deploy/post-receive should only pay attention to certain branches

deploy/post-receive should read the branch name (if any) passed by git and only perform the deployment if it matches a pre-configured value; thus, any push to the deployment repository is valid, but only those to (e.g.), refs/heads/live will cause a checkout/rotation to occur.

Refactor tests

Eregansu tests should be refactored out into a common module which can be used by any Eregansu-based module or application.

Installer mis-creates symlink for config.php if dangling link already exists

Before:

lrwxr-xr-x  1 mo everyone   17 2011-04-20 10:32 config.php -> config.sobkou.php

(config.sobkou.php was removed; installer was re-run specifying an instance name of "sample")

After:

lrwxr-xr-x  1 mo everyone   17 2011-04-20 10:32 config.php -> config.sobkou.php
-rw-r--r--  1 mo everyone 1493 2011-04-20 13:24 config.sample.php
lrwxr-xr-x  1 mo everyone   17 2011-04-20 13:24 config.sobkou.php -> config.sample.php

Re-factor content negotiation, move to Request

The content-negotiation logic from the Routeable classes should be migrated to a Request::negotiate() method which returns an array of response headers ('Content-type', 'Content-language', etc.) if the request can be satisfied based upon the constraints supplied as parameters, or null if not.

When serialising RDF, if the CURIE would be invalid, don't use it

e.g., rather than generating…

<ns12:1786Opera rdf:about="http://dbpedialite.org/resource/The_Marriage_of_Figaro">

generate:

<rdf:Description rdf:about="http://dbpedialite.org/resource/The_Marriage_of_Figaro"><rdf:type rdf:resource="http://dbpedia.org/class/yago/1786Operas"/>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.