Download the PHP package eberfreitas/cakephp-power-router without Composer

On this page you can find all versions of the php package eberfreitas/cakephp-power-router. 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 cakephp-power-router

PowerRouter Plugin

Build Status Coverage Status

PowerRouter is a plugin that extends how your default Router can be used. It enables three new features:

Requirements

Installation

Using Composer

Add the plugin to your project's composer.json - something like this:

Because this plugin has the type cakephp-plugin set in it's own composer.json, composer knows to install it inside your /Plugins directory, rather than in the usual vendors file. It is recommended that you add /Plugins/PowerRouter to your .gitignore file. Why? read this.

Manual

GIT Submodule

In your app directory type:

GIT Clone

In your plugin directory type:

Usage

PowerRouter is a custom route class that extends on the CakeRoute. This way you can use it to define your routes and take advantage of it's features. Using it will replace both match and parse methods.

The match method is used to handle reverse routing and parse is used to parse requests. You can read more about custom route classes on the CakePHP book.

In order to use the features from PowerRouter, first you need to load the plugin adding the following line in your app/Config/bootstrap.php:

Later, import the library into your "app/Config/routes.php" file like this:

After that you can start to define your routes like this:

But, if you are planning on using PowerRoute a lot, you can use the helper class PowerRouter in order to make declaring new routes a little bit easier. In that case, instead of importing the 'PowerRoute' lib, import the 'PowerRouter' lib like this (mind the "r"):

Now you can do something like this:

Here is how the PowerRouter::connect method is described:

Where:

Using named routes

So, the first thing you can do with PowerRouter is to define named routes. This will make it easier and faster to match routes when doing any kind of route matching. Let's see an example:

Now, if you want to link to this page on your views, you can do something like this:

That will match the right route. You can also combine params:

Using callbacks

With callbacks you can manipulate your route's params before it is used by the application. When a route is parsed it returns an array with the params it will use such as the controller that was matched, the action, among other things. Using a callback you can inject or modify information into that array. The callback can be anything that is_callable, including closures. Let's take a look at an example:

Now, when someone hits /dashboard/user/view/123 you will "redirect" the request to the UserController::dash_view method. The callback is executed and effectively changes the params being used on that request.

It's really important that you return the $params variable at the end of the callback function, as that will be used by the application from now on.

Using conditional callbacks

Another form of callback that PowerRouter enables is the condition one. With that callback you can block a route from being used by any conditions you define in that callback. The function should return a boolean value representing the validity of that route. Example:

Depending on the value of the route configuration key, the test route will be used or not. With that you can dynamically mold your routes to respond according to a given environment or set of conditions.

Alternatively you can pass an array of callback functions that will be executed in order until any of the them deny access to that route.

License

The MIT License (MIT)

Copyright (c) 2014 Éber Freitas Dias

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


All versions of cakephp-power-router with dependencies

PHP Build Version
Package Version
Requires composer/installers 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 eberfreitas/cakephp-power-router contains the following files

Loading the files please wait ....