# An other Slim\\Exception\\ HttpNotFoundException error

**URL:** <https://discourse.slimframework.com/t/an-other-slim-exception-httpnotfoundexception-error/5316>\
**Category:** Questions\
**Created:** [July 23, 2022, 12:27pm UTC](https://discourse.slimframework.com/t/an-other-slim-exception-httpnotfoundexception-error/5316 "2022-07-23T12:27:17Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![LaBaude](https://avatars.discourse-cdn.com/v4/letter/l/8e8cbc/32.png) [@LaBaude](https://discourse.slimframework.com/u/LaBaude)\
**Post date:** [July 23, 2022, 12:27pm UTC](https://discourse.slimframework.com/t/an-other-slim-exception-httpnotfoundexception-error/5316/1 "2022-07-23T12:27:17Z")

</div>

Hello,

I tried to take over an old project, the updates broke everything so I tried to make a clean installation from scratch and integrate my old code in it.

But there is something that doesn’t work, I have this error all the time:

```php
[Sat Jul 23 14:11:41 2022] [::1]:57598 [200]: OPTIONS /tokens
[Sat Jul 23 14:11:41 2022] [::1]:57598 Closing
[Sat Jul 23 14:11:41 2022] [::1]:57600 Accepted
[Sat Jul 23 14:11:41 2022] 404 Not Found
Type: Slim\Exception\HttpNotFoundException
Code: 404
Message: Not found.
File: /home/baudouin/Documents/DEV/pvappcore-test/vendor/slim/slim/Slim/Middleware/RoutingMiddleware.php
Line: 91
Trace: #0 /home/baudouin/Documents/DEV/pvappcore-test/vendor/slim/slim/Slim/Middleware/RoutingMiddleware.php(58): Slim\Middleware\RoutingMiddleware->performRouting()
#1 /home/baudouin/Documents/DEV/pvappcore-test/vendor/slim/slim/Slim/MiddlewareDispatcher.php(147): Slim\Middleware\RoutingMiddleware->process()
#2 /home/baudouin/Documents/DEV/pvappcore-test/vendor/selective/basepath/src/BasePathMiddleware.php(52): Psr\Http\Server\RequestHandlerInterface@anonymous->handle()
#3 /home/baudouin/Documents/DEV/pvappcore-test/vendor/slim/slim/Slim/MiddlewareDispatcher.php(209): Selective\BasePath\BasePathMiddleware->process()
#4 /home/baudouin/Documents/DEV/pvappcore-test/vendor/slim/slim/Slim/Middleware/ErrorMiddleware.php(107): Psr\Http\Server\RequestHandlerInterface@anonymous->handle()
#5 /home/baudouin/Documents/DEV/pvappcore-test/vendor/slim/slim/Slim/MiddlewareDispatcher.php(147): Slim\Middleware\ErrorMiddleware->process()
#6 /home/baudouin/Documents/DEV/pvappcore-test/src/Middleware/LoginMiddleware.php(21): Psr\Http\Server\RequestHandlerInterface@anonymous->handle()
#7 /home/baudouin/Documents/DEV/pvappcore-test/vendor/slim/slim/Slim/MiddlewareDispatcher.php(313): App\Middleware\LoginMiddleware->__invoke()
#8 /home/baudouin/Documents/DEV/pvappcore-test/vendor/slim/slim/Slim/MiddlewareDispatcher.php(81): Psr\Http\Server\RequestHandlerInterface@anonymous->handle()
#9 /home/baudouin/Documents/DEV/pvappcore-test/vendor/slim/slim/Slim/App.php(215): Slim\MiddlewareDispatcher->handle()
#10 /home/baudouin/Documents/DEV/pvappcore-test/vendor/slim/slim/Slim/App.php(199): Slim\App->handle()
#11 /home/baudouin/Documents/DEV/pvappcore-test/public/index.php(3): Slim\App->run()
#12 {main}
[Sat Jul 23 14:11:41 2022] [::1]:57600 [404]: POST /tokens
[Sat Jul 23 14:11:41 2022] [::1]:57600 Closing

```

I tried a lot of things but it doesn’t work.

I have to know that during the installation I had a conflict between PHP-DI and psr/container that I had to downgrade with -W flag.

```php
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires php-di/php-di ^6.4 -> satisfiable by php-di/php-di[6.4.0].
    - php-di/php-di 6.4.0 requires psr/container ^1.0 -> found psr/container[1.0.0, 1.1.0, 1.1.1, 1.1.2] but the package is fixed to 2.0.2 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.

```

Yo can see the code here : [https://gitlab.com/LaBaude32/pvappcore-test](https://gitlab.com/LaBaude32/pvappcore-test)

I’m interested in any advice you may have!

Thx

---

<div class="post-metadata">

**Author:** ![odan](https://avatars.discourse-cdn.com/v4/letter/o/9de053/32.png) [@odan](https://discourse.slimframework.com/u/odan)\
**Post date:** [July 23, 2022, 1:52pm UTC](https://discourse.slimframework.com/t/an-other-slim-exception-httpnotfoundexception-error/5316/2 "2022-07-23T13:52:28Z")

</div>

In this case the real “issue” refers to PHP-DI as dependency. The error message is not related to the Slim router or basePath etc. as the title implies.

> php-di/php-di 6.4.0 requires psr/container ^1.0

This is a known issue with PHP-DI 6.x, see here:

- [Error installing php-di on slim 4.8 - #2 by rifalgar](https://discourse.slimframework.com/t/error-installing-php-di-on-slim-4-8/4841/2)
- [Why not use psr/container v2? · Issue #789 · PHP-DI/PHP-DI · GitHub](https://github.com/PHP-DI/PHP-DI/issues/789)

To solve this you can force composer to “downgrade” to `psr/container` v1 with:

```auto
composer require php-di/php-di --with-all-dependencies

```

This would still work with Slim since the interface is not that different.

PHP-DI 7.0 provides support for `psr/container` 2.0 interfaces.

See here: [https://github.com/PHP-DI/PHP-DI/pull/726](https://github.com/PHP-DI/PHP-DI/pull/726)

---

<div class="post-metadata">

**Author:** ![LaBaude](https://avatars.discourse-cdn.com/v4/letter/l/8e8cbc/32.png) [@LaBaude](https://discourse.slimframework.com/u/LaBaude)\
**Post date:** [July 23, 2022, 2:26pm UTC](https://discourse.slimframework.com/t/an-other-slim-exception-httpnotfoundexception-error/5316/3 "2022-07-23T14:26:12Z")

</div>

Thanks for your quick answer ! That’s what it seemed to me too.

But I already did that :

> [@odan](#):
>
> `composer require php-di/php-di --with-all-dependencies`

And my psr is already in version 1.1.2

But it does not solve my issue and i don’t know why.

---

<div class="post-metadata">

**Author:** ![odan](https://avatars.discourse-cdn.com/v4/letter/o/9de053/32.png) [@odan](https://discourse.slimframework.com/u/odan)\
**Post date:** [July 23, 2022, 3:29pm UTC](https://discourse.slimframework.com/t/an-other-slim-exception-httpnotfoundexception-error/5316/4 "2022-07-23T15:29:29Z")

</div>

I have downloaded your example project, and it works with this command. Just an idea. Maybe try to delete the vendor/ directory and the composer.lock file and run `composer update` again.

---

<div class="post-metadata">

**Author:** ![LaBaude](https://avatars.discourse-cdn.com/v4/letter/l/8e8cbc/32.png) [@LaBaude](https://discourse.slimframework.com/u/LaBaude)\
**Post date:** [July 24, 2022, 8:57am UTC](https://discourse.slimframework.com/t/an-other-slim-exception-httpnotfoundexception-error/5316/5 "2022-07-24T08:57:54Z")

</div>

Unfortunately it doesn’t change anything.  
Is it possible that the problem comes from the fact that I’m using php 8.1 ? because I saw that PHP-DI 7 seems to bring php 8 support

Edit :

There is only one route that works: home ( localhost:8000/).  
But all the others don’t work.  
You can try for example `localhost:8000/adduser` which is the only unprotected one.

```auto
{
"email": "",
"firstName": "",
"lastName": "",
"organism": "",
"password": "",
"phone": "",
"user_function": "",
"userGroup": ""
}

```

---

<div class="post-metadata">

**Author:** ![odan](https://avatars.discourse-cdn.com/v4/letter/o/9de053/32.png) [@odan](https://discourse.slimframework.com/u/odan)\
**Post date:** [July 24, 2022, 10:09am UTC](https://discourse.slimframework.com/t/an-other-slim-exception-httpnotfoundexception-error/5316/6 "2022-07-24T10:09:56Z")

</div>

I guess not, because I use PHP 8.1 on my local dev machine, and it works with your example repository.

PS: According to the routing issue.

`localhost:8000/adduser`

This will not work, because there is no route like this in your project.  
But there is a route like: `localhost:8000/api/v1/addNewUser`  
Have you tried this url?

Question: Why do you use RPC-ish URL-paths?

---

<div class="post-metadata">

**Author:** ![LaBaude](https://avatars.discourse-cdn.com/v4/letter/l/8e8cbc/32.png) [@LaBaude](https://discourse.slimframework.com/u/LaBaude)\
**Post date:** [July 24, 2022, 1:25pm UTC](https://discourse.slimframework.com/t/an-other-slim-exception-httpnotfoundexception-error/5316/7 "2022-07-24T13:25:04Z")

</div>

> [@odan](#):
>
> This will not work, because there is no route like this in your project.  
> But there is a route like: `localhost:8000/api/v1/addNewUser`  
> Have you tried this url?

Damn, I’m really stupid. I don’t work on it since 2 years.  
Indeed with the right road it works better!  
I made some fixes but I still have a problem with the tokens.

```auto
Message: Call to undefined method Lcobucci\JWT\Builder::issuedBy()
File: /home/baudouin/Documents/DEV/pvappcore-test/src/Auth/JwtAuth.php
Line: 88

```

–

> [@odan](#):
>
> Question: Why do you use RPC-ish URL-paths?

Hum I’m really do that ? 🙈 😂 . For me this is RESTfull but maybe I’m not doing it right. But i have followed you tutorial. So I probably miss something

---

<div class="post-metadata">

**Author:** ![odan](https://avatars.discourse-cdn.com/v4/letter/o/9de053/32.png) [@odan](https://discourse.slimframework.com/u/odan)\
**Post date:** [July 24, 2022, 4:26pm UTC](https://discourse.slimframework.com/t/an-other-slim-exception-httpnotfoundexception-error/5316/8 "2022-07-24T16:26:36Z")

</div>

It looks like your [JwtAuth](https://gitlab.com/LaBaude32/pvappcore-test/-/blob/main/src/Auth/JwtAuth.php#L88) class is referring to an older version of the `lcobucci/jwt` package. Do you have the latest version of the eBook? You can also read the latest article online. Please send me a private message and I can check your email address.

> For me this is RESTfull but maybe I’m not doing it right. But i have followed you tutorial. So I probably miss something

I never said that 🙂 Can you show me where I recommend to build RPC-ish URI path?

---

<div class="post-metadata">

**Author:** ![LaBaude](https://avatars.discourse-cdn.com/v4/letter/l/8e8cbc/32.png) [@LaBaude](https://discourse.slimframework.com/u/LaBaude)\
**Post date:** [July 24, 2022, 6:23pm UTC](https://discourse.slimframework.com/t/an-other-slim-exception-httpnotfoundexception-error/5316/9 "2022-07-24T18:23:16Z")

</div>

> [@odan](#):
>
> I never said that 🙂 Can you show me where I recommend to build RPC-ish URI path?

The truth is, I don’t know what an RPC-ish URI path is.  
I followed the old tutorial in 2019 when it was longer and before you created the eBook. So, since we can’t access the full version anymore, I can’t check. But as I say, this is probably me making a mistake. 😉

–

> [@odan](#):
>
> You can also read the latest article online.

Witch one ?

–

> [@odan](#):
>
> It looks like your [JwtAuth](https://gitlab.com/LaBaude32/pvappcore-test/-/blob/main/src/Auth/JwtAuth.php#L88) class is referring to an older version of the `lcobucci/jwt` package.

Yes, I am trying to reproduce the same thing I got with version 3. Actually the real repository is the one I’m trying to fix: [https://github.com/LaBaude32/PvApp\_Core](https://github.com/LaBaude32/PvApp_Core)

–

> [@odan](#):
>
> Do you have the latest version of the eBook?

No I haven’t bought it yet, but I think I will soon but until now I was a student so I had little money.

---

<div class="post-metadata">

**Author:** ![odan](https://avatars.discourse-cdn.com/v4/letter/o/9de053/32.png) [@odan](https://discourse.slimframework.com/u/odan)\
**Post date:** [July 24, 2022, 7:17pm UTC](https://discourse.slimframework.com/t/an-other-slim-exception-httpnotfoundexception-error/5316/10 "2022-07-24T19:17:58Z")

</div>

Ok, no problem. Let me explain what I mean with “RPC-ish”. RPC means “Remote Procedure Call”, where you have method names in an API like “addNewUser” or “getUser” etc… When you use a URI path like `/addNewUser` or `/getUser` then this is looking very “RPC-ish” to me. 🙂

In practice, this style is not the way how to name **RESTful** API endpoints. Instead you would combine the HTTP method and the URI path to represent the resource you are trying to fetch, change or delete.

So instead of `POST /addNewUser` you would use `POST /users`,  
and instead of `GET getUser` you would use `GET /users`.

> Witch one ?

This article is only available if you buy the eBook.

> I got with version 3

Yeah, this might be the point. The tutorial uses lcobucci/jwt v4.  
This [upgrading guide](https://lcobucci-jwt.readthedocs.io/en/stable/upgrading/) exlains how to upgrade lcobucci/jwt from version 3 to version 4. I hope it helps.
