attogram/attogram-framework

This package is abandoned and no longer maintained. No replacement package was suggested.

The Attogram Framework provides developers a PHP skeleton starter site with a content module system, file-based URL routing, IP-protected backend, Markdown parser, jQuery and Bootstrap. Core modules available to add an integrated SQLite database with web admin, user system, and more.

v0.8.2 2016-07-24 09:43 UTC

README

[//]: # ( Attogram Framework - README.md (markdown) - v0.1.19 )

Build Status Latest Stable Version Latest Unstable Version Total Downloads License Code Climate Issue Count Codacy Badge [CHANGELOG] [TODO]

The Attogram Framework provides developers a PHP skeleton starter site with a content module system, file-based URL routing, IP-protected backend, Markdown parser, jQuery and Bootstrap.

Core modules available to add a SQLite database with web admin, user system, and more.

After that, Attogram tries to stay out of your way while you do your thing!

More Info

Requirements

  • PHP 5.3.3 or higher, or PHP7
  • PHP installed with SQLite PDO driver
  • Apache 2.2.16 or higher, with setting: AllowOveride all

Setup: Install

  • Get Attogram:

  • Setup your web server to use the ./public/ directory as the web site root.

  • edit ./public/.htaccess, set FallbackResource, ErrorDocument 403 and ErrorDocument 404 to the full web path to the index.php file in the install directory.

  • (optional) copy ./public/config.sample.php to ./public/config.php and edit to change default settings .

Setup: Admin

  • admin pages are IP protected
  • change the allowed admin IPs by setting $config['admins'] in ./public/config.php
  • default admin IPs is localhost in ip4 and ip6: array( '127.0.0.1', '::1' )
  • admin page requests from non-admin IPs will result in a 404 Page Not Found error

Attogram now has modules! Updated docs coming soon

OLD DOCS

Setup: Database

  • Install the Attogram Database Module
  • Make sure the database file ./db/global is writeable by the web server
  • Tables are lazily created when needed.
  • To create all tables at once, goto the db-tables admin page and click Create Attogram Tables
  • phpLiteAdmin is available for database administration, goto the db-admin admin page, default password is attogram

Setup: Users

  • load the homepage, goto admin action users, click Create New User
  • enter username, password, etc. and click Insert
  • load the homepage, click login, login as the new user

Attogram Modules

  • Easily create modules to extend Attogram!
  • Each module lives in its own subdirectory within the Attogram ./modules/ directory.

Module Structure

  • Modules may have the following subdirectories:

    • actions/ - The Public Actions (.php or .md markdown files) If present, the home action is used as the home page.
    • admin_actions/ - The backend admin-only Actions (.php or .md markdown files)
    • configs/- Configurations via namespace Attogram; global $config; $config['configname'] = ..., loaded at startup (.php files only)
    • includes/ - Included files, loaded at startup (.php files only)
    • tables/ - Database table definitions. Tables are created lazily as needed (.sql files only)
    • templates/ - Templates, to override default Attogram templates (.php files only)
    • public/ - Files for public consumption. Served via requests to the web/ virtual web directory
  • Modules are loaded in directory list order.

    • Actions and files cascade: a duplicate action name or file will overwrite any previous modules action or file of the same name.

Core Modules

Create a page

  • create a new PHP or Markdown file in the ./actions/ directory, add anything you want!
  • The filename is used as the page URL. ./actions/example.php = example.com/example/

PHP pages

  • PHP filenames must end in .php

  • The Attogram object is available via the $this variable

  • Helpful functions:

    • $this->pageHeader($title)
    • $this->pageFooter()
    • $this->log->debug(), ->error(), etc.
    • $this->getSiteUrl()
    • $this->error404($error_message)
    • $this->isAdmin()
    • $this->isLoggedIn()
  • Depth settings in ./public/config.php

    • $config['depth']['insert-action-name-here']
  • End Slash settings in ./public/config.php

    • $config['noEndSlash'][] = 'insert-action-name-here'

Markdown pages

  • Markdown filenames must end in .md
  • The first line of the Markdown file is used as the page title

Remove a page

  • delete the pages corresponding file from the ./actions/ directory

Admin pages

  • create/delete the same as normal pages, but in the ./admin_actions/ directory

Database tables

  • To add a table, add a file into ./tables/ directory
  • The filename must be the name of the table
  • File content is the sql CREATE TABLE ... statement
  • tables are automatically created upon first use

Web discovery

  • If ./robots.txt does not exist, Attogram dynamically serves it, with a link to the Sitemap
  • If ./sitemap.xml does not exist, Attogram dynamically serves it, with a listing of all public pages

Admin URL overrides

  • admins may use URL/?noadmin on any page to turn off admin access
  • admins may use URL/?debug on any page to turn on debugging