VELOX - The fastest way to build simple websites using PHP!

Overview

VELOX


VELOX

The fastest way to build simple websites using PHP!

PHP Version Latest Version on Packagist License Maintenance Total Downloads Scrutinizer Build Status Scrutinizer Code Quality StyleCI Code Style

Table of Contents

Installation
About VELOX
Architecture
Config
Classes
Functions
Themes
Changelog

Tweet


Key Features

  1. Zero dependencies
  2. Intuitive and easy to get along with
  3. Unlimited flexibility when it comes to customizing it to your exact needs

Installation

Using Composer:

composer create-project marwanalsoltany/velox my-velox-app

#ff6347 Note: You may need to add the --stability=dev depending on the version/branch.

Using Git:

git clone https://github.com/MarwanAlsoltany/velox.git my-velox-app

#1e90ff Fact: If you don't want to use any other third party packages. Installing VELOX using Git is sufficient.

Using source:

Download VELOX as a .zip or .tar.gz and extract it in your server web root directory.


About VELOX

VELOX is a lightweight micro-framework that makes creating a simple website using PHP joyful. It helps you create future-proof websites faster and more efficiently. It provides components that facilitate the process of creating a website using vanilla PHP. VELOX does not have any dependencies, the VELOX package and everything that it needs is included in the project itself. All that VELOX provides is a way to work with config, pass data, register routes, render views, handle exceptions, autoload code, and resolve assets. It provides the View and the Controller parts of an MVC design pattern, leaving the Model part for you to implement as you wish, or use any 3rd-Party Package; in case you needed it. VELOX can also be used as a Static Site Generator if all you need is HTML files in the end.

Why does VELOX exist?

VELOX was created to solve a specific problem, it's a way to build a website that is between dynamic and static, a way to create a simple website with few pages without being forced to use a framework or a CMS that comes with a ton of stuff which will never get used, it's lightweight and straight to the point.

It's not recommended to use VELOX if you have an intermediary project, you would be better off using some well-established frameworks. VELOX is not an initiative to reinvent the wheel, you can look at VELOX as a starter-kit for small projects.

VELOX has a very special use-case, simple websites, and here is meant really simple websites. The advantage is, you don't have stuff that you don't need. Comparing VELOX to Laravel or Symfony is irrelevant, as these frameworks play in a totally different area, it also worth mentioning that VELOX is much simpler than Lumen or Slim.


Architecture

Directory structure

Directory Description
bootstrap This is where VELOX bootstraps the application. You normally don't have to change anything in this directory, unless you want to extend VELOX functionality beyond basic stuff.
config This is where all config files will live. All files here will be accessible using the Config class at runtime.
storage This is where VELOX will write caches and logs. You can also use this directory to store installation-wide assets.
classes This is where VELOX source files live. You shouldn't be touching anything here unless you want to make your own version of VELOX.
functions This is where all functions that are loaded in the application live. You can freely add yours, or delete the entire directory.
themes This is where all your frontend themes will be placed. You will be mostly working here for the frontend part of your app.
app This is where your own backend logic will be placed. You will be mostly working here for the backend part of your app.
bin This is where PHP executables are placed. You can freely add yours, or delete the entire directory.
public This is where you should put your index.php for maximum security. You can freely delete this directory if you want to.
vendor This is where your Composer dependencies will be placed. You can freely delete this directory if you don't want to use Composer.

#32cd32 Advice: Most files listed in these directories are documented. Take a look through them to learn more about VELOX.

App Entry

The entry point for a VELOX app is the index.php, here you need to require the bootstrap/autoload.php, register some routes with their handlers using the Router::class, and start the router. This is all that you need to have a working VELOX app.



require 'bootstrap/autoload.php';

Router::handle('/', function () {
    return View::render('home', ['title' => 'Home']);
});

Router::start();

Additionally, you can also set up handlers for 404 and 405 responses using Router::handleRouteNotFound() Router::handleMethodNotAllowed() respectively.

Alternatively, you can extract the "routes registration part" in its own file and let VELOX know about it using bootstrap/additional.php.

