Download the PHP package marwanalsoltany/velox without Composer

On this page you can find all versions of the php package marwanalsoltany/velox. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package velox

VELOX


VELOX

The fastest way to build simple websites using PHP! [![PHP Version][php-icon]][php-href] [![Latest Version on Packagist][version-icon]][version-href] [![Total Downloads][downloads-icon]][downloads-href] [![License][license-icon]][license-href] [![Maintenance][maintenance-icon]][maintenance-href] [![Documentation][documentation-icon]][documentation-href] [![Scrutinizer Build Status][scrutinizer-icon]][scrutinizer-href] [![Scrutinizer Code Coverage][scrutinizer-coverage-icon]][scrutinizer-coverage-href] [![Scrutinizer Code Quality][scrutinizer-quality-icon]][scrutinizer-quality-href] [![Travis Build Status][travis-icon]][travis-href] [![StyleCI Code Style][styleci-icon]][styleci-href] [![Open in Visual Studio Code][vscode-icon]][vscode-href] [![Run on Repl.it][replit-icon]][replit-href] [![Tweet][tweet-icon]][tweet-href] [![Star][github-icon]][github-href]
Table of Contents

[Installation](#installation)
[About VELOX](#about-velox)
[Architecture](#architecture)
[Config](#config)
[Classes](#classes)
[Functions](#functions)
[Commands](#commands)
[Themes](#themes)
[Extending VELOX](#extending-velox)
[MVC](#mvc)
[Templating](#templating)
[Authentication](#authentication)
[Changelog](./CHANGELOG.md)
[Documentation](https://marwanalsoltany.com/velox)


If you like this project and would like to support its development, giving it a :star: would be appreciated!
VELOX Demo Check out the [**Demo**](https://velox.marwanalsoltany.repl.co) or play with the [**REPL**](https://replit.com/@MarwanAlsoltany/velox). Do you feel like reading? Check out the full API on the documentation website on [`marwanalsoltany.github.io/velox`](https://marwanalsoltany.github.io/velox).

Key Features

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

Installation

Using Composer:

RED Note: You may need to add the --stability=dev depending on the version/branch. You may also want to add --no-dev flag to not install development dependencies.

Using Git:

BLUE 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.

GREEN Advice: If you want to test out VELOX quickly and you don't have any web server available, use whatever installing method and run php bin/app-serve from inside VELOX directory. This command will spin up a development web server on localhost:8000 (Note that you need to have at least PHP installed on your system).


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 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, interact with the database, render views, handle exceptions, autoload code, and resolve assets. It provides the View and the Controller parts of an MVC design pattern. Staring from v1.3.0, VELOX also provides the Model part, making it a fully featured MVC framework and starting from v1.4.0 it also comes shipped with a simple authentication system. 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, minimal, and straight to the point.

It's not recommended to use VELOX if you have an intermediary project, you would be better off using a well-established framework. 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.
bin This is where PHP executables are placed. You can freely add yours, or delete the entire directory.
app This is where your own backend logic will be placed. You will be mostly working here for the backend part of your app.
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.
includes This is where all files that should be preloaded will be placed. 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.
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.
public This is where you should put your index.php with a symlink for static assets (active theme assets/ directory for example) 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.

GREEN 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 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.

Additionally, you can add middlewares using Router::middleware() and/or set up handlers for 404 and 405 responses using {global.errorPages.CODE} config value.

Alternatively, you can extract the "routes registration part" in its own file and let VELOX know about it using bootstrap/additional.php. Starting from v1.2.0 VELOX does that by default, the file includes/routes/web.php is where you should register your routes. The router will also start automatically if not started explicitly.

RED 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.
session.php This config file contains session configuration, it is used by the Session::class.
database.php This config file contains database credentials, it is used by the Database::class.
auth.php This config file contains authentication configuration, it is used by the Auth::class.
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.
cli.php This config file can be used to enable/disable the commands or change their arguments.

BLUE 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 your 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

VELOX classes are divided in four namespaces:

The following table lists all available classes with their description:

Class Description
Velox\App A class that serves as a basic service-container for VELOX.


Backend\Event A class that offers simple events handling functionality (dispatching and listening).
Backend\Config A class that loads everything from the /config directory and make it as an array that is accessible via dot-notation.
Backend\Router A class that serves as a router and an entry point for the application.
Backend\Globals A class that serves as an abstraction/wrapper to work with superglobals.
Backend\Session A class that offers a simple interface to work with sessions.
Backend\Controller An abstract class that serves as a base Controller that can be extended to make handlers for the router.
Backend\Database A class that represents the database and handles database operations.
Backend\Model An abstract class that serves as a base model that can be extended to create custom models.
Backend\Auth A class that serves as an authentication system for users.


Frontend\Data A class that serves as an abstracted data bag/store that is accessible via dot-notation.
Frontend\View A class that renders view files (Layouts, Pages, and Partials) with the ability to include additional files, divide page content into sections and cache rendered views.
Frontend\HTML A class that serves as a fluent interface to write HTML in PHP. It also helps with creating HTML elements on the fly.
Frontend\Path A class that serves as a path resolver for different paths/URLs of the app.


Helper\Dumper A class that dumps variables and exception in a nice formatting.
Helper\Misc A class that serves as a holder for various miscellaneous utility function.

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

BLUE Fact: The App, Event, Config, Router, Globals, Session, Database, Auth, Data, View, HTML, Path classes are aliased on the root namespace for ease-of-use.


Functions

VELOX functions are divided into these files:

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

Class/Group Function(s)
App::class app(),
abort(),
terminate()
Event::class event()
Config::class config()
Router::class router(),
handle(),
redirect(),
forward()
Database::class database()
Globals::class globals()
Session::class session(),
flash(),
csrf()
Auth::class auth()
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()

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


Commands

VELOX comes with some handy commands that you can use to do some repetitive tasks. You can execute these commands using the php bin/{command-name}.

The following table lists all available commands with their description.

Command Description
app-serve This command starts a development server.
app-mirror This command mirrors the application in the /public directory.
config-cache This command caches the current configuration.
config-dump This command dumps the current configuration with syntax highlighting.
cache-clear This command clears caches.

You can customize these commands using the config/cli.php file. Here you can enable/disable them or provide different arguments for them.

If you would like to make all these commands accessible via a single interface. Check out my other package Blend, which will do that for you and even more.


Themes

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

You can customize the behavior of themes using the config/view.php file.

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

Examples:

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

Extending VELOX

To add your 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 your classes. See app/Controller/DefaultController.php, to get an idea.

Here is a list of some important files that you should consider when working with VELOX:


MVC

Creating a Model:

Working with the Model:

Using the Model in the Controller:

BLUE Fact: CRUD operations (namely: index, create, store, show, edit, update, destroy) are registered and configured by default. To register your own routes automatically, use the @route("<path>", {<http-verb>, ...}) annotation. See Controller::registerRoutes() DocBlock to learn more.

BLUE Fact: To make the model available as property for the controller ($this->model), use Controller::associateModel(). See Controller::associateModel() DocBlock to learn more.

GREEN Advice: If in production mode, as a shortcut, throwing an exception with a code matching {global.errorPages.CODE} config value will render the corresponding error page. For example, when throwing new Exception('Not found', 404) form the controller, the configured 404 error page will be rendered and will be passed the exception message. If the page is not configured, the 500 error page will be rendered as a fallback instead.

VELOX does not have any way to validate data. Check out my other package Mighty, which will do that for you and even more.

Using the Model in a View:

GREEN Advice: Check out the PersonsController to see a realistic example.


Templating

VELOX comes with its own templating engine. This templating engine is very intuitive and easy to get along with, if you have experience with any other templating engine, learning it would be a matter of minutes. Note that the use of this templating engine is optional. You can simply use raw PHP in your views.

The following table lists all available tags and what they do:

Tag Description
code>{! @extends 'path/to/template' !} Extend a template, blocks of this template will be inherited.
code>{! @include 'path/to/file' !} Include a file, this will get rendered before inclusion (can't access context variables).
code>{! @embed 'path/to/file' !} Embed a file, this will be included as is (can access context variables).
br>{! @endblock !} Create a block to wrap some code.
code>{! @super !} Use it inside a block in an extended template to inherit parent block content.
code>{! @block(name) !} Print a block. Needs to be called at least once in order to render a block.
{! @foreach ($vars as $var) !}/code>
{! @endforeach !}
Control structures (loops, if statements, ...). All PHP control structures are available (if, else, elseif, do, while, for, foreach, continue, switch, break, return, require, include) with the same syntax but simply prefixed with an @ symbol if a control structure is the first word in the tag.
{! $var = '' !} Variable assignments. Content can be a variable or any valid PHP expression.
{{ $var }} Print a variable. Content can be a variable or any PHP expression that can be casted to a string.
{{{ $var }}} Print a variable without escaping. Content can be a variable or any PHP expression that can be casted to a string.
{# This is a comment #} Comment something. This will be a PHP comment (will not be available in final HTML).

GREEN Advice: Take a look at PersonsController in VELOX theme for a realistic example.


Authentication

Starting from v1.4.0 VELOX comes shipped with a simple built-in authentication system. This system is very simple and easy to use.

GREEN Advice: Check out the UsersController to see a realistic example.


License

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


All versions of velox with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4 || ^8.0
ext-mbstring Version *
ext-json Version *
ext-dom Version *
ext-intl Version *
ext-pdo Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package marwanalsoltany/velox contains the following files

Loading the files please wait ....