Download the PHP package jinexus-framework/jinexus-route without Composer

On this page you can find all versions of the php package jinexus-framework/jinexus-route. 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 jinexus-route

JiNexus Route

JiNexus Route provides simple route matching and access to every registered route in an application, together with a redirect helper, for jinexus-mvc applications.

A Route holds a name-keyed table of route definitions, derives the current request URI from $_SERVER, and matches it against that table. A Redirect sends a Location header for a named route and terminates the request.

Requirements

Installation

Install via Composer:

Usage

Registering routes

A route table is an array keyed by the route name. Each entry needs a route key holding the URI; any other keys are yours to use and are returned untouched on a match.

Matching the current request

A match returns the whole entry, keyed by its route name. Matching stops at the first hit, so if two names share a URI, the earlier one wins.

You can also match against a table passed in directly, without registering it. A supplied table takes precedence; an empty one falls back to the registered routes:

Resolving a route's URI by name

getRouteUri() follows the same rule as getMatchRoute(): a supplied $routes table wins, and an empty one falls back to whatever setRoutes() registered. It throws a RouteException when the name is found in neither.

Deriving the request URI

getUri() strips the directory the front controller lives in, drops the query string, and normalizes the surrounding slashes:

SCRIPT_NAME REQUEST_URI getUri()
/index.php / /
/index.php /about-us/ /about-us
/index.php /search?q=a/b /search
/app/public/index.php /app/public/ /
/app/public/index.php /app/public/user/42 /user/42

This reads $_SERVER['SCRIPT_NAME'] and $_SERVER['REQUEST_URI'] directly, so both must be present.

Redirecting

toRoute() throws a RouteException when the name is empty or unregistered and skips the header if headers have already been sent. It terminates the request either way, so nothing after the call runs.

The redirect a Route was constructed with is reachable from it:

Magic getters and setters

AbstractBase::__call() resolves getX()/setX() against public properties only. Setters are fluent. Anything it cannot resolve — a protected property, an unknown property, or a method that isn't a get/set prefix — throws a RouteException:

Error handling

Package-level failures throw JiNexus\Route\RouteException (a subclass of \Exception):

Message Thrown by
Route "<name>" not found getRouteUri(), toRoute()
Route name must be provided toRoute() with an empty name
Not implemented: <class>::<property> AbstractBase::__call()

Extending

Route and Redirect are deliberately empty subclasses of AbstractRoute and AbstractRedirect. Keep them that way — the public accessors are implemented with PHP property hooks over backing fields, and declaring a real property would shadow them. For IDE autocompletion, prefer @property PHPDoc tags over real properties.

AbstractRedirect exposes three protected seams so the terminating redirect can be tested: headersSent(), sendHeader(), and terminate(). Override them in a subclass to observe or intercept the redirect instead of ending the request.

Testing

The suite is 52 tests at 100% line, method, and class coverage. phpunit.dist.xml is the committed configuration. Use XDEBUG_MODE=off to silence the local Xdebug notice:

Contributing

Please see CONDUCT.md for the code of conduct. Contributions should include tests and a CHANGELOG.md entry. See AGENTS.md for detailed build, style, and workflow conventions.

License

BSD-3-Clause. See LICENSE.md.


All versions of jinexus-route with dependencies

PHP Build Version
Package Version
Requires php Version ^8.5
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 jinexus-framework/jinexus-route contains the following files

Loading the files please wait ...