Simple Lightweight Routing PHP Framework.
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin
config
core
docs
public
src/Controller
tests
.gitignore
CHANGELOG.md
LICENSE
README.md
composer.json
init_user.php
routes.php

README.md

barrens

This is supposed to be a super simple framework for PHP projects. It barely does anything and requires the minimum amount of setup that you have probably already done before.

Why Use It

You want a framework that does nothing and that you don't have to do a lot of setup for.

Features

  • Quick install
  • Simple routing engine

Requirements

  • Apache2 (or implement your own URL rewriting)
  • PHP 7.1 and above

Setup

Run sudo a2enmod rewrite to enable the rewrite Apache extension.

Edit your apache2.conf and add this:

<Directory /var/www/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
        Require all granted
</Directory>

If you haven't already, install Composer.

Then run php composer.phar install-project keythkatz/barrens . to install it into the current folder or php composer.phar install-project keythkatz/barrens [install directory] to install it into a folder of your choice.

Point your domain to the public/ folder.

At this point you should see a "Hey, it works!" message on your homepage.

.htaccess, Images, CSS and JS

By default, URLs ending in an image format, .css and .js are not handled by the router, and are served by files in the public/ directory. You can modify the public/.htaccess file to add/remove extensions.

Usage

Your code

Your code (should) live in the src/ folder.

Routing

The router initialises an instance of the specified class, then calls the function provided.

To add a route, modify the routes.php file. An example has been provided.

In general, to add a route:

	Route::[verb]([full path], [full class name to initialise], [function to call]);
	// [verb] = get, post, put, patch, delete, head, options

Use Route::cli(...) for command line-only access.

Parameters

In the path, you can use {paramName} to indicate a parameter. These will be passed as an array into the provided function. Example: Route::get("/from/{from}/to/{to}", "\Example", "main") will pass ["from" => ..., "to" => ...] into \Example->main($params).