> composer require viewi/viewi:dev-master
To create a default viewi application automatically run command:
> vendor/bin/viewi new [folder]
Where folder is an optional parameter and can be omitted. For example:
> vendor/bin/viewi newor
> vendor/bin/viewi new myViewiAppor
> vendor/bin/viewi new src/ViewiApp
It will generate for you the default code for using Viewi as a standalone application in one of these files: /index.php or /public/index.php.
If you specified folder parameter, your components will be located in that folder, otherwise it will use one of these: viewi-app/ or src/ViewiApp/.
To create a new app manually follow the next steps
In your /public/index.php put this if it's not there already:
require __DIR__ . '/../vendor/autoload.php';
Config file viewi-app/config.php:
<?php use Viewi\PageEngine; const VIEWI_COMPONENTS = __DIR__ . '/Components'; const PUBLIC_FOLDER = __DIR__ . '/../public/'; return [ PageEngine::SOURCE_DIR => VIEWI_COMPONENTS, PageEngine::SERVER_BUILD_DIR => __DIR__ . '/build', PageEngine::PUBLIC_ROOT_DIR => PUBLIC_FOLDER, PageEngine::DEV_MODE => true, PageEngine::RETURN_OUTPUT => true, PageEngine::COMBINE_JS => true ];
Routes file viewi-app/routes.php:
<?php use Viewi\Routing\Route as ViewiRoute; // routes here
Viewi boot file viewi-app/viewi.php:
<?php use Viewi\App; $config = require 'config.php'; include __DIR__ . '/routes.php'; App::init($config);
In your /public/index.php put these:
include __DIR__ . '/../viewi-app/viewi.php'; Viewi\App::handle();