Download the PHP package badluck/badrouter without Composer
On this page you can find all versions of the php package badluck/badrouter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package badrouter
BadRouter
A minimalist router inspired by Ruby's Sinatra router.
Visit the official documentation page here: https://badrouter.badluck.io
Install
1. Run composer require badluck/badrouter
in your project directory to install the package and its dependencies.
2. Require the autoloader. At the beginning of your PHP file, require the Composer autoloader by adding this line of code:
3. Use the Router
static class.
You can use ::get
, ::post
, ::put
, and ::delete
. BadRouter supports dynamic routes in {braces}
.
4. Configure the view and public directories.
The public
directory is where the router will search for static files if the URI is not a route.
The views
directry is where Router::render
will search when rendering pages.
5. After the router is configured, run it.
Full Usage example
Change Log
Log types:
- Added
- Changed
- Fixed
- Moved
- Removed
- Renamed
- Updated
v0.4.5 (2023-07-26)
- Added styling rules
v0.4.4 (2023-05-03)
- Fixed bug with fetching views using relative directory paths
v0.4.3 (2023-05-03)
- Fixed incorrect Content-Type for 404
v0.4.2 (2023-05-03)
- Fixed bug in URI parsing
v0.4.1 (2023-05-02)
- Fixed file search path missing a slash
v0.4.0 (2023-05-01)
- Added 74 MIME types
- Changed static files automatically fetched and no longer need PUBLIC_PATH to be specified
v0.3.4 (2023-04-26)
- Removed Router::json datatype for input
v0.3.3 (2023-04-24)
- Fixed warning
$server['HTTP_REFERER']
with null coalescence
v0.3.2 (2023-04-18)
- Fixed Composer PHP requirements from "^7.4.33" to ">=7.4.33"
v0.3.1 (2023-04-17)
- Fixed route not checking against the
Request
object - Fixed
Router::render
$layout
param not being nullable
v0.3.0 (2023-04-17)
- Added class
Request
- Added variable type specifications to method params
- Added variable type to method returns
- Updated middleware
use
to specifyClosure(Request)
type - Updated documentation to include change logs
v0.2.5 (2023-04-13)
- Updated documentation to mention https://badrouter.badluck.io
v0.2.4 (2023-04-13)
- Fixed (another) bug in
Router::set_base_path
- Moved example website from this package and into its own repo at https://github.com/BadLuckSoftware/BadRouter-Example
- Updated
$request
fields to benull
if$_SERVER
field wasnull
- Updated
Router::redirect
to useBASE_PATH
instead ofself::$base_path
v0.2.3 (2023-04-13)
- Added GitHub Action to deploy example to https://badrouter.badluck.io
- Fixed bug in
Router::set_base_path
v0.2.2 (2023-04-13)
- Added
$request
parameter to middleware - Added
VIEWS_PATH
global variable - Added
Router::json
method - Renamed directory
example_website
toexample
- Updated example website to reflect the current features of
BadRouter
- Updated
Router::set_base_path
to default empty paths to '/
'
v0.2.1 (meow)
- The cow goes moo
v0.2.0 (2023-04-11)
- Added
BASE_PATH
global variable - Added
Router::set_base_path
method - Added Composer keywords
- Changed
PUBLIC_DIR
global variable toPUBLIC_PATH
- Moved
BadRouter
repo toBadLuckSoftware
underbadluck
namespace - Updated Composer description
v0.1.3 (2023-04-06)
- Updated documentation
v0.1.2 (2023-04-05)
- Renamed file
BadRouter.php
toRouter.php
- Updated example in readme
- Updated example website to use the correct Router name
v0.1.1 (2023-04-05)
- Added forgotten namespace
- Renamed class
BadRouter
toRouter
v0.1.0 (2023-04-05)
- Added initial BadRouter Composer package