Closed radekdostal closed 1 year ago
It looks like this change https://github.com/contributte/apitte/commit/67d760544d6a168c62b850e6362ab4dc1a2fc615
Can you send me examples of your URL patterns with example domain?
The absolute simplest example, I have one controller and one method.
// BaseV1Controller.php
/**
* @Path("/v1")
*/
abstract class BaseV1Controller implements IController {}
// UserController.php
/**
* @Path("/users")
*/
final class UserController extends BaseV1Controller
{
/**
* @Path("/")
* @Method("GET")
*/
public function getAll(ApiRequest $request, ApiResponse $response): ApiResponse
{
...
}
}
// config.neon
extensions:
api: Apitte\Core\DI\ApiExtension
api:
catchException: TRUE
debug: %debugMode%
plugins:
Apitte\Core\DI\Plugin\CoreDecoratorPlugin:
Apitte\Debug\DI\DebugPlugin:
debug:
panel: %debugMode%
negotiation: %debugMode%
services:
- App\Controllers\UserController()
// index.php
// ...
App\Bootstrap::boot()
->createContainer()
->getByType(Apitte\Core\Application\IApplication::class)
->run();
GET https://web.localhost/<project-url>/v1/users
Hmm, I see some troubles at <project-url>
, can you give a try https://github.com/contributte/middlewares/blob/master/.docs/README.md#autobasepathmiddleware?
Only blank page. But Tracy shows the same as before.
Hmm, I am lost. I don't use setup https://web.localhost/<project-url>/v1/users
thus I don't know where is the catch.
Can you please setup https://github.com/contributte/apitte-skeleton/ as you have a and write a little manual for me how to setup webserver routing as you have?
I ran apitte-skeleton on Apache (without Docker) and it's still the same. The base URL of the app is https://web.localhost/aplikace/www/apitte-skeleton-master/www. Then I try https://web.localhost/aplikace/www/apitte-skeleton-master/www/api/v1/users and it always ends with "No matched route by given URL".
I run apitte-skeleton on webhosting, https://examples.contributte.org/apitte-skeleton/api/v1/users and routing works.
local.neon
file:
services:
middleware.basepath:
factory: Contributte\Middlewares\AutoBasePathMiddleware
tags:
middleware:
priority: 10
Yes, I get the 401 error as well, but if I remove middleware.authenticator, it ends up with the same error again "No matched route by given URL", even though I set middleware.basepath.
It works now: https://examples.contributte.org/apitte-skeleton/api/v1/users?_access_token=admin
It looks like there was a bug in contributte/di (https://github.com/contributte/di/commit/49d6b93d46f57be319b1e811cd983bfed0c90979).
Please use latest version https://github.com/contributte/apitte-skeleton/commit/8fe7418c28d966bce7e37e5b13c47ee7c33bbff0
Yes, it works! But I had to use the middleware autobasepath in my application.
Since version 0.10.0 without changing the code an error is always thrown "Apitte\Core\Exception\Api\ClientErrorException #404 No matched route by given URL".
After downgrading to 0.9.1, everything works better.
PHP 8.2