Skip to content
A tool to create multiple Phalcon Collections with easy.
PHP CSS
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs-src
docs
examples
src
.gitignore
.php_cs
LICENSE.md
README.md
composer.json
composer.lock
docker-compose.yml
mkdocs.yml

README.md

Baka Router

A tool to create multiple Phalcon Collections with easy.

Requirements

  • This package requires PHP 7.1 or higher.
  • Phalcon 3.4 or higher.

Installation

You can install the package via composer:

composer require baka/router

Basic Usage

require_once __DIR__ . '/vendor/autoload.php';

use Baka\Router\RouteGroup;
use Baka\Router\Route;
use Baka\Router\Utils\Http;

$routes = [
    Route::add('u')->controller('UsersController')->via(Http::GET, Http::POST),
    Route::get('custom-fields'),
    Route::put('users')->action('editUser'),
    Route::add('companies')->middlewares(
        'custom.middleware@before:10,12',
        'custom.middleware2@after'
    ),
];

$anotherRoute = new Route('companies');

$anotherRoute->prefix('/v2')
->controller('CompaniesController')
->namespace('App\\Api\\Controllers')
->via('get','put','post');

$routeGroup = RouteGroup::from($routes)
->addRoute(Route::put('products')->action('edit'))
->addRoute($anotherRoute)
->addMiddlewares('extra.middleware@before')
->defaultNamespace('App\\Default\\Controllers')
->defaultAction('call');

$collections = $routeGroup->toCollections();

var_dump($collections); // 16 Collection instances


// Mount collections to the app

$app = new \Phalcon\Mvc\Micro();

foreach ($collections as $collection){ 
    $app->mount($collection);
}
You can’t perform that action at this time.