Documentation

Class Phalcon\Mvc\Micro

extends abstract class Phalcon\Di\Injectable

implements Phalcon\Events\EventsAwareInterface, Phalcon\Di\InjectionAwareInterface, ArrayAccess

Source on GitHub

With Phalcon you can create “Micro-Framework like” applications. By doing this, you only need to write a minimal amount of code to create a PHP application. Micro applications are suitable to small applications, APIs and prototypes in a practical way.

<?php

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

 $app->get('/say/welcome/{name}', function ($name) {
    echo "<h1>Welcome $name!</h1>";
 });

 $app->handle();

Methods

public __construct ([Phalcon\DiInterface $dependencyInjector])

Phalcon\Mvc\Micro constructor

public setDI (Phalcon\DiInterface $dependencyInjector)

Sets the DependencyInjector container

public Phalcon\Mvc\Router\RouteInterface map (string $routePattern, callable $handler)

Maps a route to a handler without any HTTP method constraint

public Phalcon\Mvc\Router\RouteInterface get (string $routePattern, callable $handler)

Maps a route to a handler that only matches if the HTTP method is GET

public Phalcon\Mvc\Router\RouteInterface post (string $routePattern, callable $handler)

Maps a route to a handler that only matches if the HTTP method is POST

public Phalcon\Mvc\Router\RouteInterface put (string $routePattern, callable $handler)

Maps a route to a handler that only matches if the HTTP method is PUT

public Phalcon\Mvc\Router\RouteInterface patch (string $routePattern, callable $handler)

Maps a route to a handler that only matches if the HTTP method is PATCH

public Phalcon\Mvc\Router\RouteInterface head (string $routePattern, callable $handler)

Maps a route to a handler that only matches if the HTTP method is HEAD

public Phalcon\Mvc\Router\RouteInterface delete (string $routePattern, callable $handler)

Maps a route to a handler that only matches if the HTTP method is DELETE

public Phalcon\Mvc\Router\RouteInterface options (string $routePattern, callable $handler)

Maps a route to a handler that only matches if the HTTP method is OPTIONS

public Phalcon\Mvc\Micro mount (Phalcon\Mvc\Collection $collection)

Mounts a collection of handlers

public Phalcon\Mvc\Micro notFound (callable $handler)

Sets a handler that will be called when the router doesn’t match any of the defined routes

public Phalcon\Mvc\RouterInterface getRouter ()

Returns the internal router used by the application

public Phalcon\Di\ServiceInterface offsetSet (string $serviceName, mixed $definition, [boolean $shared])

Sets a service from the DI

public object offsetGet (string $serviceName)

Obtains a service from the DI

public mixed getSharedService (string $serviceName)

Obtains a shared service from the DI

public mixed handle ([string $uri])

Handle the whole request

public stop ()

Stops the middleware execution avoiding than other middlewares be executed

public setActiveHandler (callable $activeHandler)

Sets externally the handler that must be called by the matched route

public callable getActiveHandler ()

Return the handler that will be called for the matched route

public mixed getReturnedValue ()

Returns the value returned by the executed handler

public boolean offsetExists (string $serviceName)

Checks if a service is registered in the DI

public offsetUnset (string $alias)

Removes a service from the internal services container using the array syntax

public Phalcon\Mvc\Micro before (callable $handler)

Appends a before middleware to be called before execute the route

public Phalcon\Mvc\Micro after (callable $handler)

Appends an ‘after’ middleware to be called after execute the route

public Phalcon\Mvc\Micro finish (callable $handler)

Appends a ‘finish’ middleware to be called when the request is finished

public array getHandlers ()

Returns the internal handlers attached to the application

public Phalcon\Mvc\Micro error (callable $handler)

Sets a handler that will be called when an exception is thrown handling the route

protected Phalcon\Mvc\Micro _throwException (string $message)

Sets a handler that will be called when an exception is thrown handling the route

public Phalcon\DiInterface getDI ([unknown $error], [unknown $notUseDefault]) inherited from Phalcon\Di\Injectable

Returns the internal dependency injector

public setEventsManager (Phalcon\Events\ManagerInterface $eventsManager) inherited from Phalcon\Di\Injectable

Sets the event manager

public Phalcon\Events\ManagerInterface getEventsManager () inherited from Phalcon\Di\Injectable

Returns the internal event manager

public boolean fireEvent (string $eventName, [mixed $data], [unknown $cancelable]) inherited from Phalcon\Di\Injectable

Fires an event, implicitly calls behaviors and listeners in the events manager are notified

public mixed fireEventCancel (string $eventName, [mixed $data], [unknown $cancelable]) inherited from Phalcon\Di\Injectable

Fires an event, can stop the event by returning to the false

public boolean hasService (string $name) inherited from Phalcon\Di\Injectable

Check whether the DI contains a service by a name

public Phalcon\Di\ServiceInterface setService (unknown $name) inherited from Phalcon\Di\Injectable

Sets a service from the DI

public object|null getService (unknown $name) inherited from Phalcon\Di\Injectable

Obtains a service from the DI

public mixed getResolveService (string $name, [array $args], [unknown $noerror], [unknown $noshared]) inherited from Phalcon\Di\Injectable

Resolves the service based on its configuration

public attachEvent (string $eventType, Closure $callback) inherited from Phalcon\Di\Injectable

Attach a listener to the events

public __get (unknown $property) inherited from Phalcon\Di\Injectable

Magic method __get

public __sleep () inherited from Phalcon\Di\Injectable

...

public __debugInfo () inherited from Phalcon\Di\Injectable

...