Skip to content
Locus framework, PHP5 - MVC - MongoDB
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Locus is a PHP Rapid Web Development Framework intended to utilise MVC and MongoDB
New in Locus 0.1.3:

  * System actually working. Can make models now, and push them to the database, and get them again.
  * Skeleton directory which you can copy to make as many Locus instances as you want!

  1) Copy skel to a new directory name, point your webserver documentroot at this directory.
  2) Change yourappdir/conf/conf.php to reflect your MongoDB database details.
  3) Create controllers, models, views
How to create a controller:

  1) Copy the stuff in controllers/pages.php
  2) Models to use go in $uses var on the controller;
  3) Name the function what you want your /controller/action to be
How to create a model:
  1) Copy the stuff in models/page.php
  2) If you want to associate this model with other models, you must do something like the following
     in your __construct magic method:
  3) your public $vars will be instantiated into the database if they do not begin with _.

How to create a view:

  1) Make an action.tpl file in views/controller/ directory. change action/controller depending on your intended path.
How to work with models:

  1) In your controller, you can do something like:
    $page = $this->Page;
    $page->body = "This is the page body";
    $page->title = "This is the page title";
    or if you have other models associated:
    $page = $this->Page;
    $page->body = "This is the page body";
    $page->title = "This is the page title";
    $comment_index = $page->add('Comment'); // if this is a hasMany
    $comment = $page->Comment[$comment_index];
    $comment->body = "This is the comment body";
    $comment->name = "This is the comment name";
    $second_comment = $page->add('Comment');
    $comment2 = $page->Comment[$second_comment];
    $comment2->body = "This is the second comment body";
    $comment2->name = "This is the second comment name";
    $user = $this->User->findOne(array("username" => "robinduckett")))
    $page->Author->username = "robinduckett"; // if this is a hasOne
    $page->Author->user_id = $user["_id"];
    $page = $page->commit(); // returns the whole thing as a nice object, how it looks in the db.
How to update models:

  * This is not currently finished.
    Proposed implementation:
    $user = $this->User->findOne(array("username" => "robinduckett")));
    $user->username = "haxd";
Something went wrong with that request. Please try again.