Skip to content

Symphony is a collection of tools for speeding-up website building processes using PHP

License

Notifications You must be signed in to change notification settings

woXrooX/Symphony

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

Symphony

What's this?

Symphony is a collection of tools for speeding-up website building processes using PHP

Quick Start

  1. Clone the repo
  2. On terminal: cd to Symphony/source
  3. On terminal: php -S localhost:8080 -c php.ini (php.ini for enabling yaml extension)
  4. Start creating pages in Symphony/source/pages folder

Creating A Simple Page

  1. All of the Classes are under namespace called: Symphony
  2. Reserved function name: onGET
  • Function onGET(): string will be called when request method is GET
  1. 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";
}

?>

Core Class

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 in index.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();

?>

Configurations Class

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:

  1. Paths
  • css
  • js
  • pages
  1. Database credentials (MySQL)
  • name
  • user
  • password
  • host
  • port
  • charset
  • collate
  1. Detailed URL Structure
  • prefix
  • sub_domain
  • domain_name
  • domain_extension
  • port
  1. 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:

  1. Paths: Configurations::path(): array
  2. Database: Configurations::database(): array
  3. URL: Configurations::URL(): array
  4. HTML: Configurations::HTML(): array
  5. Raw: Configurations::raw(): array

Database Class

Class for working with databases
File location: Symphony/source/php/database.php
Methods / APIs:

  1. 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
  1. Database::fetchAll(): array
  • Fetches all data
  • Returns key value paired array
  1. Database::fetchOne(): array
  • Fetches one data
  • Returns key value paired array
  1. Database::rowCount(): int
  • Returns row count
  1. 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
?>

HTML Class

Class for working with html structure of the page
File location: Symphony/source/php/HTML.php
Methods / APIs:

  1. HTML::setTitle(string:): void
  • Sets title of the current page
  • Accepts one argument (string)
  1. 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"]

About

Symphony is a collection of tools for speeding-up website building processes using PHP

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages