Skip to content

Rest route not found / recognized #264

Answered by borisdelev
errXprintln asked this question in Q&A
Discussion options

You must be logged in to vote

Mate, you code looks fine. But the issue is the URL... you open : http://localhost/projects/Phalcon/api/countries and i think your code is in that phalcon folder?

so... try this:

$app->get(
    '/projects/Phalcon/api',
    function () use ($app) {
        $data = [];

        echo json_encode($data);
    }
);

$app->get(
    '/projects/Phalcon/api/countries',
    function () use ($app) {
        $data = [];

        echo json_encode($data);
    }
);

Some recommendation:
Try to use vhosts in Apache - then url will be like http://project.api/countries (for example):

In apache httpd-vhosts.conf

<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs/projects/Phalcon/api/"
    ServerName project…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@errXprintln
Comment options

Answer selected by errXprintln
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants