Documentation

Main configuration

Main configuration file is anjy_config.json.

PublicPath

Folder for public files such as index.html, style.css, script.js etc.

SessionPath

Folder for private session files. Those files are similar to PHP session files. In ANJY session files also not encoded so you should specify private directory for them

RoutePath

Folder for your routes. We are also recommend you to hide this folder from public access

Port

Port that will be used for server. By default port is 8080 but you can use port 80.

SessionName

Name for session that you can see in browser's cookie. For example: in PHP you can see name PHPSESSID

SessionLifeTime

Time in seconds. When the time is up session file will be destroyed

Secret

Password for system functions that can be executed from browser. For example: http://127.0.0.1:8080/anjy_reload?secret=my_secret

File404

File that will be returned with 404 response. Remember! File must be in PublicPath

DB

driver

Driver for connection. Available drivers: mysql5.6, mysql5.5, mysql5.1, mysql5.0, postgre, mssql

host

Database host. For example: if you database in the same server you can use 127.0.0.1

database

Database name

charset

Character set for connection. By default utf8

user

Database user

password

Database password

Routes

Route is a file with instructions for each request for ANJY. Routes must be placed in RoutePath. It also has JSON structure.

url

REQUEST_URI string. For example: /catalog. Also you can use variables in request like /catalog/:id. To use variable from request in SQL statement you must prepend _request_ to your variable in field list. For example: SELECT * FROM category WHERE parent_id = :_request_parent_id

get

post

head

options

put

patch

delete

Request method that work on this url

[method name] > enabled

true | false

[method name] > execute

"read" | "write". Instructions for database. If you are using SELECT - type "read". For else methods such as INSERT | UPDATE ... use "write"

[method name] > sql

SQL request string. For variables use ":" before variable name. For example: INSERT INTO category (name, parent_id, enabled) VALUES (:name, :parent_id, :enabled)

[method name] > fields

Array of input data fields. For example if you have $_POST['parent_id'] you should type "parent_id" in "name" property. Also you can specify type of this variable for better performance. To do this use "escape" parameter

session_conditions

Array of conditions to perform operation in this request.

session_conditions > fields

variable name in Session

session_conditions > s_operator

< | > | = | !=

session_conditions > value

value that will be compared

action

Object for result action
action > return

"json" | "html"

action > session_set

"RESULT_FIRST_ROW" Or you can skip this property.

action > not_found_on_empty

true | false. Or you can skip this property.

action > session_set

string for template that will be rendered if return is html. Remember! This file must be in PublicPath For example: "partials/menu.html"

HTML templates

Template for rendering result from database is very simple. There is only one directive to render array of data. It is tag [repeat]. Inside this tag you can show items accessed by their names. For example:

Remember! You can use only one declaration in template file of [repeat] section.