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., (*1)
Why Use It
You want a framework that does nothing and that you don't have to do a lot of setup for., (*2)
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., (*3)
Edit your apache2.conf
and add this:, (*4)
<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., (*5)
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., (*6)
Point your domain to the public/
folder., (*7)
At this point you should see a "Hey, it works!" message on your homepage., (*8)
.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., (*9)
Usage
Your code
Your code (should) live in the src/
folder., (*10)
Routing
The router initialises an instance of the specified class, then calls the function provided., (*11)
To add a route, modify the routes.php
file. An example has been provided., (*12)
In general, to add a route:, (*13)
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., (*14)
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)
., (*15)