vutran/wpmvc-core

v0.1.3 2016-06-15 13:33 UTC

This package is not auto-updated.

Last update: 2024-12-21 19:58:11 UTC


README

Simple framework for building WordPress themes/apps

Quick Start

See below for a quick usage example. All files are relative to your theme directory.

functions.php

<?php

// Instantiate the framework
$app = new \WPMVC\Common\Bootstrap(array(
    'templatePath' => TEMPLATEPATH,
    'templateDir' => str_replace(WP_CONTENT_DIR, '', WP_CONTENT_URL . TEMPLATEPATH),
    'templateUrl' => get_template_directory_uri()
));

// Create a view
$myView = $app->createView('slug-a/slug-b');

// set view variables
$myView->set([
  'foo' => 'Hello',
  'bar' => 'World',
]);

// prints the view
echo $myView->output();

views/slug-a/slug-b.php

<?php

echo $foo . ' ' . $bar;

// outputs "Hello World";

Filters

Actions

Docker

Install

$ docker-compose up install

Update Composer and Packages

$ docker-compose up update

PHP Code Sniffer

$ docker-compose up phpcs

Validate PHP

# --rm          automatically remove the container on exit
# -v            map volume host volume to container (host:container)
# php:5.6       image name:tag
# php           command to run in container
# script.php    PHP script to run
$ docker run --rm -v "$PWD":/app -w /app php:5.6 php /path/to/script.php