Learn Bone MVC Framework

All our crew be trained by the Melee Island Swordmaster!

Installation

Ahoy matey! First ye be needin' Composer! Then install Bone.

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

or if ye haven't installed composer globally ...

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

Docker Dev Box

Bone comes wit' a docker-compose.yml in th' project, so ye can instantly get a dev server runnin' if ye use Docker (Tested usin' a default VirtualBox VM). Jus' add this t' yer hosts file
awesome.scot 192.168.99.100

docker-machine start eval $(docker-machine env) cd /path/to/project docker-compose up

Then ye can access th' site at https://awesome.scot in yer browser. O' course if ye don't use docker ye can add it t' yer LAMP stack in th' usual way.

Cap'n's Logs

Ye can see ye have a config, data, public, and src folder. Dinnae be touchin' th' vendor folder or th' Cap'n will make ye walk the plank!

Make th' data folder writable. 777 be lettin' every landlubber have write access, so if ye can we prefer 775 with yer Apache user in th' group.

chmod -R 775 data

In yer apache virtual hosts, set the document root as th' public folder

<VirtualHost *:80> DocumentRoot "/var/www/bonemvc/public" ServerName awesome.scot SetEnv APPLICATION_ENV development <Directory "/var/www/bonemvc"> DirectoryIndex index.php FallbackResource /index.php Options -Indexes +FollowSymLinks AllowOverride all Require all granted </Directory> </VirtualHost>

Th' config folder

Ye can drop in any number o' .php files into th' config/ folder. Make sure they return an array wit' th' config . Ye can o'erride configuration based on environment var APPLICATION_ENV, so fer instance if th' environment was productionit would load th' additional config th' production subdirectory.

Thar are several config files by default:

db.php i18n.php logs.php mail.php routes.php templates.php

In yer config files, ye can add anythin' ye wants. It gets stored in th' Bone\Mvc\Registry.


Database

Set yer default db credentials in th' main config/db.php, 'n any environment specific configs in a subdirectory

'db' => array( 'host' => '127.0.0.1', 'database' => 'bone', 'user' => 'LeChuck', 'pass' => 'monkeyIsland' ),

Lingo

Bone supports translation into different locales. Translation files (gettext .po 'n .mo) best be placed in data/translations, under a subdirectory o' th' locale, eg data/translations/en_GB/en_GB.po. Ye can set th' default locale 'n an array o' supported locales.

<?php return [ 'i18n' => [ 'translations_dir' => 'data/translations', 'type' => \Zend\I18n\Translator\Loader\Gettext::class, 'default_locale' => 'en_PI', 'supported_locales' => ['en_PI', 'en_GB', 'nl_BE', 'fr_BE'], ] ];

T' use th' translator, ye can simply call:To use the translator, you can simply call:

// from a controller: $this->getTranslator()->translate('placeholder.string'); // to set locale $this->getTranslator()->setLocale($locale); // from a view file: $this->t('placeholder');

Cap'n's Logs

Bone uses monolog/monolog, 'n logs can be found in data/logs. Currently we only support writin' t' files, but ye can add as many channels as ye like:

<?php return [ 'log' => [ 'channels' => [ 'default' => 'data/logs/default_log', ], ], ];

T' use th' logger in a controller:

$this->getLog()->debug($message) // or error(), etc, see PSR-3

Messages in bottles

Bone uses Zend Mail. T' configure th' mail client, jus' drop in yer config (see zend mail docs)

<?php return [ 'mail' => [ 'name' => '127.0.0.1', 'host' => 'localhost', 'port' => 25, // 'connection_class' => 'login', // plain, login, crammd5 // 'connection_config' => [ // 'username' => 'user', // 'password' => 'pass', // ], ], ];

If ye be usin' th' Docker Box provided by bone, ye also 'ave th' awesome MailHog at yer disposal. Browse t' awesome.scot:8025 'n ye'll see a catch all email inbox, so ye ne'er needs t' worry about development emails reachin' th' real world.


Voyages

Routes follow a default pattern o' /controller/action/param/value/nextparam/nextvalue/etc/etc
Ye can also o'erride routes by definin' them in th' config array:

<?php return [ 'routes' => [ '/' => [ 'controller' => 'index', 'action' => 'index', 'params' => [], ], '/:locale' => [ 'controller' => 'index', 'action' => 'index', 'params' => [], ], '/optional[/:id]' => [ 'controller' => 'index', 'action' => 'index', 'params' => [], ], ], ];

When definin' routes, mandatory variables in th' uri 'ave a colon like :id
Optional uri vars 'ave [ ] surroundin' them like [:id]


Layouts

Ignore this config. 'tis ole deprecated nonsense.