Hello,
I am trying to "PUT" values like FQDN with an API, but I got 404 ... I have written a brief testcase to reproduce it with a simple GET request.. Can I have some help to point me my error ?
I initialized the project with:
$ phalcon create-project store micro
Phalcon DevTools (4.0.3)
Success: Project 'store' was successfully created.
Info: Please choose a password and username to use Database connection.
Info: Used default: 'root' without password.
Then I edited the app.php with:
<?php
use Phalcon\Mvc\Micro;
/**
* Local variables
* @var \Phalcon\Mvc\Micro $app
*/
$app = new Micro();
/**
* Add your routes here
*/
$app->get('/', function () {
echo 'index' .PHP_EOL;
});
// stupid function to check
$app->get(
'/invoices/view/{id}',
function ($id) {
echo "Invoice #{$id}!" . PHP_EOL;
}
);
/**
* Not found handler
*/
$app->notFound(function () use($app) {
$app->response->setStatusCode(404, "Not Found")->sendHeaders();
echo '404' . PHP_EOL;
});
Then I launch a php server process:
$ phalcon serve --hostname=127.0.0.1 --port=8091 --rootpath=public --basepath=public/index.php
and finally i test using curl:
$ curl https://127.0.0.1:8091/invoices/view/1
Invoice #1!
$ curl https://127.0.0.1:8091/invoices/view/1.1
<!doctype html><html><head><title>404 Not Found</title><style>
body { background-color: #fcfcfc; color: #333333; margin: 0; padding:0; }
h1 { font-size: 1.5em; font-weight: normal; background-color: #9999cc; min-height:2em; line-height:2em; border-bottom: 1px inset black; margin: 0; }
h1, p { padding-left: 10px; }
code.url { background-color: #eeeeee; font-family:monospace; padding:0 2px;}
</style>
</head><body><h1>Not Found</h1><p>The requested resource <code class="url">/invoices/view/1.1</code> was not found on this server.</p></body></html>
$
The only difference is 1.1 instead of 1 ... Is there a parameter missing ? a filter problem perhaps ?
Thank you for your help ... Nicolas.
$ phalcon info
Phalcon DevTools (4.0.3)
Environment:
OS: Darwin MacBook-Air-de-Nicolas.local 19.5.0 Darwin Kernel Version 19.5.0: Tue May 26 20:41:44 PDT 2020; root:xnu-6153.121.2~2/RELEASE_X86_64 x86_64
PHP Version: 7.2.30
PHP SAPI: cli
PHP Bin: /usr/local/Cellar/[email protected]/7.2.30_1/bin/php
PHP Extension Dir: /usr/local/Cellar/[email protected]/7.2.30_1/lib/php/20170718
PHP Bin Dir: /usr/local/Cellar/[email protected]/7.2.30_1/bin
Loaded PHP config: /usr/local/etc/php/7.2/php.ini
Versions:
Phalcon DevTools Version: 4.0.3
Phalcon Version: 4.0.5
AdminLTE Version: 2.3.6