#ff6347 Note: In order for VELOX to work correctly and safely, you need to redirect all requests to application entry point (index.php) and block all requests to other PHP files on the server (take a look at .htaccess.dist to get started with Apache).


Config

The following table lists all config files that come shipped with VELOX.

Config File Description
global.php This config file contains some global variables that are used by almost all classes (app-wide config).
router.php This config file can be used to override Router::class default parameters.
theme.php This config file can be used to edit/extend theme configuration.
view.php This config file can be used to customize everything about the views. It is used by the View::class.
data.php This config file can be used to provide any arbitrary data, which then will get injected in the Data::class.

#1e90ff Fact: You can freely add your own config files too, all you need to do is to create a new file under /config and add you own configuration to it. VELOX will know about this file and load it in the application. You can access your config via Config::get('filename.whatEverKeyYouWrote').


Classes

The following table lists all available classes with their description.

VELOX classes are divided in four namespaces:

Class Description
Config A class that loads everything from the /config directory and make it as an array that is accessible via dot-notation.
Router A class that serves as a router and an entry point for the application.
Globals A class that serves as an abstraction/wrapper to work with superglobals.
Controller An abstract class that serves as a base Controller that can be extended to make handlers for the router.
Data A class that serves as an abstracted data bag/store that is accessible via dot-notation.
View A class that renders and caches view files (Layouts, Pages, and Partials) with the ability to include additional files and divide page content into sections.
HTML A class that serves as a fluent interface to write HTML in PHP. It also helps with creating HTML elements on the fly.
Path A class that serves as a path resolver for different paths/URLs of the app.
Dumper A class that dumps variables and exception in a nice formatting.
Misc A class that serves as a holder for various miscellaneous utility function.
App A class that serves as a basic service-container for VELOX.

#ff6347 Note: This all what the VELOX package provides out of the box.

#1e90ff Fact: The App, Config, Router, Globals, Data, View, HTML, Path classes are aliased on the root namespace for ease-of-use.

Extending VELOX

To add you own classes use the app/ directory, this is where you should put you own business logic. Note that you have to follow PSR-4 in order for VELOX to load you classes. See app/Controller/DefaultController, to get an idea.


Functions

The following table lists all available functions and to which class/group they belong.

VELOX functions are divided into these files:

  • helpers.php: This is where helper functions for VELOX classes live, these are mainly functions that return an instance of class or alias some method on it.
  • html.php: This is where HTML helper functions live, these are nothing other than aliases for the most used PHP functions with HTML.
Class/Group Function(s)
App::class app()
Config::class config()
Router::class router(),
handle(), redirect(), forward()
Globals::class globals()
View::class view(),
render(), render_layout(), render_page(), render_partial(),
section_push(), section_reset(), section_start(), section_end(), section_yield(),
include_file()
Data::class data(),
data_has(), data_get(), data_set()
HTML::class html()
Path::class path(),
app_path_current(), app_url_current(),
app_path(), app_url(),
theme_path(), theme_url(),
assets_path(), assets_url()
Dumper::class dd(), dump(), dump_exception()
HTML Helpers he(), hd(), hse(), hsd(), st(), nb()

#1e90ff Fact: You can freely add your functions too, all you need to do is to create a new file under functions/ and add you own functions to it. VELOX will know about this file and load it in the application.


Themes

VELOX is built around the idea of themes, a theme is divided into four directories:

  • The assets/ directory is where all your static assets associated with this theme will find their place.
  • The layouts/ directory is where you define your layouts. A layout in VELOX terminology is the outer framing of a webpage.
  • The pages/ directory is where you put the content specific to every page, the page will then be wrapped with some layout of your choice and finally rendered. A page in VELOX terminology is the actual content of a webpage.
  • The partials/ directory is where you put all your reusable pieces of the theme, which then will be used in your layouts or pages. A good example for partials could be: Components, Includes, and Content-Elements.

You can customize the behavior of themes using the config/theme.php file. Here you can set the active theme with the active key. Themes can inherit from each other by setting parent(s) with the parent key. You can also change the theme directory structure if you wish to using the paths key. Other configurations that worth taking a look at which have to do with themes can be found in the config/view.php file.

