Welcome to TinyMVC, the tiny PHP Framework.

Installation

Contents

Installing TinyMVC

Requirements: TinyMVC 2.0 requires PHP 5.4 or later, and is tested on PHP 5.6 through 8.5. The database layer requires the PDO extension and the PDO driver for your database (such as pdo_mysql or pdo_sqlite).

Quick "I just want to see it" Install

You should see the welcome screen.

Single Installation (Typical)

This basically means a single website. If you are installing multiple websites and want the TinyMVC core codebase to be shared between them, then skip down to the Shared installation.

Unpack the distribution archive in a temporary place. You will see the following structure:

/htdocs/
  index.php

/tinymvc/
  /myapp/
  /myfiles/
  /sysfiles/

The index.php file is the file directly accessed by the web browser. No other files are required inside the doc root.

The /tinymvc/ directory holds all of the system files and application files. It is recommended (but not required) to place this directory somewhere outside of your web server document root.

If you decide to place this in your doc root, be sure to restrict browser access to /tinymvc/ with your web server configuration.

Example install:

/var/www.foo.com/htdocs/
  index.php

/var/www.foo.com/tinymvc/
  /myapp/
  /myfiles/
  /sysfiles/

Inside the index.php file, you will find the following:

/* PHP error reporting level, if different from default */
error_reporting(E_ALL);
 
/* if the /tinymvc/ dir is not up one directory, uncomment and set here */
//define('TMVC_BASEDIR','../tinymvc/');
 
/* if the /myapp/ dir is not inside the /tinymvc/ dir, uncomment and set here */
//define('TMVC_MYAPPDIR','/path/to/myapp/');
 
/* define to 0 if you want errors/exceptions handled externally */
define('TMVC_ERROR_HANDLING',1);

Set the PHP error reporting level. E_ALL is a good choice for development. On a production site you may prefer to remove the line and use your php.ini setting.

If necessary, uncomment and set the TMVC_BASEDIR path, which is the path to where you installed the /tinymvc/ directory. If this is located one directory up from the index.php file, the default setting should work.

TMVC_ERROR_HANDLING turns on the TinyMVC error and exception handler. See Custom Error Handler.

Be sure to include a trailing slash.

Once you are finished, take your browser to http://localhost/index.php (or wherever the index.php file is on your web server). You should see a welcome screen. If not, check the error messages, and check your data paths and configuration settings again.

Database Settings

If you are using a database, be sure you edit your database settings here:

/tinymvc/
  /myapp/
    /configs/
      config_database.php

config_database.php:

$config['default']['plugin'] = 'TinyMVC_PDO'; // plugin for db access
$config['default']['type'] = 'mysql';      // connection type
$config['default']['host'] = 'localhost';  // db hostname
$config['default']['name'] = 'dbname';     // db name
$config['default']['user'] = 'dbuser';     // db username
$config['default']['pass'] = 'dbpass';     // db password
$config['default']['persistent'] = false;  // db connection persistence?

You can have multiple database connection settings. "default" is the name of the default connection. To make new settings, copy all seven lines and make a new setting name.

Leave the plugin setting as TinyMVC_PDO, unless you are using your own custom database library. Set the type, host, name, user, pass and persistent settings according to your database server.

Shared Installation

Each website has it's own index.php file and /myapp/ directory associated with it. The websites can share the main TinyMVC code base. This way TinyMVC upgrades are done in one place.

The /sysfiles/ directory is what you update when you upgrade TinyMVC, it should never be touched. The /myfiles/ directory is where you can place custom plugins that you want shared across websites.

For each website, you will install a separate index.php file and /myapp/ directory.

Example setup for three different websites:

# shared code
/usr/local/lib/tinymvc/
  /myfiles/
  /sysfiles/

#website 1
/var/www.foo1.com/htdocs/index.php
/var/www.foo1.com/myapp/

#website 2
/var/www.foo2.com/htdocs/index.php
/var/www.foo2.com/myapp/

#website 3
/var/www.foo3.com/htdocs/index.php
/var/www.foo3.com/myapp/


For each website, edit the index.php file and set the path to TMVC_BASEDIR and TMVC_MYAPPDIR. Example:

index.php:

/* TinyMVC base library path */
define('TMVC_BASEDIR','/usr/local/lib/tinymvc/');
 
/* application library path */
define('TMVC_MYAPPDIR','../myapp/');

Be sure to include a trailing slash.

Upgrading from 1.x

Replace the /tinymvc/sysfiles/ directory with the one from the new version. Your /myapp/ and /myfiles/ directories are not touched. Then check the following:

TinyMVC is licensed under the GNU LGPL license.
This page was rendered in 0.00031 seconds.