What's this?
- Clone the repo
- On terminal:
cd
toSymphony/source
- On terminal:
php -S localhost:8080 -c php.ini
(php.ini for enabling yaml extension) - Start creating pages in
Symphony/source/pages
folder
- All of the Classes are under namespace called: Symphony
- Reserved function name: onGET
- Function
onGET(): string
will be called when request method is GET
- Reserved function name: onPOST
- Function
onPOST(): string
will be called when request method is POST
<?php
// Symphony/source/pages/home.php
// Setting title
Symphony\HTML::setTitle("Home");
// Adding JavaScript
Symphony\HTML::addJavaScript("main");
function onGET(){
return "GET";
}
function onPOST(){
return "POST";
}
?>
File location: Symphony/source/php/core.php
Methods / APIs:
- DevMode
- By default disabled
- Enabling:
Core::enableDevMode(): void
- Note! Call this method before starting the
Core
and inindex.php
to avoid unknown bugs
File location: Symphony/source/index.php
<?php
require_once 'php/core.php';
// Enabling Dev Mode
// To Enable DevMode Uncomment The Line Below
// Symphony\Core::enableDevMode();
// Setting JSON As Default Configurations File
// Symphony\Configurations::useJSON();
// Starting Symphony
Symphony\Core::start();
?>
By default class uses YAML
file to keep configurations
File location: Symphony/source/yaml/configurations.yaml
But you can use JSON
as configurations file by calling Configurations::useJSON(): void
NOTE! Call this method in Symphony/source/index.php
before starting Core
File location: Symphony/source/json/configurations.json
You can modify followings:
- Paths
- css
- js
- pages
- Database credentials (MySQL)
- name
- user
- password
- host
- port
- charset
- collate
- Detailed URL Structure
- prefix
- sub_domain
- domain_name
- domain_extension
- port
- HTML defaults
- lang
- charset
- title
The data above can be accessed using Configurations
class.
Included in: Symphony/source/php/core.php
<?php
// Returns title defined in configurations.yaml under HTML
Configurations::HTML()["title"];
?>
Config
and Conf
are alias to Configurations
There are 4 getters. All of them return key value paired arrays:
- Paths:
Configurations::path(): array
- Database:
Configurations::database(): array
- URL:
Configurations::URL(): array
- HTML:
Configurations::HTML(): array
- Raw:
Configurations::raw(): array
Class for working with databases
File location: Symphony/source/php/database.php
Methods / APIs:
Database::execute(arg1, arg2): bool
- arg1 is query to execute
- arg2 (optional) is array of placeholders for prepared statement
- On success returns true, On error returns false
Database::fetchAll(): array
- Fetches all data
- Returns key value paired array
Database::fetchOne(): array
- Fetches one data
- Returns key value paired array
Database::rowCount(): int
- Returns row count
Database::lastID(): int
- Returns Last Inserted Id
<?php
Database::execute("SELECT * FROM table WHERE id=?", [1]); // Returns true or false depending result
Database::fetchAll(); // Returns data for query executed above
Database::rowCount(); // Row count for query executed above
?>
Class for working with html structure of the page
File location: Symphony/source/php/HTML.php
Methods / APIs:
HTML::setTitle(string:): void
- Sets title of the current page
- Accepts one argument (string)
HTML::addJavaScript(string:): void
- Adds JavaScript to
html > head
- You need to pass only name of the script to be added
- Note! without extension
(.js)
- Note! without path
- JavaScript path will be brought using
Conf::path()["js"]