Download the PHP package corneltek/pux without Composer

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

Pux

Pux is a faster PHP router, it also includes out-of-box controller helpers.

Latest Stable Version Total Downloads Latest Unstable Version License Monthly Downloads Daily Downloads

2.0.x Branch Build Status (This branch is under development)

Benchmark

FEATURES

REQUIREMENT

INSTALLATION

SYNOPSIS

The routing usage is dead simple:

Mux

Mux is where you define your routes, and you can mount multiple mux to a parent one.

Methods

Sorting routes

You need to sort routes when not using compiled routes, it's because pux sorts longer path to front:

This sorts routes to:

So pux first compares /page, /pa, than /.

Different String Comparison Strategies

When expand is enabled, the pattern comparison strategy for strings will match the full string.

When expand is disabled, the pattern comparison strategy for strings will match the prefix.

RouteRequest

RouteRequest maintains the information of the current request environment, it also provides some constraint checking methods that helps you to identify a request, e.g.:

APCDispatcher

Although Pux\Mux is already fast, you can still add APCDispatcher to boost the performance, which is to avoid re-lookup route.

This is pretty useful when you have a lot of PCRE routes.

Controller

Pux provides the ability to map your controller methods to paths automatically, done either through a simple, fast controller in the C extension or its pure PHP counterpart:

You can also use @Route and @Method annotations to override the default \Pux\Controller::expand() functionality:

This is especially helpful when you want to provide more specific or semantic (e.g., HTTP method-specific) actions. Note that by default, expanded controller routes will be available via any HTTP method - specifying @Method will restrict it to the provided method.

Route RouteExecutor

Pux\RouteExecutor executes your route by creating the controller object, and calling the controller action method.

Route executor take the returned route as its parameter, you simply pass the route to executor the controller and get the execution result.

Here the simplest example of the usage:

You can also define the arguments to the controller's constructor method:

Dispatching Strategy

There are two route dispatching strategies in Pux while Symfony/Routing only provides PCRE pattern matching:

  1. Plain string comparison.
  2. PCRE pattern comparison.

You've already knew that PCRE pattern matching is slower than plain string comparison, although PHP PCRE caches the compiled patterns.

The plain string comparison is designed for static routing paths, it improves the performance while you have a lot of simple routes.

The PCRE pattern comparison is used when you have some dynamic routing paths, for example, you can put some place holders in your routing path, and pass these path arguments to your controller later.

Pux sorts and compiles your routes to single cache file, it also uses longest matching so it sorts patterns by pattern length in descending order before compiling the routes to cache.

Pux uses indexed array as the data structure for storing route information so it's faster.

Routing Path Format

Static route:

/post

PCRE route:

/post/:id                  => matches /post/33

PCRE route with optional pattern:

/post/:id(/:title)         => matches /post/33, /post/33/post%20title
/post/:id(\.:format)       => matches /post/33, /post/33.json .. /post/33.xml

Q & A

Why It's Faster

Why It's Here

Most of us use a lot of machines to run our applications, however, it uses too much energy and too many resources.

Some people thinks routing is not the bottleneck, the truth is this project does not claim routing is the bottleneck.

Actually the "bottleneck" is always different in different applications, if you have a lot of heavy db requests, then your bottleneck is your db; if you have a lot of complex computation, then the bottleneck should be your algorithm.

You might start wondering since the bottleneck is not routing, why do we implement route dispatcher in C extension? The answer is simple, if you put a pure PHP routing component with some empty callbacks and use apache benchmark tool to see how many requests you can handle per second, you will find out the routing component consumes a lot of computation time and the request number will decrease quite a few. (and it does nothing, all it does is ... just routing)

Pux tries to reduce the overheads of loading PHP classes and the runtime method/function calls, and you can run your application faster without the overheads.

Pros & Cons of Grouped Pattern Matching Strategy

An idea of matching routes is to combine all patterns into one pattern and compare the given path with pcre_match in one time.

However this approach does not work if you have optional group or named capturing group, the pcre_match can not return detailed information about what pattern is matched if you use one of them.

And since you compile all patterns into one, you can't compare with other same patterns with different conditions, for example:

/users  # GET
/users  # POST
/users  # with HTTP_HOST=somedomain

The trade off in Pux is to compare routes in sequence because the same pattern might be in different HTTP method or different host name.

The best approach is to merge & compile the regexp patterns into a FSM (Finite state machine), complex conditions can also be merged into this FSM, and let this FSM to dispatch routes. And this is the long-term target of Pux.

Contributing

Testing XHProf Middleware

Define your XHPROF_ROOT in your phpunit.xml, you can copy phpunit.xml.dist to phpunit.xml, for example:

Hacking Pux C extension

  1. Discuss your main idea on GitHub issue page.

  2. Fork this project and open a branch for your hack.

  3. Development Cycle:

    cd ext
    ./compile
    ... hack hack hack ...
    
    # compile and run phpunit test
    ./compile && ./test -- --debug tests/Pux/MuxTest.php
    
    # use lldb to debug extension code
    ./compile && ./test -l -- tests/Pux/MuxTest.php
    
    # use gdb to debug extension code
    ./compile && ./test -g -- tests/Pux/MuxTest.php
  4. Commit!

  5. Send pull request and describe what you've done and what is changed.

All versions of pux with dependencies

PHP Build Version
Package Version
Requires corneltek/cliframework Version ^2
corneltek/codegen Version ^2.1
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 corneltek/pux contains the following files

Loading the files please wait ....