2017 © Pedro Peláez
 

package fcphp-route

Package to manipulate route for FcPhp

image

00f100/fcphp-route

Package to manipulate route for FcPhp

  • Saturday, July 28, 2018
  • by 00F100
  • Repository
  • 1 Watchers
  • 1 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

FcPHP Route

Package do manage routes into FcPhp, (*1)

Build Status codecov Total Downloads, (*2)

How to install

Composer:, (*3)

$ composer require 00f100/fcphp-route

or composer.json, (*4)

{
    "require": {
        "00f100/fcphp-route": "*"
    }
}

How to use

After match route (same 404, 403) return instance of FcPhp\Route\Entity, (*5)

<?php

use FcPhp\SHttp\SEntity;
use FcPhp\Route\Facades\RouteFacade;

// See: https://github.com/00F100/fcphp-shttp
$entity = new SEntity();

// Config directories to autoload and cache
$vendorPath = 'tests/*/*/config';
$cachePath = 'tests/var/cache';

// Init instance of Route
$instance = RouteFacade::getInstance($entity, $vendorPath, $cachePath);

// Match route into routes list
$match = $instance->match('GET', 'v1/users/10');

// Print: FcPhp\Route\Entity
echo get_class($match);

// Print: 200
echo $match->getStatusCode();
Callback's
<?php

use FcPhp\Route\Interfaces\IEntity;

// Init match route process
$instance->callback('initCallback', function(array $routes) {

    // Your code here ...

});

// Match route
$instance->callback('matchCallback', function(array $routes, string $method, string $route, array $entity, IEntity $routeEntity) {

    // Your code here ...

});

// Route not found
$instance->callback('notFoundCallback', function(array $routes, string $method, string $route, array $entity = [], IEntity $routeEntity = null) {

    // Your code here ...

});
FcPhp\Route\Entity
<?php

namespace FcPhp\Route\Interfaces
{
    interface IEntity
    {
        /**
         * Method to construct instance
         *
         * @param array $params Params to populate Entity
         * @return void
         */
        public function __construct(array $params = []);

        /**
         * Method to return method of request
         *
         * @return string
         */
        public function getMethod() :string;

        /**
         * Method to return route of request
         *
         * @return string|null
         */
        public function getRoute();

        /**
         * Method to return rule to access
         *
         * @return string|null
         */
        public function getRule();

        /**
         * Method to return action to execute
         *
         * @return string|null
         */
        public function getAction();

        /**
         * Method to return filters to apply
         *
         * @return array
         */
        public function getFilter() :array;

        /**
         * Method to return status code
         *
         * @return int
         */
        public function getStatusCode();

        /**
         * Method to return status message
         *
         * @return string|null
         */
        public function getStatusMessage();

        /**
         * Method to configure full route
         *
         * @param string $fullRoute Full route
         * @return void
         */
        public function setFullRoute(string $fullRoute) :void;

        /**
         * Method to return full route
         *
         * @return string|null
         */
        public function getFullRoute();

        /**
         * Method to configure params to controller
         *
         * @param array $params Params to controller
         * @return void
         */
        public function setParams(array $params) :void;

        /**
         * Method to return params to controller
         *
         * @return array
         */
        public function getParams() :array;
    }
}

The Versions

28/07 2018

dev-master

9999999-dev https://github.com/00f100/fcphp-route

Package to manipulate route for FcPhp

  Sources   Download

The Requires

 

The Development Requires

route manager fcphp

25/07 2018