Skip to content

mrpapercut/base-installer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

base installer

A script to provide the bare minimum to start building a PHP/MooTools powered website. Used for small projects, where it's feasible to get cracking right away. Of course you could copy/paste files from one project to the other every time, but now you don't have to worry about leftover data polluting your files.

Requires PHP5.x and directory read/write permissions to use.

Please note: only tested on Windows. Not likely to work on Linux/Mac (as of now)

Description

This installer is meant for small projects, where you want a basic setup with convenient functions. Launch the script, test if it works and start coding with a working environment in under a minute.

It features the following functionalities:

  • A basic mysql connection with INSERT, UPDATE, DELETE and plain query functions.
  • A primitive PHP templating system
  • Ajax calls in Javascript and handling in PHP
  • html5doctor.com's CSS reset stylesheet
  • MooTools 1.4.5 (non-compressed)
  • A clear and clean folder structure

Usage

The installer uses $_SERVER['DOCUMENT_ROOT'] as its base for installations.

  1. Run the installer from your browser.
  2. Enter the location where you want to install to. Note: if you choose an existing folder, it will overwrite conflicting files.
  3. Optional: enter your database details. This will only be saved for the current process.
  4. Overview page. Click 'Install' to start.
  5. Click 'Go!' to visit your newly created project.
    • Test the Ajax call function
    • Test the database connection, if you filled in the correct details at step 3
    • 'Final preparations' removes all the test-data and presents you with a clean project

Files

The following filetree is created:

  • classes
    • Ajax.class.php
    • Db.class.php
    • Site.class.php
    • Template.class.php
  • css
    • reset.css
    • styles.css
  • inc
    • definitions.inc.php
  • js
    • Site.js
    • mootools-core-1.4.5-full-nocompat-yc.js
  • templates
    • content-default.php
    • footer.php
    • header.php
  • index.php

index.php

Calls Site.class.php and initiates page

classes/Ajax.class.php

The heart of all interaction between JS and PHP, this file handles all Ajax requests.

function getRequest()

function getRequest($request [, $data])

Returns called function

Looks for the request literally as a function, else use switch-statement

function getDefault()

function getDefault([ $data ])

Returns content-default.php template

classes/Db.class.php

Database class

function query()

function query([ $query ])

Returns error or empty set or results

function insert()

function insert($table, $data = array())

Returns error or true

$table

Table name

$data

Data to be inserted

Array(
    'column_name1' => 'value1',
    'column_name2' => 'value2'
);

function update()

function update($table, $id, $data = array())

Returns error or true

$table

Table name

$id

Row where 'id'

$data

Data to be inserted

Array(
    'column_name1' => 'value1',
    'column_name2' => 'value2'
);

function delete()

function delete($table, $id)

Returns error or true

$table

Table name

$id

Row where 'id' to delete

classes/Site.class.php

Main class

function __construct()

Initiates $_SESSION, loads inc/definitions.inc.php, assigns autoloader, initiates classes, processes Ajax-requests

function getPage()

function getPage()

Returns default page

function error()

function error($errorMsg [, $line = 'undefined', $file = 'undefined'])

Basic errors

Returns error message

$errorMsg

Error message to return

$line

Line number

$file

File

css/reset.css

Html5doctor.com reset stylesheet

css/styles.css

Empty stylesheet file

inc/definitions.inc.php

Set Database constants. If provided in the installation, this should be filled in.

js/mootools-core-1.4.5-full-nocompat-yc

MooTools core version 1.4.5, non-compressed

js/Site.js

Main MooTools javascript

function ajaxRequest()

ajaxRequest: function(request, data, success)

Returns function call return or console.log(error)

Processes Ajax-requests

request

Function to call

data

JSON object with data to transfer

success

Callback function on success

Example:
$('button').addEvent('click', function(event) {
    this.ajaxRequest('getDefault', {
        key1: 'value1',
        key2: {
            key2a: 'value2a',
            key2b: 'value2b'
        }
    },
    function(response) {
        console.log(response);
    })
});

templates/content-default.php

Example empty template file, is called on initial loading of page

templates/footer.php

Closes HTML tags

templates/header.php

Calls HTML header with HTML5 doctype, stylesheets and javascript files

MPlogo

About

Script to prepare a PHP/Mootools project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages