Download the PHP package bcen/ci-dispatcher without Composer

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

CodeIgniter-Dispatcher (WIP)

Introduction

CodeIgniter-Dispatcher uses CodeIgniter's _remap function to do an extra routing to a class-based controller instead of function-based.

Example

CodeIgniter's function-based controller

With CodeIgniter-Dispatcher's class-based controller

Installtion

  1. Download the composer.phar executable or use the installer

  2. Add this to composer.json

  3. Run composer php composer.phar install

  4. Include autoload.php in your project and add this to routes.php

    Dispatcher\BootstrapInstaller::run($route) will create 3 files inside of CodeIgniter's APPPATH, if you want to skip the file creation, add true to to skip the file check.

Features

Poor man's dependency injection

Middlewares, DispatchableController and DispatchableResource will be injected by default.

Middlewares

processRequest and processResponse are optional, middleware can implement either one or both to alter the request/response cycle.

CodeIgniter Awareness

Any class that is created by the Dispatcher can implement CodeIgniterAware to have CI injection.

E.g.

Configurations

There are two configuration files, config/dispatcher.php and config/dependencies.php.

dispatcher.php

debug:
Whether to show or hide debug information.
Set true to show exception, false to return error 404 response when stuff gone wrong.

middlewares:
An array of middleware class(es) to be processed before/after dispatch.
When specifying the middlewares, it can be a fully qualified class name if it is autoloaded, otherwise the class must live under application/middlewares/ in order for CI-Dispatcher to load it (Note: naming convention applies).

dependencies.php

This configuration file is used for DIContainer to load dependencies and inject them into Middlewares, DispatchableController and DispatchableResource's constructor.
Note: DIContainer is a copy cat of Pimple.

Note:
container can have anonymous function or simple value like string, array, etc...
sharedContainer must contian only anonymous function.

Conventions

URL to Controller mappings

URL mapping convention follows almost excatly like CodeIgniter's default strategy.

E.g.
http://domain.com/ maps to application/controllers/index.php with the class name Index
http://domain.com/about_me maps to application/controllers/about_me.php with the class name About_Me

Directory nesting:

http://domain.com/blog and http://domain.com/blog/ajax/fetch_all_posts can be mapped to:

Mapping strategy:

CI-Dispatcher will search through each URI segments for the exact file name under application/controllers. If it doesn't exists, it will search index.php under that URI segments.

E.g.
http://domain.com/blog has the URI segment: blog.
First CI-Dispatcher will search for application/controllers/blog.php.
If it doesn't exists, then it will try for application/controllers/blog/index.php.

URI variable:

Sometime URI segments are not fixed, thus we cannot mapped to a directory or class. However, we can mapp it to the function arguments of the request handler.

E.g. http://domain.com/blog/posts/this-is-a-crayz-blog-post-about-my-blog/ can be mapped to application/controllers/blog/posts.php with the follow class:

Note: The request handler must accept at least one argument for the Request object.

Middlewares

If middlewares are not autoloaded by class loader like composer, they must live under application/middlewares.

E.g.

debug_filter will be mapped to application/middlewares/debug_filter.php with the class name Debug_Filter.
auth_filter will be mapped to application/middlewares/auth_filter.php with the class name Auth_Filter.

Controller Explained

Any class lives under application/controllers/ and extends Dispatcher\DispatchableController will be created and injected by the CI-Dispatcher.

E.g. Assumes we are sending a GET request to http://domain.com/blog/posts/special-post.

At minimal

By default, a GET request handler is provided, when get got invoked, it will load the views and data.
So when extending the DispatchableController, you only need to provide where the view files are by declaring $views = 'post_view' or as an array $views = array('header', 'post_view', 'footer')

Overrides getContextData to send data to the view layer:

Overrides/implements get, post, delete, put and etc to take complete control of the request/response handling.

Tests

License

CI-Dispatcher is released under the MIT public license.


All versions of ci-dispatcher with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
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 bcen/ci-dispatcher contains the following files

Loading the files please wait ....