Phalcon plugin for checking access by HTTP Method of request.
Phalcon plugin for checking access by HTTP Method of request.
You can select one or more HTTP methods for action availability from this: GET, POST, PUT, DELETE.
Works with PHP 7.1+
Plugin require availability ‘Annotations’ and ‘Request’ components in application DI container.
$dispatcher = new \Phalcon\Mvc\Dispatcher();
$eventManager = new \Phalcon\Events\Manager();
$eventManager->attach('dispatch:beforeExecuteRoute', new \Vados\PhalconPlugins\HTTPMethodsPlugin());
$dispatcher->setEventsManager($eventManager);
And just take annotations to controllers actions
class FooController extends \Phalcon\Mvc\Controller
{
/**
* @Method(GET, POST, PUT, DELETE)
*/
public function barAction()
{
return 'foobar';
}
}
Use composer for installation
composer require vados/phalcon-http-methods-plugin