Download the PHP package awesomite/chariot without Composer

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

Chariot

Codacy Badge Build Status Coverage Status

Just another routing library. Makes human-friendly URLs and programmer-friendly code. Uses trees for the best performance.

github.com/awesomite/chariot

Why?

To simplify creating human-friendly URLs.

Table of contents

How does it work?

Patterns

Patterns are designed to maximally simplify creating routing in your application. Patterns can have parameters packed in {{ double curly brackets }}.

Parameters

Parameters contains three values separated by one or more white characters. Second and third values are optional. First value is just a name. Second value is a regular expression or name of registered regular expression, default value is equal to [^/]+. Third value contains default value of parameter (used for generating links).

Examples

I believe that the best documentation are examples from the real world. The following patterns should help you to understand how does it work.

Routing

Generating links

Hidden parameters

Hidden parameters are a very useful mechanism. Using them allows you to completely change routing in your application without changing code in a lot of places. Let's look at the following scenario:

  1. You have a category page in your website.
  2. Path pattern to category page is equal to /category-{{ id :uint }}.
  3. Link to category page is generated in many places in your code. Let's say 100.
  4. You want to change approach. Category's id in a link is not expected anymore. You want to have human-friendly links, e.g. /books instead of /category-15.
  5. Using old school way of generating links forced you to rewrite code in 100 places. You have to spend time to rewriting code. The risk of error is high.

Instead of monotonous rewriting code you can change only one thing in routing. This approuch helps you to save your time and protects your code from bugs. The following pieces of code should help you understand how to rewrite routing.

Old code

New code

Note: In this case small number of categories (let's say 100) will not cause performance issue. But keep in your mind - big number of routes assigned to one handler can slow down generating links. I encourage you to execute performance tests on your machine. Exemplary test is attached to this repository, execute the following commands to perform it:

Bigger example

Caching

Defining custom patterns

Validation

Chariot checks correctness of values incoming (routing) and outcoming (generating links).

Note: Method PatternRouter->linkTo() returns instance of LinkInterface. Read description to understand difference between toString() and __toString() methods.

Default parameters

Transforming parameters

Router can transform parameter extracted from URL (and parameter passed to URL). Passed object to method addPattern() must implements interface PatternInterface. @See PatternInterface.

Providers / Decorators

Let's imagine the following scenario:

1) You have prepared big web-application. 2) Application is using the following pattern to display items /items/{{ id :int }}. 3) Next goal is add title of item to url (/items/{{ id :int }}-{{ title }}).

You can just change URL pattern and add code withParam('title', $title) wherever application generates url to item. Chariot allows resolve such issues better and faster. The following code explains how to use providers. See:

Default patterns

Method Awesomite\Chariot\Pattern\Patterns::createDefault() returns instance of Awesomite\Chariot\Pattern\Patterns with set of standard patterns:

name input output class/regex
:int -5 (int) -5 IntPattern
:uint 5 (int) 5 UnsignedIntPattern
:float -5.05 (float) -5.05 FloatPattern
:ufloat 5.05 (float) 5.05 UnsignedFloatPattern
:date 2017-01-01 new DateTimeImmutable("2017-01-01") DatePattern
:list red,green,blue (array) ["red", "green", "blue"] ListPattern
:ip4 8.8.8.8 (string) "8.8.8.8" Ip4Pattern
:alphanum nickname2000 (string) "nickname2000" [a-zA-Z0-9]+

More examples

License

MIT - read license

Versioning

The version numbers follow the Semantic Versioning 2.0.0 scheme.


All versions of chariot with dependencies

PHP Build Version
Package Version
Requires php Version ^7.0
ext-pcre 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 awesomite/chariot contains the following files

Loading the files please wait ....