phpBricks alpha preview

In phpBricks on January 10th, 2010

phpBricks is MVC framework for PHP programming language. It’s the framework so it may not be the way you want, but it’s the way I/we have found right. In early stage of my programming career, I see lot of resources and time was consuming to write same piece of validation code and I decide to save that time by writing piece of code which can be reused. After then, I see series of such things one after another, like:

  1. Mix/Max of php and HTML code, which is pain in ASS to UI programmer, CSS guys.
  2. Junk and vulnerable SQL statement, no way to make site secure.
  3. Bunch of configuration variables and constants on config.php file.
  4. Unmanaged structure of files, functions and classes.
  5. Not proper modular structure which cause hard to maintenance application.
  6. Personal interest of variable, function naming – lots of garbage and junk codes.
  7. Writing and re-writing of code for same function within one projects and in multiple project.
  8. No common standard and no central key. Different flow of each function/module, you never can say start and end when it comes to debugging.
  9. And, I am seeing lot more others day by day…

So, on process of eliminating those stuffs, I keep enhancing that piece of code with feedback and direct involvement of some handful colleague, phpBricks is made.

I understand it is same pain for all programmers until you know such framework exists (I bet hundreds of such framework exists, just google it). So here, it is my privileges to share that piece of code, now so called phpBricks. I have uploaded demo copy, naming alpha release at SourceForge. I have been using it to build many commercial softwares. But I do not recommend you as this is alpha release and no sufficient resource will be found. If you want to use it, challenge the risk.

RBAC schemas (Entities Relationship) in phpBricks

In phpBricks on July 1st, 2009

phpBricks saves roles, resources and permissions in database which looks following (more to come later):

RBAC schemas (Entities Relationship) in phpBricks

Update: RBAC model has been changed. This one is new model.

RBAC – how do I code in phpBricks

In phpBricks on June 22nd, 2009

Last week, I wrote blog about RBAC architecture in phpBricks (http://tinyurl.com/rbac1). Today, I am going to give little snapshots about coding implementation. As you already know, RBAC is a component, but it is special provisioned component which works with core phpBricks. There is quick option which tells whether to apply RBAC or not. If you decide to apply RBAC set code in configuration like:
define('_RBAC', 1);

When RBAC is applied, an instance of RBAC is available in controller and views, but not in model classes. RBAC is not relevant in model because models are not supposed to contain any business logic. It is very much important to understand how each function is accessed to understand how RBAC determine authenticity. Each resource (or function) is identified with set of parameters, called CMA. Suppose you want to see list of users, that means calling index method of users. For that CMA parameter looks like (‘c’=>’user’, ‘m’=>’users’, ‘a’=>’index’).

In RBAC, permissions are assigned to roles not to users. Users inherit permission from their roles. So checking permission is done with combination of provided CMA parameters and roles. There is function called isPermission which takes 5 parameters. First three are CMA, fourth is primary_key (for advance business rule), and fifth is roles. Last two are optional.

For example, if you want to check that whether current loged in user has permission to see list of users or not:


if($this->Auth->isPermission('user','users','index'))
{
// code to list users
}
else
{
// sorry permission denied.
}

This works from view and controller.

Roles of user is collected at time of login and stored in session, which is available in $_SESSION['__userroles']. So if you don’t pass roles parameter, phpBricks suppose current user. Now your turn to think how do you check permission of a users who is not loged in.

———-

This blog is intended to alpha users of phpBricks. Thank you guys, you are source of energy. Thanks for suggestion, exceptions.