Bone Mvc Framework

As if there weren’t enough PHP frameworks out there, I went ahead and built one myself!

Announcing Bone MVC Framework, a bare bones MVC framework in a distinctly piratey flavour.

It be the mightiest bare bones framework it th’ seven seas!

Install it using Composer by typing into your terminal:

php composer.phar create-project delboy1978uk/bonemvc your/path/here dev-master

If you don’t have Composer type this in to download it first:

php -r "readfile('');" | php

Change the permissions for the data folder:

chmod -R 775 data

In config/config.php, you can set any default settings (anything at all) in here, and it will be available in the Registry (which a future version will be replaced by a dependency injection container), but there are some settings Bone uses such as routes and db connection for the PDO connection. Check the link above for more details.

Bone MVC Framework uses Twig for it’s view, but eventually we will be able to swap that out for any view library of our choice! Layouts can be found in the /App/View/layouts folder. The index and error folders correspond to the index and error controllers.

In the controllers, you have actions, and from within these you can call whatever the hell you like! Just remember the use statements for any classes you want to use. Bone comes with a few controller methods:

public function nonstopAction() 
    $this->getRequest(); // the Request object 
    $this->getParam('param'); // gets a single uri param 
    $this->getParams(); // gets an array of all the params 
    $this->getDbAdapter(); // a PDO connection t' yer Db 
    $this->getHeaders(); // returns a headers object for header manipulation
    $this->hasLayoutEnabled(); // boolean 
    $this->disableLayout(); // turns the layout off 
    $this->hasViewEnabled(); // boolean 
    $this->disableView(); // turns twig off 
    $this->getTwig(); // gets yer Twig object 
    $this->getBody(); // response body (when view disabled) 
    $this->setBody($body); // sets th' response body (when view disabled) 

Have a play with it! Fork it on GitHub! If you have any comments for improvements or any issues, again leave them on GitHub!

I’ll be making some more posts soon, talking about Unit, Functional, and Acceptance tests using Codeception, and Continuous Integration using Travis! Stay tuned!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s