Application template
====================

A template (boilerplate) allows to create an application in quickly way using the least amount of development.

It consists of a library and its sample implementation - billing system and main application.

Structure
*********

The template allows to use simplified MVC pattern in order to separate particular application components.

Creating a new action step-by-step:

- To create new controller, create the class in ``src/Controller/`` (i.e. ``src/Controller/Books.php``), that inherits from ``ControllerAbstract``, and is defined in ``Controller`` namespace
- Create ``myAction`` method
- Create a view in directory ``view`` according to the schema: ``controller-name/action-name.php`` (i.e. ``controller/my.php``)
- In order to pass a variable to the view, use following expression ``$this['variable'] = 'value';`` in action code. Then, this variable will be accessible like a regular variable within the view.

How to start
************

- `Download the boilerplate <https://github.com/dreamcommerce/app-template>`_
- `Install SDK`_
- `Configure`_

Install SDK
***********

If you're using Composer to manage your packages and SDK, inside the project directory call ``composer install``.

Alternatively, it's possible to manually install SDK. Just extract its contents into project directory.

Configure
*********

In file ``src/Config.php``:


.. code-block:: php

    return array(
        /*
         * Application ID generated by AppStore
         */
        'appId' => '',

        /*
         * Secret generated by AppStore
         */
        'appSecret' => '',

        /*
         * AppStore Secret generated by AppStore
         */
        'appstoreSecret' => '',


        'db' => array(
            /*
             * PDO DSN
             */
            'connection' => 'mysql:host=127.0.0.1;dbname=app',

            /*
             * PDO Database username
             */
            'user' => '',

            /*
             * PDO Database password
             */
            'pass' => ''
        ),

        /*
         * Enable debug mode or not
         */
        'debug' => false,

        /*
         * Path to log file or empty to disable logging
         */
        'logFile' => "logs/application.log",


        /*
         * timezone of the application
         *
         * Value is passed to date_default_timezone_set function
         */
        'timezone' => 'Europe/Warsaw',

        'php' => array(
            /*
             * This determines whether errors should be printed to the screen as
             * part of the output or if they should be hidden from the user
             *
             * Value is passed to ini_set function
             */
            'display_errors' => 'off'
        )
    );