#32cd32 Advice: You can take a look at the provided velox theme to see how all stuff work together in practice.

Examples:

  1. Layout: themes/velox/layouts/main.phtml
  2. Page: themes/velox/pages/home.phtml
  3. Partial: themes/velox/partials/text-image.phtml

License

VELOX is an open-source project licensed under the MIT license.
Copyright (c) 2021 Marwan Al-Soltany. All rights reserved.

You might also like...
REST-like PHP micro-framework.

Phprest Description REST-like PHP micro-framework. It's based on the Proton (StackPhp compatible) micro-framework. Phprest gives you only the very bas

MOP is a php query handling and manipulation library providing easy and reliable way to manipulate query and get result in a fastest way
MOP is a php query handling and manipulation library providing easy and reliable way to manipulate query and get result in a fastest way

Mysql Optimizer mysql optimizer also known as MOP is a php query handling and manipulation library providing easy and reliable way to manipulate query

MOP is a php query handling and manipulation library providing easy and reliable way to manipulate query and get result in a fastest way. ( WEBSITE VERSION )
MOP is a php query handling and manipulation library providing easy and reliable way to manipulate query and get result in a fastest way. ( WEBSITE VERSION )

Mysql Optimizer mysql optimizer also known as MOP is a php query handling and manipulation library providing easy and reliable way to manipulate query

The fastest way to make a powerful JSON:API compatible Rest API with Laravel.
The fastest way to make a powerful JSON:API compatible Rest API with Laravel.

The first fully customizable Laravel JSON:API builder. "CRUD" and protect your resources with 0 (zero) extra line of code. Installation You can instal

The fastest way to make a powerful JSON:API compatible Rest API with Laravel.
The fastest way to make a powerful JSON:API compatible Rest API with Laravel.

The first fully customizable Laravel JSON:API builder. "CRUD" and protect your resources with 0 (zero) extra line of code. Installation You can instal

Validate your input data in a simple way, an easy way and right way. no framework required. For simple or large. project.

wepesi_validation this module will help to do your own input validation from http request POST or GET. INTEGRATION The integration is the simple thing

The fastest pure PHP database framework with a powerful static code generator, supports horizontal scale up, designed for PHP7
The fastest pure PHP database framework with a powerful static code generator, supports horizontal scale up, designed for PHP7

Maghead 4.0.x IS CURRENTLY UNDER HEAVY DEVELOPMENT, API IS NOT STABLE Maghead is an open-source Object-Relational Mapping (ORM) designed for PHP7. Mag

Drupal is an open source content management platform supporting a variety of websites ranging from personal weblogs to large community-driven websites.
Drupal is an open source content management platform supporting a variety of websites ranging from personal weblogs to large community-driven websites.

Drupal is an open source content management platform supporting a variety of websites ranging from personal weblogs to large community-driven websites.

Which is the fastest web framework?

Which is the fastest ? Simple framework comparison Motivation There are many frameworks, each one comes with its own advantages and drawbacks. The pur

Laravel Kickstart is a Laravel starter configuration that helps you build Laravel websites faster.

Laravel Kickstart What is Laravel Kickstart? Laravel Kickstart is a Laravel starter configuration that helps you build Laravel websites faster. It com

Build lightning-fast and feature-rich websites with ProcessWire.

WIREKIT Core Build lightning-fast and feature-rich websites with ProcessWire. Website: wirekit.dev (in plans) Demo: start.wirekit.dev/core/ Updates: W

Moodle activity plugin for embedding content from other websites in a GDPR-compliant way

ICON activate external content What is it? This plugin is for when you want to include GDPR-compliant embeddings of content from external platforms su

PHing Is Not GNU make; it's a PHP project build system or build tool based on Apache Ant.

P H I N G Thank you for using PHING! PHing Is Not GNU make; it's a PHP project build system or build tool based on Apache Ant. You can do anything wit

PHing Is Not GNU make; it's a PHP project build system or build tool based on Apache Ant.

P H I N G Thank you for using PHING! PHing Is Not GNU make; it's a PHP project build system or build tool based on Apache Ant. You can do anything wit

Parsica - PHP Parser Combinators - The easiest way to build robust parsers.

Parsica The easiest way to build robust parsers in PHP.

Parsica - PHP Parser Combinators - The easiest way to build robust parsers.

Parsica The easiest way to build robust parsers in PHP. composer require parsica-php/parsica Documentation & API: parsica-php.github.io ?php $parser

A research raw data repository for researchers of Arba Minch University built using Codeigniter which follows MVC architecture. The front-end is build using Bootstrap.

Arba Minch University Dataset Repository This system is a research dataset repository for Arba Minch University researchers and is build using Codeign

Run multiple websites using the same Laravel installation while keeping tenant specific data separated for fully independent multi-domain setups, previously github.com/hyn/multi-tenant

The unobtrusive Laravel package that makes your app multi tenant. Serving multiple websites, each with one or more hostnames from the same codebase. B

Run multiple websites using the same Laravel installation while keeping tenant specific data separated for fully independent multi-domain setups.

Tenancy for Laravel Enabling awesome Software as a Service with the Laravel framework. This is the successor of hyn/multi-tenant. Feel free to show su

Releases(v1.5.8)
Owner
Marwan Al-Soltany
Known as "MAKS", a developer & polyglot. From Mesopotamia, lives in Germany. TRYING TO MAKE DIFFERENCE! ● @MarwanAlsoltany
Marwan Al-Soltany
Lemon is php micro framework built for simple applications.

Lemon is simple micro framework that provides routing, etc.

Lemon 20 Dec 16, 2022
StackSync is a simple, lightweight and native fullstack PHP mini-framework.

StackSync is a fullstack PHP mini framework, with an MVC structure, custom API system with a Middleware and JWT authentication, components based views, flexible routing, PSR4 autoloading. Essential files generation (migrations, seeders, controllers and models) and other operations can be executed through custom commands.

Khomsi Adam 3 Jul 24, 2022
[DEPRECATED -- Use Symfony instead] The PHP micro-framework based on the Symfony Components

Silex, a simple Web Framework WARNING: Silex is in maintenance mode only. Ends of life is set to June 2018. Read more on Symfony's blog. Silex is a PH

Silex 3.6k Dec 22, 2022
⚡ Flat-files and plain-old PHP functions rockin'on as a set of general purpose high-level abstractions.

Siler is a set of general purpose high-level abstractions aiming an API for declarative programming in PHP. ?? Files and functions as first-class citi

Leo Cavalcante 1.1k Dec 30, 2022
A resource-oriented micro PHP framework

Bullet Bullet is a resource-oriented micro PHP framework built around HTTP URIs. Bullet takes a unique functional-style approach to URL routing by par

Vance Lucas 415 Dec 27, 2022
A PHP client for (Spring Cloud) Netflix Eureka service registration and discovery.

PHP Netflix Eureka Client A PHP client for (Spring Cloud) Netflix Eureka service registration and discovery. Installation You can install this package

Hamid Mohayeji 72 Aug 21, 2022
Yet another PHP Microframework.

ρ Yet another PHP Microframework. The premise of this framework is to be backwards-compatible (PHP <= 5.6) with powerful utilities (Like caching and l

null 0 Apr 6, 2022
PHP微服务框架即Micro Service Framework For PHP

Micro Service Framework For PHP PHP微服务框架即“Micro Service Framework For PHP”,是Camera360社区服务器端团队基于Swoole自主研发现代化的PHP协程服务框架,简称msf或者php-msf,是Swoole的工程级企业应用框

Camera360 1.8k Jan 5, 2023
Frankie - A frankenstein micro-framework for PHP

Frankie - A frankenstein micro-framework for PHP Features Frankie is a micro-framework focused on annotation. The goal is to use annotation in order t

null 19 Dec 10, 2020
ExEngine is an ultra lightweight micro-services framework for PHP 5.6+

ExEngine is an ultra lightweight micro-services framework for PHP 5.6+. Documentation Checkout the Wiki. Examples Click here to browse examples, also

linkfast.io 1 Nov 23, 2020