Core overview

From SocialStrap Wiki
Jump to: navigation, search

SocialStrap script is built and organized around well known MVC (model-view-controller) programming architecture using Zend Framework 1.12. The script contains three main components Model, View and Controller.


Controller

This component is going to process and responding to all events such as user actions and it's going to invoke changes to the model (database) or the view based on that. Each controller can have many different actions. For example, controller is 'Search' and action is 'Users'. Unless overridden, each controller/action is automatically mapped to the appropriate directory/file inside the view layer.


Model

This component handles the data. It contains all data-related application logic. Its only job is to retrieve and store the data into the database. All functions inside a model are usually invoked from the controller. Each model is usually mapped to a single database table.


View

This is presentation layer (layout), what user see and how everything looks. This is the last part which will be executed on the server side. Some view files are 'partial' or 'common' which means they are used in many different places as a small chunks of code.


Application workflow

Application workflow looks something like this:

URL
|
|
CONTROLLER/ACTION <-> MODEL (DB)
|
|
VIEW
|
|
OUTPUT TO BROWSER


URL mapping

Each browser's requests is mapped like this:

http://www.yoursite.com/[controller]/[action](/[param1]/[value1]/[param2]/[value2]/...)

So in this case:

http://www.yoursite.com/notifications/list/page/3

controller will be 'notifications', specific action is 'list' and a parameter called 'page' has a value of '3'.

After some initialization (Bootstrap process), application will look into the notification controller /app/core/controllers/NotificationsController.php searching for list action function listAction(). This action will call notification model (/app/core/models/Notifications.php) to get the necessary data and it will store that in a view variable. At the end of the listAction() function application will automatically execute the view part mapped to same controller/action path /app/core/views/layout/notifications/list.phtml

Note: when action or controller name is omitted router will assume that the name is 'index'.

There are few exceptions in URL routing applied during bootstrap process /app/core/Bootstrap.php in order to create pretty URL for all profiles. All users, groups and pages are actually mapped to controller called 'profiles' and action called 'show'. So example.com/john is actually mapped here: example.com/profiles/show/name/john


File Structure

Please note that core functionality can be changed with each new update. By making changes here you risk that either your current version or any future version won’t run properly. Instead, try to extend and customize the script with addons.

app/ 
app/log.txt (main application log file)
app/configs/ 
app/core/controllers/ (controllers and actions) 
app/core/controllers/helpers/ (common controller helpers)
app/core/forms/ (form logic)
app/core/languages/ (translations) 
app/core/models/ (model component - database logic)
app/core/plugins/ (common, reusable application-wide code)
app/core/views/ (view component)
app/core/views/emails/ (email templates)
app/core/views/helpers/ (common, reusable code)
app/core/views/info/ (info pages, about, terms etc.)
app/core/views/layout/ (layout root) 
app/core/Bootstrap.php (application init) 
app/lib/ (Zend Framework) 
app/tmp/ (temporary, cache files)