Cphalcon: Fatal error: Uncaught exception 'Phalcon\Mvc\Micro\Exception' with message 'The Not-Found handler is not callable or is not defined'

Created on 6 Dec 2012  路  4Comments  路  Source: phalcon/cphalcon

error_reporting(E_ALL | E_STRICT) ;
ini_set('display_errors', 'On');

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

$app->get('/say/welcome/{name}', function ($name) {

});

$app->handle();

Most helpful comment

Hi, this usually happens when "The Not-Found handler is not callable or is not defined", you can define a not-found handler for the app in the following way:

$app->notFound(function () use ($app) {
    $app->response->setStatusCode(404, "Not Found")->sendHeaders();
    echo 'This is crazy, but this page was not found!';
});

http://docs.phalconphp.com/en/latest/reference/micro.html#not-found-handler

All 4 comments

Hi, this usually happens when "The Not-Found handler is not callable or is not defined", you can define a not-found handler for the app in the following way:

$app->notFound(function () use ($app) {
    $app->response->setStatusCode(404, "Not Found")->sendHeaders();
    echo 'This is crazy, but this page was not found!';
});

http://docs.phalconphp.com/en/latest/reference/micro.html#not-found-handler

Bolsheo thank you. But all describe in a single file is bad. If you create folders and files in them he put them ?
example:
/model1/get.php
/model1/post.php
/model1/put.php

<?php

require 'functions/func1-file.php';
require 'functions/func2-file.php';

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

$app->get('/some/route/{name}', 'func1');
$app->get('/some/route', 'func2');

In functions/func1-file.php:

function func1($name){

}

In functions/func2-file.php:

function func2(){

}

thanks, you can close)

Was this page helpful?
0 / 5 - 0 ratings